Home My Page Projects Code Snippets Project Openings diderot
Summary Activity Tracker Tasks SCM

SCM Repository

[diderot] Diff of /branches/charisee/src/compiler/tree-il/tree-il.sml
ViewVC logotype

Diff of /branches/charisee/src/compiler/tree-il/tree-il.sml

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1444, Mon Jul 11 12:11:53 2011 UTC revision 1640, Wed Nov 16 02:19:51 2011 UTC
# Line 13  Line 13 
13      structure Op = LowOps      structure Op = LowOps
14      structure Ty = LowILTypes      structure Ty = LowILTypes
15    
   (* program properties *)  
     datatype program_prop  
       = StrandsMayDie                   (* present if strands may die *)  
       | NewStrands                      (* present if new strands may be created dynamically *)  
       | StrandCommunication             (* present is strands read the state of other strands *)  
   
16      datatype program = Program of {      datatype program = Program of {
17          props : program_prop list,          props : StrandUtil.program_prop list,
18          globals : var list,          globals : var list,
19          inputInit : block,          inputInit : block,
20          globalInit : block,          globalInit : block,
# Line 38  Line 32 
32      and strand = Strand of {      and strand = Strand of {
33          name : Atom.atom,          name : Atom.atom,
34          params : var list,          params : var list,
35          state : strand_var list,          state : state_var list,
36          stateInit : block,          stateInit : block,
37          methods : method list          methods : method list
38        }        }
39    
40      and strand_var = SV of {      and state_var = SV of {
41            name : string,          (* name (should be unique) *)
42            id : Stamp.stamp,       (* unique ID *)
43            ty : Ty.ty,             (* type *)
44          varying : bool,         (* varies over the lifetime of the strand *)          varying : bool,         (* varies over the lifetime of the strand *)
45          output : bool,          (* is the output value of the strand *)          output : bool           (* is the output value of the strand *)
         var : var               (* the variable itself *)  
46        }        }
47    
48      and method = Method of {      and method = Method of {
49          name : MethodName.name,          name : StrandUtil.method_name,
50          body : block            (* method body *)          body : block            (* method body *)
51        }        }
52    
# Line 61  Line 57 
57    
58      and stm      and stm
59        = S_Comment of string list        = S_Comment of string list
60        | S_Assign of var * exp        | S_Assign of var list * exp
61        | S_IfThen of exp * block        | S_IfThen of exp * block
62        | S_IfThenElse of exp * block * block        | S_IfThenElse of exp * block * block
63      (* special Diderot forms *)      (* special Diderot forms *)
64        | S_LoadImage of var * int * exp  (* load image data *)        | S_LoadImage of var * int * exp  (* load image data *)
65        | S_Input of var * string * string * exp option (* get input *)        | S_Input of var * string * string * exp option (* get input *)
66        | S_New of Atom.atom * exp list   (* new strand creation *)        | S_New of Atom.atom * exp list   (* new strand creation *)
67          | S_Save of state_var list * exp  (* save strand state *)
68        | S_Exit of exp list        | S_Exit of exp list
69      (* return functions for methods *)      (* return functions for methods *)
70        | S_Active of exp list        | S_Active
71        | S_Stabilize of exp list        | S_Stabilize
72        | S_Die        | S_Die
73    
74      and exp      and exp
75        = E_Var of var        = E_State of state_var
76          | E_Var of var
77        | E_Lit of Literal.literal        | E_Lit of Literal.literal
78        | E_Op of Op.rator * exp list        | E_Op of Op.rator * exp list
79        | E_Apply of ILBasis.name * exp list        | E_Apply of ILBasis.name * exp list
# Line 90  Line 88 
88    
89      and var_kind      and var_kind
90        = VK_Global                       (* global variable *)        = VK_Global                       (* global variable *)
       | VK_State of Atom.atom           (* strand state variable; argument is strand name *)  
91        | VK_Local                        (* includes strand parameters *)        | VK_Local                        (* includes strand parameters *)
92    
93      structure Var : sig      structure Var : sig
# Line 118  Line 115 
115          end (* local *)          end (* local *)
116        end        end
117    
118    (* printing utilities for debugging *)      structure StateVar : sig
119      fun propToString p = (case p          val name : state_var -> string
120             of StrandsMayDie => "StrandsMayDie"          val ty : state_var -> Ty.ty
121              | NewStrands => "NewStrands"          val isOutput : state_var -> bool
122              | StrandCommunication => "StrandCommunication"          val isVarying : state_var -> bool
123            (* end case *))          val toString : state_var -> string
124          end = struct
125            fun name (SV{name, ...}) = name
126            fun ty (SV{ty, ...}) = ty
127            fun isOutput (SV{output, ...}) = output
128            fun isVarying (SV{varying, ...}) = varying
129            fun toString (SV{name, ...}) = "self." ^ name
130          end
131    
132      fun kindToString k = (case k      fun kindToString k = (case k
133             of VK_Global => "Global"             of VK_Global => "Global"
             | VK_State s => concat["State(", Atom.toString s, ")"]  
134              | VK_Local => "Local"              | VK_Local => "Local"
135            (* end case *))            (* end case *))
136    
137        fun stateVarToString (SV{name, ...}) = "self." ^ name
138    
139    end    end

Legend:
Removed from v.1444  
changed lines
  Added in v.1640

root@smlnj-gforge.cs.uchicago.edu
ViewVC Help
Powered by ViewVC 1.0.0