-
Notifications
You must be signed in to change notification settings - Fork 103
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: parenthetical syntax for cycles
, timeout
etc.
#4608
base: master
Are you sure you want to change the base?
Changes from 3 commits
d4811e2
b6d32ec
d3b9415
3f57777
7e23ac8
b0516b0
dc5a72f
8f7df27
e5f3ca9
5eb79a3
9672a96
00b2507
3d4bb5a
d989397
892ea54
42a0471
e43b1cc
43e816c
272870b
2f22db2
b6ee8dd
812d78d
e7f13f6
ccd03db
dbe054d
835502c
b104f85
0542367
eaa577d
4f77084
38dfd70
1f61bb5
4d0d263
d472f53
48096cb
ff217f3
29110d3
463f12a
4abc9e8
261ae02
2e5b787
8c05650
f9abea4
998f689
6873747
3f4c1de
009f05d
2bbe8d5
391fedd
275e952
56d79fe
4009982
8628695
016ac58
9c611a9
ee4e2c9
4279b96
0f35682
5a9e300
3d5cdc7
e080bcb
3120931
cf7cfa4
84e42e1
b3ea1c2
6b0d54a
ebc89b4
82f2049
a7d2874
b482532
13b46f6
b5f98a9
19e8058
a0e321d
d147896
a23f97a
c475dc7
58c81b9
498dd9b
41186f3
65013fa
2f179ec
2f938cb
38fb28c
031c375
ac6928c
b9b3c17
fbaf8b4
599fe2d
30dbe01
5be4240
a5b0984
137ab9a
2b27bf9
92976f8
336de0b
8a7c490
05eb145
0a9f6c0
fb97b74
fe6107e
277789a
2a2b19a
85075eb
1982b48
a93b8e1
5a4d21f
9ae719b
f0f9436
21ce382
fff0aca
df56dcc
b7aab76
4ba0df1
8384150
360974a
309a231
64696a1
339a98e
a0d475a
c9bd84f
3bed728
cbfacdf
f1cc907
2edbcd9
83e70ab
0878d90
ec31258
ca66302
4c37385
e79c48d
b5eb704
f80ffa8
2e58517
7cb6cf0
dc37044
72900db
01e1ba6
6498fe3
f1e37a1
ccff46a
df50c8c
54794a6
7877986
76eadcd
8a67b0b
afb2c14
a850539
4ad010f
ff5c16e
1974e7d
395b2e7
316fd27
76198c0
9b3764d
f2671da
5831aaf
afa8805
b9ff9b9
152d7a3
bbf2f24
92e194c
cb17a6e
aa505ae
39438b3
fc49209
4326440
cfc0180
f1c153d
5ba40d1
d6dc3b0
ae41e7b
1fc897e
3bbf8d5
c65092e
fa9dfc6
8d8ccbe
9bf649a
5cebc01
e540954
d064586
90627c8
0284e96
6c85d13
d188121
a0b08c1
ef1f8d1
1eb1cd5
94a5bf2
98e6348
ae6d506
868c96c
7235e0a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -312,14 +312,16 @@ let funcE name sort ctrl typ_binds args typs exp = | |
note = Note.{ def with typ; eff = T.Triv }; | ||
} | ||
|
||
let recordE' = ref (fun _ -> nullE ()) (* gets correctly filled below *) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. use |
||
|
||
let callE exp1 typs exp2 = | ||
let typ = match T.promote (typ exp1) with | ||
| T.Func (_sort, control, _, _, ret_tys) -> | ||
T.codom control (fun () -> List.hd typs) (List.map (T.open_ typs) ret_tys) | ||
| T.Non -> T.Non | ||
| _ -> raise (Invalid_argument "callE expect a function") | ||
in | ||
let p = CallPrim typs in | ||
let p = CallPrim (typs, !recordE' []) in | ||
let es = [exp1; exp2] in | ||
{ it = PrimE (p, es); | ||
at = no_region; | ||
|
@@ -351,7 +353,7 @@ let orE : Ir.exp -> Ir.exp -> Ir.exp = fun e1 e2 -> | |
let impliesE : Ir.exp -> Ir.exp -> Ir.exp = fun e1 e2 -> | ||
orE (notE e1) e2 | ||
let oldE : Ir.exp -> Ir.exp = fun e -> | ||
{ it = (primE (CallPrim [typ e]) [e]).it; | ||
{ it = (primE (CallPrim ([typ e], !recordE' [])) [e]).it; | ||
at = no_region; | ||
note = Note.{ def with | ||
typ = typ e; | ||
|
@@ -771,6 +773,8 @@ let objE sort typ_flds flds = | |
|
||
let recordE flds = objE T.Object [] flds | ||
|
||
let _ = recordE' := recordE | ||
|
||
let check_call_perform_status success mk_failure = | ||
ifE | ||
(callE | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -113,7 +113,7 @@ and lexp' = | |
all call-by-value. Many passes can treat them uniformly, so they are unified | ||
using the PrimE node. *) | ||
and prim = | ||
| CallPrim of Type.typ list (* function call *) | ||
| CallPrim of Type.typ list * exp (* function call *) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I makes me nervous that prim now as subexpressions since we might miss them in traversals. For example, is closure conversion in the backend considering these? It might be safer to put these arguments in the prim argument list. |
||
| UnPrim of Type.typ * unop (* unary operator *) | ||
| BinPrim of Type.typ * binop (* binary operator *) | ||
| RelPrim of Type.typ * relop (* relational operator *) | ||
|
@@ -257,7 +257,7 @@ let replace_obj_pat pfs pats = | |
|
||
let map_prim t_typ t_id p = | ||
match p with | ||
| CallPrim ts -> CallPrim (List.map t_typ ts) | ||
| CallPrim (ts, _FIXME) -> CallPrim (List.map t_typ ts, _FIXME) | ||
| UnPrim (ot, op) -> UnPrim (t_typ ot, op) | ||
| BinPrim (ot, op) -> BinPrim (t_typ ot, op) | ||
| RelPrim (ot, op) -> RelPrim (t_typ ot, op) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -310,7 +310,7 @@ and interpret_exp_mut env exp (k : V.value V.cont) = | |
| PrimE (p, es) -> | ||
interpret_exps env es [] (fun vs -> | ||
match p, vs with | ||
| CallPrim typs, [v1; v2] -> | ||
| CallPrim (typs, _), [v1; v2] -> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. But this ignores the side-effects therein! There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yep, needs fixing |
||
let call_conv, f = V.as_func v1 in | ||
check_call_conv (List.hd es) call_conv; | ||
check_call_conv_arg env exp v2 call_conv; | ||
|
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -94,14 +94,14 @@ and assignEs vars exp : dec list = | |||||
and exp' env e : exp' = match e.it with | ||||||
| VarE _ | LitE _ -> e.it | ||||||
| AssignE (e1, e2) -> AssignE (lexp env e1, exp env e2) | ||||||
| PrimE (CallPrim insts, [e1; e2]) -> | ||||||
| PrimE (CallPrim (insts, pars), [e1; e2]) -> | ||||||
begin match e1.it, env with | ||||||
| VarE f1, { tail_pos = true; | ||||||
info = Some { func; typ_binds; temps; label; tail_called } } | ||||||
when f1 = func && are_generic_insts typ_binds insts -> | ||||||
tail_called := true; | ||||||
(blockE (assignEs temps (exp env e2)) (breakE label (unitE ()))).it | ||||||
| _,_-> PrimE (CallPrim insts, [exp env e1; exp env e2]) | ||||||
| _,_-> PrimE (CallPrim (insts, pars), [exp env e1; exp env e2]) | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
end | ||||||
| BlockE (ds, e) -> BlockE (block env ds e) | ||||||
| IfE (e1, e2, e3) -> IfE (exp env e1, tailexp env e2, tailexp env e3) | ||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thoughts on using
,
here in place of;
for consistency with other parenthesized expressions? The formatter uses this invariant (commas in parentheses, semicolons in square brackets and curly braces) to automatically replace commas with semicolons and vice versa whenever there is otherwise a syntax error that makes the AST unparseable. I can add an exception, but it seems nice to keep this pattern so that it's easier for people to remember which delimiter to use.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry for missing this comment for some time... Yeah, it is a nice consistency argument. I was stealing the syntax from the record field separators, but I guess comma works as well. Will try and report back. @crusso any gut feelings about this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd stick with
;
since these are more like fields. Would be even nicer if they just were fields...There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, they are fields, but where is it written that they cannot be separated by commas? ;-) Just playing the devil's advocate.
Anyway, I have started a branch to get a feeling for the suggestion: #4782. I am not married to either way.