mirror of
https://github.com/ProgramSnail/pass_strategy_synthesis.git
synced 2026-04-29 01:12:03 +00:00
structures: expr eval & typing
This commit is contained in:
parent
9d8dc1000c
commit
9d21c99556
1 changed files with 101 additions and 75 deletions
|
|
@ -36,6 +36,7 @@
|
||||||
#let Ref = `Ref`
|
#let Ref = `Ref`
|
||||||
#let MaybeWrite = [$diamond$ `Write`]
|
#let MaybeWrite = [$diamond$ `Write`]
|
||||||
#let AlwaysWrite = [$square$ `Write`]
|
#let AlwaysWrite = [$square$ `Write`]
|
||||||
|
#let NotWrite = [$not$ `Write`]
|
||||||
#let Read = `Read`
|
#let Read = `Read`
|
||||||
#let In = `In`
|
#let In = `In`
|
||||||
#let Out = `Out`
|
#let Out = `Out`
|
||||||
|
|
@ -111,7 +112,8 @@
|
||||||
{
|
{
|
||||||
Or[$()$][value of simple type] // `Unit`
|
Or[$()$][value of simple type] // `Unit`
|
||||||
Or[$path$][value from variable] // `Path`
|
Or[$path$][value from variable] // `Path`
|
||||||
Or[$rf expr$][reference expr] // `Ref`
|
// TODO: FIXME: decide what is the result of ref expr eval
|
||||||
|
// Or[$rf expr$][reference expr] // `Ref`
|
||||||
Or[$[expr+]$][tuple expr] // `Prod`
|
Or[$[expr+]$][tuple expr] // `Prod`
|
||||||
}
|
}
|
||||||
),
|
),
|
||||||
|
|
@ -241,18 +243,7 @@ $s in stmt, f in X, x in X, a in X$
|
||||||
#let tmode = $attach(tack.r, br: mode)$
|
#let tmode = $attach(tack.r, br: mode)$
|
||||||
|
|
||||||
#let val = `val`
|
#let val = `val`
|
||||||
#let label = `label`
|
|
||||||
#let tval = $attach(tack.r, br: val)$
|
#let tval = $attach(tack.r, br: val)$
|
||||||
#let tlabel = $attach(tack.r, br: label)$
|
|
||||||
|
|
||||||
// TODO: TMP, deprecated
|
|
||||||
// #let tetype = $attach(tack.r.double, br: type)$
|
|
||||||
// #let temode = $attach(tack.r.double, br: mode)$
|
|
||||||
// #let telabel = $attach(tack.r.double, br: label)$
|
|
||||||
|
|
||||||
#let teval = $attach(tack.r.double, br: val)$
|
|
||||||
|
|
||||||
// TODO: env mem label ??, env mem value ??
|
|
||||||
|
|
||||||
- #[ Конструирование путей по переменой
|
- #[ Конструирование путей по переменой
|
||||||
#align(center, prooftree(
|
#align(center, prooftree(
|
||||||
|
|
@ -358,66 +349,6 @@ $s in stmt, f in X, x in X, a in X$
|
||||||
))
|
))
|
||||||
]
|
]
|
||||||
|
|
||||||
// TODO: FIXME: not required (trivial) ??
|
|
||||||
// - #[ Получение метки поля
|
|
||||||
// #align(center, prooftree(
|
|
||||||
// vertical-spacing: 4pt,
|
|
||||||
// rule(
|
|
||||||
// name: [ access],
|
|
||||||
|
|
||||||
// $vals, mu tval p eqmu rf l$,
|
|
||||||
// $vals, mu tmode p arrmu l$,
|
|
||||||
// )
|
|
||||||
// ))
|
|
||||||
// ]
|
|
||||||
|
|
||||||
// TODO: not required (trivial) ??
|
|
||||||
// - #[ Получение read-write тега поля по окружению
|
|
||||||
// #align(center, prooftree(
|
|
||||||
// vertical-spacing: 4pt,
|
|
||||||
// rule(
|
|
||||||
// name: [ access],
|
|
||||||
|
|
||||||
// $x : types[x] tmode p -> cr r space w cl$,
|
|
||||||
// $sigma temode p -> cr r space w cl$,
|
|
||||||
// )
|
|
||||||
// ))
|
|
||||||
// ]
|
|
||||||
|
|
||||||
- #[ Получение значения поля по окружению
|
|
||||||
#align(center, prooftree(
|
|
||||||
vertical-spacing: 4pt,
|
|
||||||
rule(
|
|
||||||
name: [ access],
|
|
||||||
|
|
||||||
$x eqmu vals[x] tval p eqmu v$,
|
|
||||||
$types, vals, mu teval p eqmu x$,
|
|
||||||
)
|
|
||||||
))
|
|
||||||
]
|
|
||||||
|
|
||||||
// FIXME: move to new mode model
|
|
||||||
// === Mode Correctness
|
|
||||||
|
|
||||||
// Функции проверки тегов, имеют тип $mode -> #[bool]$:
|
|
||||||
|
|
||||||
// #let modevar = $(r space w space c space i space o)$
|
|
||||||
|
|
||||||
// $ isRead modevar = r == "Read" $
|
|
||||||
// $ isAlwaysWrite modevar = w == square "Write" $
|
|
||||||
// $ isPossibleWrite modevar = w == diamond "Write" || w == square "Write" $
|
|
||||||
// $ isRef modevar = c == "Ref" $
|
|
||||||
// $ isCopy modevar = c == "Copy" $
|
|
||||||
// $ isIn modevar = i == "In" $
|
|
||||||
// $ isOut modevar = o == "Out" $
|
|
||||||
|
|
||||||
// Требования к тегам:
|
|
||||||
|
|
||||||
// $ isOut mode -> isAlwaysWrite mode $
|
|
||||||
// $ isRead mode -> isIn mode $
|
|
||||||
|
|
||||||
// TODO: rest conditions ??
|
|
||||||
|
|
||||||
=== Eval Rules
|
=== Eval Rules
|
||||||
|
|
||||||
#let args = `args`
|
#let args = `args`
|
||||||
|
|
@ -812,11 +743,106 @@ $ vals in envv, types in envt, space mu in mem, space m in mode,
|
||||||
|
|
||||||
=== Expression Evaluation
|
=== Expression Evaluation
|
||||||
|
|
||||||
*TODO*
|
// TODO: check
|
||||||
|
|
||||||
|
#let eval = `eval`
|
||||||
|
#let texpre = $attach(tack.r.double, br: eval)$
|
||||||
|
|
||||||
|
#align(center, prooftree(
|
||||||
|
vertical-spacing: 4pt,
|
||||||
|
rule(
|
||||||
|
name: [ path type],
|
||||||
|
|
||||||
|
$vals, mu tval p eqmu v$,
|
||||||
|
$vals, mu texpre p eqmu v$,
|
||||||
|
)
|
||||||
|
))
|
||||||
|
|
||||||
|
#align(center, prooftree(
|
||||||
|
vertical-spacing: 4pt,
|
||||||
|
rule(
|
||||||
|
name: [ unit value type],
|
||||||
|
|
||||||
|
$vals, mu texpre () eqmu 0$,
|
||||||
|
)
|
||||||
|
))
|
||||||
|
|
||||||
|
// NOTE: tmp removed
|
||||||
|
// #align(center, prooftree(
|
||||||
|
// vertical-spacing: 4pt,
|
||||||
|
// rule(
|
||||||
|
// name: [ unit value type],
|
||||||
|
|
||||||
|
// $vals, mu texpre e : t$,
|
||||||
|
|
||||||
|
// [*TODO*],
|
||||||
|
|
||||||
|
// // TODO: reference to what ??
|
||||||
|
// $vals, mu texpre rf e eqmu rf ??$,
|
||||||
|
// )
|
||||||
|
// ))
|
||||||
|
|
||||||
|
#align(center, prooftree(
|
||||||
|
vertical-spacing: 4pt,
|
||||||
|
rule(
|
||||||
|
name: [ unit value type],
|
||||||
|
|
||||||
|
$vals, mu texpre e_1 eqmu v_1$,
|
||||||
|
$...$,
|
||||||
|
$vals, mu texpre e_n eqmu v_n$,
|
||||||
|
$vals, mu texpre [e_1, ... e_n] eqmu [v_1, ... v_n]$,
|
||||||
|
)
|
||||||
|
))
|
||||||
|
|
||||||
|
|
||||||
=== Expresion Typing
|
=== Expresion Typing
|
||||||
|
|
||||||
*TODO*
|
// TODO: check
|
||||||
|
|
||||||
|
#let texprt = $attach(tack.r.double, br: type)$
|
||||||
|
|
||||||
|
#align(center, prooftree(
|
||||||
|
vertical-spacing: 4pt,
|
||||||
|
rule(
|
||||||
|
name: [ path type],
|
||||||
|
|
||||||
|
$types ttype p : t$,
|
||||||
|
$types texprt p : t$,
|
||||||
|
)
|
||||||
|
))
|
||||||
|
|
||||||
|
#align(center, prooftree(
|
||||||
|
vertical-spacing: 4pt,
|
||||||
|
rule(
|
||||||
|
name: [ unit value type],
|
||||||
|
|
||||||
|
$types texprt () : cl Read, NotWrite cr$,
|
||||||
|
)
|
||||||
|
))
|
||||||
|
|
||||||
|
// NOTE: tmp removed
|
||||||
|
// #align(center, prooftree(
|
||||||
|
// vertical-spacing: 4pt,
|
||||||
|
// rule(
|
||||||
|
// name: [ unit value type],
|
||||||
|
|
||||||
|
// $types texprt e : t$,
|
||||||
|
// // TODO: why Ref mode ?? <- due to immutability ??
|
||||||
|
// $types texprt rf e : rf Ref t$,
|
||||||
|
// )
|
||||||
|
// ))
|
||||||
|
|
||||||
|
#align(center, prooftree(
|
||||||
|
vertical-spacing: 4pt,
|
||||||
|
rule(
|
||||||
|
name: [ unit value type],
|
||||||
|
|
||||||
|
$types texprt e_1 : t_1$,
|
||||||
|
$...$,
|
||||||
|
$types texprt e_n : t_n$,
|
||||||
|
$types texprt [e_1, ... e_n] : [t_1, ... t_n]$,
|
||||||
|
)
|
||||||
|
))
|
||||||
|
|
||||||
=== Function Evaluation
|
=== Function Evaluation
|
||||||
|
|
||||||
|
|
@ -919,7 +945,7 @@ $ vals in envv, types in envt, space mu in mem, space m in mode,
|
||||||
rule(
|
rule(
|
||||||
name: [ READ $p$],
|
name: [ READ $p$],
|
||||||
|
|
||||||
$mu, types, vals teval p eqmu 0$,
|
$mu, types, vals tval p eqmu 0$,
|
||||||
|
|
||||||
$cl types, vals, mu cr
|
$cl types, vals, mu cr
|
||||||
xarrow("READ" p)
|
xarrow("READ" p)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue