Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
48 commits
Select commit Hold shift + click to select a range
be5e40a
modified Ir.ml and desugar.ml to preserve types
crusso Jan 4, 2019
e9d5dbb
tidy
crusso Jan 7, 2019
e1e93b8
use semantic, not syntactic types in IR
crusso Jan 7, 2019
f44d211
remove inst type from syntax (now redundant)
crusso Jan 8, 2019
cb4cd53
update tests to reflect new arrange output
crusso Jan 8, 2019
535449c
simplify note on typ_bind to typ from Con.t ref
crusso Jan 8, 2019
d828378
simplify pat annotations to typ from note_typ
crusso Jan 8, 2019
e96576b
simply annotation on types to typ from typ_note
crusso Jan 8, 2019
a6292f3
simplify annotation on types to typ from typ_note
crusso Jan 8, 2019
ef0710b
Merge branch 'claudio/check-ir' of github.com:dfinity-lab/actorscript…
crusso Jan 8, 2019
f87144e
check_ir.ml: WIP: checking of types (only)
crusso Jan 9, 2019
064ba0f
WIP: almost working check-ir
crusso Jan 10, 2019
6ac59b1
desugar ClassD into TypD and FuncD; fix intial env in call oo check IR
crusso Jan 11, 2019
38c3849
ironing out bugs
crusso Jan 12, 2019
cbc74ed
fix async lowering to also lower (new) type and kind annotations on …
crusso Jan 14, 2019
cda0233
rename typbind to typ_bind, conid to con_id
crusso Jan 14, 2019
efcecd1
check IR.ActorE and NewObj properly
crusso Jan 15, 2019
190303b
add element type annotation to Ir.ArrayE and fix broken annotations i…
crusso Jan 21, 2019
137a4b6
annoted blocks with type after avoidance to enable checking of ir
crusso Jan 21, 2019
62fd1c8
updated tests to reflect new type annotations
crusso Jan 21, 2019
79535db
remove typ_env from IR scope; replace note_typ assigment with type eq…
crusso Jan 22, 2019
cc70ebe
annotate DotE with obj_sort to simplify desugaring (in next commit)
crusso Jan 22, 2019
d64ff0b
remove con_env from desugar.ml, now that DotE is sort annotated
crusso Jan 22, 2019
7408f0f
use Type.compare_field, not lexicographic compare, for ordering field…
crusso Jan 22, 2019
50306df
trivial code fixes
crusso Jan 23, 2019
82eea3f
remove unfold_obj in favour of Type.promote
crusso Jan 23, 2019
394e023
WIP, simplify check_ir to do less inference using annotations (or, in…
crusso Jan 24, 2019
b0814dc
ir checker: remove redundant pat code
crusso Jan 24, 2019
e443d67
restore checks on FuncD and DecD
crusso Jan 24, 2019
3c93dc8
gather block scope in a single pass; remove commented out code
crusso Jan 24, 2019
b2ded26
more checking, less inference, cleanup
crusso Jan 24, 2019
9d2d880
remove pre field from env
crusso Jan 24, 2019
b900265
check_ir: fail on first error, no recovery
crusso Jan 24, 2019
f1e81e4
add check for async body, remove check_lit
crusso Jan 24, 2019
be09e7a
spacing
crusso Jan 24, 2019
f5b5256
clean up desugarer a little
crusso Jan 24, 2019
8a6e2ca
add IR effect inference and checking of effects in check-ir; eventual…
crusso Jan 24, 2019
6bfcefd
restored ir-checking that was masking failing build
crusso Jan 25, 2019
fc05eb9
WIP; rewrite check_ir to avoid inference
crusso Jan 26, 2019
ff32768
cleanup
crusso Jan 26, 2019
53245d9
remove infer_pat*; replace by check_pat*; rename other infer_ to type_
crusso Jan 26, 2019
8f6c193
revise typing.ml to (re) annotate rvalues with dereferenced type; sim…
crusso Jan 26, 2019
1e5001f
address joachim's comments and refactor some remaining error as checks
crusso Jan 30, 2019
47ad813
refactor <~
crusso Jan 30, 2019
7b15375
add comments to T.Non <: ... cases
crusso Jan 30, 2019
8e27294
merge with master
crusso Jan 30, 2019
775a3af
merge fixes
crusso Jan 30, 2019
5783355
Merge branch 'master' into claudio/check-ir
nomeata Jan 30, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 12 additions & 11 deletions src/arrange.ml
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@ let rec exp e = match e.it with
| TupE es -> "TupE" $$ List.map exp es
| ProjE (e, i) -> "ProjE" $$ [exp e; Atom (string_of_int i)]
| ObjE (s, i, efs) -> "ObjE" $$ [obj_sort s; id i] @ List.map exp_field efs
| DotE (e, n) -> "DotE" $$ [exp e; name n]
| DotE (e, sr, n) -> "DotE" $$ [exp e; obj_sort' !sr; name n]
| AssignE (e1, e2) -> "AssignE" $$ [exp e1; exp e2]
| ArrayE (m, es) -> "ArrayE" $$ [mut m] @ List.map exp es
| IdxE (e1, e2) -> "IdxE" $$ [exp e1; exp e2]
| CallE (e1, ts, e2) -> "CallE" $$ [exp e1] @ List.map inst ts @ [exp e2]
| BlockE ds -> "BlockE" $$ List.map dec ds
| CallE (e1, ts, e2) -> "CallE" $$ [exp e1] @ List.map typ ts @ [exp e2]
| BlockE (ds, ot) -> "BlockE" $$ List.map dec ds @ [operator_type (!ot)]
| NotE e -> "NotE" $$ [exp e]
| AndE (e1, e2) -> "AndE" $$ [exp e1; exp e2]
| OrE (e1, e2) -> "OrE" $$ [exp e1; exp e2]
Expand All @@ -36,7 +36,7 @@ let rec exp e = match e.it with
| AssertE e -> "AssertE" $$ [exp e]
| IsE (e1, e2) -> "IsE" $$ [exp e1; exp e2]
| AnnotE (e, t) -> "AnnotE" $$ [exp e; typ t]
| DecE d -> "DecE" $$ [dec d]
| DecE (d, ot) -> "DecE" $$ [dec d ; operator_type !ot]
| OptE e -> "OptE" $$ [exp e]
| PrimE p -> "PrimE" $$ [Atom p]
| DeclareE (i, t, e1) -> "DeclareE" $$ [id i; exp e1]
Expand Down Expand Up @@ -109,11 +109,13 @@ and sharing sh = match sh with
and control c = match c with
| Type.Returns -> "Returns"
| Type.Promises -> "Promises"
and obj_sort s = match s.it with

and obj_sort' s = match s with
| Type.Object sh -> Atom ("Object " ^ sharing sh)
| Type.Actor -> Atom "Actor"

and obj_sort s = obj_sort' s.it

and func_sort s = match s.it with
| Type.Call sh -> Atom ("Call " ^ sharing sh)
| Type.Construct -> Atom "Construct"
Expand All @@ -135,8 +137,6 @@ and typ_bind (tb : typ_bind)
and exp_field (ef : exp_field)
= (string_of_name ef.it.name.it) $$ [id ef.it.id; exp ef.it.exp; mut ef.it.mut; priv ef.it.priv]

and inst t = typ t.it

and operator_type t = Atom (Type.string_of_typ t)

and typ t = match t.it with
Expand All @@ -152,6 +152,7 @@ and typ t = match t.it with
| ParT t -> "ParT" $$ [typ t]

and id i = Atom i.it
and con_id i = Atom i.it

and name n = Atom (string_of_name n.it)

Expand All @@ -170,8 +171,8 @@ and dec d = match d.it with
exp e
]
| TypD (i, tp, t) ->
"TypD" $$ [id i] @ List.map typ_bind tp @ [typ t]
"TypD" $$ [con_id i] @ List.map typ_bind tp @ [typ t]
| ClassD (i, j, tp, s, p, i', efs) ->
"ClassD" $$ id i :: id j :: List.map typ_bind tp @ [obj_sort s; pat p; id i'] @ List.map exp_field efs
"ClassD" $$ id i :: con_id j :: List.map typ_bind tp @ [obj_sort s; pat p; id i'] @ List.map exp_field efs

and prog prog = "BlockE" $$ List.map dec prog.it
and prog prog = "BlockE" $$ List.map dec prog.it
33 changes: 18 additions & 15 deletions src/arrange_ir.ml
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
open Source
open Arrange_type (* currently not used *)
open Ir
open Wasm.Sexpr

let ($$) head inner = Node (head, inner)
(* for concision, we shadow the imported definition of [Arrange_type.typ] and pretty print types instead *)

let typ t = Atom (Type.string_of_typ t)
let kind k = Atom (Type.string_of_kind k)

let rec exp e = match e.it with
| VarE i -> "VarE" $$ [id i]
Expand All @@ -12,21 +16,21 @@ let rec exp e = match e.it with
| RelE (t, e1, ro, e2)-> "RelE" $$ [typ t; exp e1; Arrange.relop ro; exp e2]
| TupE es -> "TupE" $$ List.map exp es
| ProjE (e, i) -> "ProjE" $$ [exp e; Atom (string_of_int i)]
| ActorE (i, efs) -> "ActorE" $$ [id i] @ List.map exp_field efs
| ActorE (i, efs, t) -> "ActorE" $$ [id i] @ List.map exp_field efs @ [typ t]
| DotE (e, n) -> "DotE" $$ [exp e; name n]
| ActorDotE (e, n) -> "ActorDotE" $$ [exp e; name n]
| AssignE (e1, e2) -> "AssignE" $$ [exp e1; exp e2]
| ArrayE (m, es) -> "ArrayE" $$ [Arrange.mut m] @ List.map exp es
| ArrayE (m, t, es) -> "ArrayE" $$ [Arrange.mut m; typ t] @ List.map exp es
| IdxE (e1, e2) -> "IdxE" $$ [exp e1; exp e2]
| CallE (cc, e1, ts, e2) -> "CallE" $$ [call_conv cc; exp e1] @ List.map Arrange.typ ts @ [exp e2]
| BlockE ds -> "BlockE" $$ List.map dec ds
| CallE (cc, e1, ts, e2) -> "CallE" $$ [call_conv cc; exp e1] @ List.map typ ts @ [exp e2]
| BlockE (ds, t) -> "BlockE" $$ List.map dec ds @ [typ t]
| IfE (e1, e2, e3) -> "IfE" $$ [exp e1; exp e2; exp e3]
| SwitchE (e, cs) -> "SwitchE" $$ [exp e] @ List.map case cs
| WhileE (e1, e2) -> "WhileE" $$ [exp e1; exp e2]
| LoopE (e1, None) -> "LoopE" $$ [exp e1]
| LoopE (e1, Some e2) -> "LoopE" $$ [exp e1; exp e2]
| ForE (p, e1, e2) -> "ForE" $$ [pat p; exp e1; exp e2]
| LabelE (i, t, e) -> "LabelE" $$ [id i; Arrange.typ t; exp e]
| LabelE (i, t, e) -> "LabelE" $$ [id i; typ t; exp e]
| BreakE (i, e) -> "BreakE" $$ [id i; exp e]
| RetE e -> "RetE" $$ [exp e]
| AsyncE e -> "AsyncE" $$ [exp e]
Expand All @@ -37,9 +41,9 @@ let rec exp e = match e.it with
| PrimE p -> "PrimE" $$ [Atom p]
| DeclareE (i, t, e1) -> "DeclareE" $$ [id i; exp e1]
| DefineE (i, m, e1) -> "DefineE" $$ [id i; Arrange.mut m; exp e1]
| NewObjE (s, nameids)-> "NewObjE" $$ (Arrange.obj_sort s ::
| NewObjE (s, nameids, t)-> "NewObjE" $$ (Arrange.obj_sort s ::
List.fold_left (fun flds (n,i) ->
(name n)::(id i):: flds) [] nameids)
(name n)::(id i):: flds) [typ t] nameids)

and pat p = match p.it with
| WildP -> Atom "WildP"
Expand All @@ -51,13 +55,9 @@ and pat p = match p.it with

and case c = "case" $$ [pat c.it.pat; exp c.it.exp]

and typ t = Atom (Type.string_of_typ t)

and exp_field (ef : exp_field)
= (Syntax.string_of_name ef.it.name.it) $$ [id ef.it.id; exp ef.it.exp; Arrange.mut ef.it.mut; Arrange.priv ef.it.priv]

and id i = Atom i.it

and name n = Atom (Syntax.string_of_name n.it)

and call_conv cc = Atom (Value.string_of_call_conv cc)
Expand All @@ -67,8 +67,11 @@ and dec d = match d.it with
| LetD (p, e) -> "LetD" $$ [pat p; exp e]
| VarD (i, e) -> "VarD" $$ [id i; exp e]
| FuncD (cc, i, tp, p, t, e) ->
"FuncD" $$ [call_conv cc; id i] @ List.map Arrange.typ_bind tp @ [pat p; Arrange.typ t; exp e]
| TypD (i, tp, t) ->
"TypD" $$ [id i] @ List.map Arrange.typ_bind tp @ [Arrange.typ t]
"FuncD" $$ [call_conv cc; id i] @ List.map typ_bind tp @ [pat p; typ t; exp e]
| TypD (c,k) ->
"TypD" $$ [con c; kind k]

and typ_bind (tb : typ_bind) =
tb.it.Type.var $$ [typ tb.it.Type.bound]

and prog prog = "BlockE" $$ List.map dec prog.it
63 changes: 63 additions & 0 deletions src/arrange_type.ml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
open Source
open Type
open Wasm.Sexpr

let ($$) head inner = Node (head, inner)

let id i = Atom i.it

let rec sharing sh = match sh with
| Type.Local -> "Local"
| Type.Sharable -> "Sharable"

and control c = match c with
| Type.Returns -> "Returns"
| Type.Promises -> "Promises"

and obj_sort s = match s with
| Type.Object sh -> Atom ("Object " ^ sharing sh)
| Type.Actor -> Atom "Actor"

and func_sort s = match s with
| Type.Call sh -> Atom ("Call " ^ sharing sh)
| Type.Construct -> Atom "Construct"

and prim p = match p with
| Null -> Atom "Null"
| Bool -> Atom "Bool"
| Nat -> Atom "Nat"
| Int -> Atom "Int"
| Word8 -> Atom "Word8"
| Word16 -> Atom "Word16"
| Word32 -> Atom "Word32"
| Word64 -> Atom "Word64"
| Float -> Atom "Float"
| Char -> Atom "Char"
| Text -> Atom "Text"

and con c = Atom (Con.to_string c)

let rec typ (t:Type.typ) = match t with
| Var (s, i) -> "Var" $$ [Atom s; Atom (string_of_int i)]
| Con (c,ts) -> "Con" $$ (con c::List.map typ ts)
| Prim p -> "Prim" $$ [prim p]
| Obj (s, ts) -> "Obj" $$ [obj_sort s] @ List.map typ_field ts
| Array t -> "Array" $$ [typ t]
| Opt t -> "Opt" $$ [typ t]
| Tup ts -> "Tup" $$ List.map typ ts
| Func (s, c, tbs, at, rt) -> "Func" $$ [func_sort s; Atom (control c)] @ List.map typ_bind tbs @ [ "" $$ (List.map typ at); "" $$ (List.map typ rt)]
| Async t -> "Async" $$ [typ t]
| Like t -> "Like" $$ [typ t]
| Mut t -> "Mut" $$ [typ t]
| Class -> Atom "Class"
| Shared -> Atom "Shared"
| Any -> Atom "Any"
| Non -> Atom "Non"
| Pre -> Atom "Pre"

and typ_bind (tb : Type.bind) =
tb.var $$ [typ tb.bound]

and typ_field (tf : Type.field) =
tf.name $$ [typ tf.typ]

Loading