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

SCM Repository

[diderot] Diff of /branches/pure-cfg/src/compiler/codegen/clang.sml
ViewVC logotype

Diff of /branches/pure-cfg/src/compiler/codegen/clang.sml

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

revision 615, Sun Mar 13 14:36:05 2011 UTC revision 616, Sun Mar 13 14:52:11 2011 UTC
# Line 59  Line 59 
59        = E_Grp of exp                    (* "(" e ")" *)        = E_Grp of exp                    (* "(" e ")" *)
60        | E_BinOp of exp * binop * exp    (* e op e *)        | E_BinOp of exp * binop * exp    (* e op e *)
61        | E_UnOp of unop * exp            (* op e *)        | E_UnOp of unop * exp            (* op e *)
62          | E_PostOp of exp * postfix       (* e op *)
63        | E_Apply of string * exp list    (* f "(" ... ")" *)        | E_Apply of string * exp list    (* f "(" ... ")" *)
64        | E_Subscript of exp * exp        (* e "[" e "]" *)        | E_Subscript of exp * exp        (* e "[" e "]" *)
65        | E_Select of exp * string        (* e "." f *)        | E_Select of exp * string        (* e "." f *)
# Line 80  Line 81 
81        | #+ | #-        | #+ | #-
82        | #* | #/ | #%        | #* | #/ | #%
83    
84      and unop = %- | %! | %& | %* | %~      and unop = %- | %! | %& | %* | %~ | %++ | %--
85    
86        and postfix = ^++ | ^--
87    
88    (* smart constructors that add E_Grp wrappers based on operator precedence *)    (* smart constructors that add E_Grp wrappers based on operator precedence *)
89      local      local
# Line 113  Line 116 
116              (* end case *))              (* end case *))
117        fun prec (E_Grp _) = atomP        fun prec (E_Grp _) = atomP
118          | prec (E_BinOp(_, rator, _)) = precOfBinop rator          | prec (E_BinOp(_, rator, _)) = precOfBinop rator
119          | prec (E_UnOp(rator, _)) = preP          | prec (E_UnOp _) = preP
120            | prec (E_PostOp _) = postP
121          | prec (E_Apply _) = callP          | prec (E_Apply _) = callP
122          | prec (E_Subscript _) = postP          | prec (E_Subscript _) = postP
123          | prec (E_Select _) = postP          | prec (E_Select _) = postP
# Line 138  Line 142 
142      fun mkUnOp (rator, e) = if prec e < unaryP      fun mkUnOp (rator, e) = if prec e < unaryP
143            then E_UnOp(rator, E_Grp e)            then E_UnOp(rator, E_Grp e)
144            else E_UnOp(rator, e)            else E_UnOp(rator, e)
145        fun mkPostOp (e, rator) = if prec e < postP
146              then E_PostOp(E_Grp e, rator)
147              else E_PostOp(e, rator)
148      fun mkApply (f, args) = E_Apply(f, args)      fun mkApply (f, args) = E_Apply(f, args)
149      fun mkSubscript(e1, e2) = if prec e1 < postP      fun mkSubscript(e1, e2) = if prec e1 < postP
150            then E_Subscript(E_Grp e1, e2)            then E_Subscript(E_Grp e1, e2)
# Line 200  Line 207 
207              | %& => "&"              | %& => "&"
208              | %* => "*"              | %* => "*"
209              | %~ => "~"              | %~ => "~"
210                | %++ => "++"
211                | %-- => "--"
212              (* end case *))
213    
214        fun postopToString rator = (case rator
215               of ^++ => "++"
216                | ^-- => "--"
217            (* end case *))            (* end case *))
218    
219      fun expToString e = let      fun expToString e = let
# Line 207  Line 221 
221                 of E_Grp e => "(" :: e2s(e, ")"::l)                 of E_Grp e => "(" :: e2s(e, ")"::l)
222                  | E_BinOp(e1, rator, e2) => e2s(e1, binopToString rator :: e2s(e2, l))                  | E_BinOp(e1, rator, e2) => e2s(e1, binopToString rator :: e2s(e2, l))
223                  | E_UnOp(rator, e) => unopToString rator :: e2s(e, l)                  | E_UnOp(rator, e) => unopToString rator :: e2s(e, l)
224                    | E_PostOp(e, rator) => e2s(e, postopToString rator :: l)
225                  | E_Apply(f, es) => let                  | E_Apply(f, es) => let
226                      fun args2s ([], l) = l                      fun args2s ([], l) = l
227                        | args2s ([e], l) = e2s(e, l)                        | args2s ([e], l) = e2s(e, l)

Legend:
Removed from v.615  
changed lines
  Added in v.616

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