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

SCM Repository

[diderot] Diff of /trunk/src/compiler/codegen/clang.sml
ViewVC logotype

Diff of /trunk/src/compiler/codegen/clang.sml

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

revision 2355, Sun Apr 7 11:35:08 2013 UTC revision 2356, Sun Apr 7 14:45:25 2013 UTC
# Line 24  Line 24 
24      datatype typed_var = V of ty * var      datatype typed_var = V of ty * var
25    
26      val voidTy = T_Named "void"      val voidTy = T_Named "void"
27        val voidPtr = T_Ptr voidTy
28      val charTy = T_Named "char"      val charTy = T_Named "char"
29      val boolTy = T_Named "bool"      val boolTy = T_Named "bool"
30      val charPtr = T_Ptr(charTy)      val charPtr = T_Ptr charTy
31      val charArrayPtr = T_Ptr(charPtr)      val charArrayPtr = T_Ptr charPtr
32      val intTy = T_Named "int"      val intTy = T_Named "int"
33      val int8 = T_Num(RawTypes.RT_Int8)      val int8 = T_Num(RawTypes.RT_Int8)
34      val uint8 = T_Num(RawTypes.RT_UInt8)      val uint8 = T_Num(RawTypes.RT_UInt8)
# Line 38  Line 39 
39      val double = T_Num(RawTypes.RT_Double)      val double = T_Num(RawTypes.RT_Double)
40    
41      datatype decl      datatype decl
42        = D_Comment of string list        = D_Pragma of string list
43          | D_Comment of string list
44      (* verbatim text (e.g., preprocessor directives) *)      (* verbatim text (e.g., preprocessor directives) *)
45        | D_Verbatim of string list        | D_Verbatim of string list
46      (* global variable declaration *)      (* global variable declaration *)
# Line 62  Line 64 
64      and stm      and stm
65        = S_Block of stm list             (* "{" stms "}" *)        = S_Block of stm list             (* "{" stms "}" *)
66        | S_Comment of string list        | S_Comment of string list
67          | S_Verbatim of string list
68        | S_Decl of attr list * ty * var * initializer option        | S_Decl of attr list * ty * var * initializer option
69                                          (* ty var [ '=' exp ]';' *)                                          (* ty var [ '=' exp ]';' *)
70        | S_Exp of exp                    (* exp ';' *)        | S_Exp of exp                    (* exp ';' *)
# Line 198  Line 201 
201        | mkUnOp (%-, e as E_UnOp(%--, _)) = E_UnOp(%-, E_Grp e)        | mkUnOp (%-, e as E_UnOp(%--, _)) = E_UnOp(%-, E_Grp e)
202        | mkUnOp (%--, e as E_UnOp(%-, _)) = E_UnOp(%--, E_Grp e)        | mkUnOp (%--, e as E_UnOp(%-, _)) = E_UnOp(%--, E_Grp e)
203        | mkUnOp (%--, e as E_UnOp(%--, _)) = E_UnOp(%--, E_Grp e)        | mkUnOp (%--, e as E_UnOp(%--, _)) = E_UnOp(%--, E_Grp e)
204          | mkUnOp (%&, E_UnOp(%*, e)) = e
205          | mkUnOp (%*, E_UnOp(%&, e)) = e
206        | mkUnOp (rator, e) = if prec e < unaryP        | mkUnOp (rator, e) = if prec e < unaryP
207            then E_UnOp(rator, E_Grp e)            then E_UnOp(rator, E_Grp e)
208            else E_UnOp(rator, e)            else E_UnOp(rator, e)
# Line 237  Line 242 
242      val mkComment = S_Comment      val mkComment = S_Comment
243      fun mkBlock [stm] = stm      fun mkBlock [stm] = stm
244        | mkBlock stms = S_Block stms        | mkBlock stms = S_Block stms
245        fun unBlock (S_Block stms) = stms
246          | unBlock stm = [stm]
247        fun prependStm (stm, blk) = mkBlock(stm :: unBlock blk)
248        fun appendStm (blk, stm) = mkBlock(unBlock blk @ [stm])
249      fun mkDecl (ty, x, init) = S_Decl([], ty, x, init)      fun mkDecl (ty, x, init) = S_Decl([], ty, x, init)
250      fun mkDeclInit (ty, x, init) = S_Decl([], ty, x, SOME(I_Exp init))      fun mkDeclInit (ty, x, init) = S_Decl([], ty, x, SOME(I_Exp init))
251      val mkAttrDecl = S_Decl      val mkAttrDecl = S_Decl
# Line 313  Line 322 
322     *)     *)
323      local      local
324        structure SS = Substring        structure SS = Substring
     in  
325      fun verbatim sl subs = let      fun verbatim sl subs = let
326            fun scan (start, ss, n, frags) = (case SS.getc ss            fun scan (start, ss, n, frags) = (case SS.getc ss
327                   of SOME(#"@", rest) => let                   of SOME(#"@", rest) => let
# Line 346  Line 354 
354                    scan (ss, ss, 0, [])                    scan (ss, ss, 0, [])
355                  end                  end
356            in            in
357              D_Verbatim(List.map expand sl)                List.map expand sl
358            end            end
359        in
360        fun verbatimDcl sl subs = D_Verbatim(verbatim sl subs)
361        fun verbatimStm sl subs = S_Verbatim(verbatim sl subs)
362      end (* local *)      end (* local *)
363    
364    (* for debugging (not syntactically correct!) *)    (* for debugging (not syntactically correct!) *)
# Line 369  Line 380 
380                  | E_Subscript(e1, e2) => e2s(e1, "[" :: e2s(e2, "]"::l))                  | E_Subscript(e1, e2) => e2s(e1, "[" :: e2s(e2, "]"::l))
381                  | E_Select(e, f) => e2s(e, "." :: f :: l)                  | E_Select(e, f) => e2s(e, "." :: f :: l)
382                  | E_Indirect(e, f) => e2s(e, "->" :: f :: l)                  | E_Indirect(e, f) => e2s(e, "->" :: f :: l)
383                  | E_Cast(ty, e) => "(ty)" :: e2s(e, l)  (* FIXME *)                  | E_Cast(ty, e) => "(ty)" :: e2s(e, l)  (* FIXME: need tyToString *)
384                  | E_Var x => x::l                  | E_Var x => x::l
385                  | E_Int(n, _) => IntegerLit.toString n :: l                  | E_Int(n, _) => IntegerLit.toString n :: l
386                  | E_Flt(f, _) => FloatLit.toString f :: l                  | E_Flt(f, _) => FloatLit.toString f :: l

Legend:
Removed from v.2355  
changed lines
  Added in v.2356

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