18 |
structure TU = TypeUtil |
structure TU = TypeUtil |
19 |
structure U = Util |
structure U = Util |
20 |
|
|
21 |
|
(* standard method names *) |
22 |
|
val stabilizeAtom = Atom.atom "stabilize" |
23 |
|
val updateAtom = Atom.atom "update" |
24 |
|
|
25 |
datatype scope = GlobalScope | StrandScope | MethodScope | InitScope |
datatype scope = GlobalScope | StrandScope | MethodScope | InitScope |
26 |
|
|
27 |
type env = {scope : scope, env : Env.env} |
type env = {scope : scope, env : Env.env} |
479 |
end |
end |
480 |
(* check the strand methods *) |
(* check the strand methods *) |
481 |
val methods = List.map (fn m => checkMethod (env, cxt, m)) methods |
val methods = List.map (fn m => checkMethod (env, cxt, m)) methods |
482 |
|
(* get the set of methods defined by the user *) |
483 |
|
val methodNames = List.foldl |
484 |
|
(fn (AST.M_Method(name, _), names) => AtomSet.add(names, name)) |
485 |
|
AtomSet.empty |
486 |
|
methods |
487 |
|
(* if the stabilize method is not provided, add one *) |
488 |
|
val methods = if AtomSet.member(methodNames, stabilizeAtom) |
489 |
|
then methods |
490 |
|
else methods @ [AST.M_Method(stabilizeAtom, AST.S_Block[])] |
491 |
in |
in |
492 |
|
if not(AtomSet.member(methodNames, updateAtom)) |
493 |
|
then err(cxt, [S "strand ", A name, S " is missing an update method"]) |
494 |
|
else (); |
495 |
AST.D_Strand{name = name, params = params, state = vds, methods = methods} |
AST.D_Strand{name = name, params = params, state = vds, methods = methods} |
496 |
end |
end |
497 |
|
|