SCM Repository
View of /trunk/src/compiler/simplify/simple.sml
Parent Directory
|
Revision Log
Revision 171 -
(download)
(annotate)
Sat Jul 24 14:13:10 2010 UTC (11 years, 9 months ago) by jhr
File size: 1879 byte(s)
Sat Jul 24 14:13:10 2010 UTC (11 years, 9 months ago) by jhr
File size: 1879 byte(s)
Adding simple-ast representation
(* simple.sml * * COPYRIGHT (c) 2010 The Diderot Project (http://diderot.cs.uchicago.edu) * All rights reserved. * * A simplified AST representation of a Diderot program *) structure Simple = struct datatype var_kind = datatype AST.var_kind datatype var = datatype AST.var datatype program = Prog of { globals : var list, globalInit : stmt, actors : actor list (* initialization *) } and actor = Actor of { params : var list, state : var list, stateInit : stmt, methods : method list } and method = M_Method of Atom.atom * stmt and stmt = S_Block of stmt list | S_Assign of var * exp | S_IfThenElse of var * stmt * stmt | S_New of Atom.atom * var list | S_Die | S_Stabilize and exp = E_Var of var | E_Lit of Literal.literal | E_Tuple of var list | E_Apply of var * Types.meta_var list * var list * Types.ty | E_Cons of var list and create = C_Create of { argInit : stmt, name : Atom.atom, args : var list } and iter = I_Range of { rangeInit : stmt, param : var, lo : var, hi : var } fun typeOf (E_Var x) = Var.monoTypeOf x | typeOf (E_Lit lit) = (case lit of (Literal.Int _) => Types.T_Int | (Literal.Float _) => Types.realTy | (Literal.String s) => Types.T_String | (Literal.Bool _) => Types.T_Bool (* end case *)) | typeOf (E_Tuple _) = raise Fail "E_Tuple" | typeOf (E_Apply(_, _, _, ty)) = ty | typeOf (E_Cons(x::xs)) = let val d = List.length xs + 1 val ty = Var.monoTypeOf x in case ty of Types.T_Tensor shape => Types.T_Tensor(Types.shapeExt(shape, Types.DimConst d)) | _ => raise Fail "element of tensor construction not tensor" (* end case *) end | typeOf (E_Cons[]) = raise Fail "impossible empty E_Cons" end
root@smlnj-gforge.cs.uchicago.edu | ViewVC Help |
Powered by ViewVC 1.0.0 |