Home My Page Projects Code Snippets Project Openings SML/NJ
Summary Activity Forums Tracker Lists Tasks Docs Surveys News SCM Files

SCM Repository

[smlnj] Diff of /sml/trunk/src/ml-nlffigen/ast-to-spec.sml
ViewVC logotype

Diff of /sml/trunk/src/ml-nlffigen/ast-to-spec.sml

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

revision 845, Thu Jun 21 16:25:49 2001 UTC revision 846, Mon Jun 25 16:06:46 2001 UTC
# Line 10  Line 10 
10      structure A = Ast      structure A = Ast
11      structure B = Bindings      structure B = Bindings
12    
13        exception VoidType
14    
15      fun bug m = raise Fail ("AstToSpec: bug: " ^ m)      fun bug m = raise Fail ("AstToSpec: bug: " ^ m)
16      fun err m = raise Fail ("AstToSpec: error: " ^ m)      fun err m = raise Fail ("AstToSpec: error: " ^ m)
17      fun warn m = TextIO.output (TextIO.stdErr, "AstToSpec: warning: " ^ m)      fun warn m = TextIO.output (TextIO.stdErr, "AstToSpec: warning: " ^ m)
# Line 79  Line 81 
81                   end)                   end)
82            | tagname (SOME n, _) = n            | tagname (SOME n, _) = n
83    
84          fun valty A.Void = err "void variable type"          fun valty A.Void = raise VoidType
85            | valty A.Ellipses = err "ellipses variable type"            | valty A.Ellipses = err "ellipses variable type"
86            | valty (A.Qual (q, t)) = valty t            | valty (A.Qual (q, t)) = valty t
87            | valty (A.Numeric (_, _, A.SIGNED, A.CHAR, _)) = Spec.SCHAR            | valty (A.Numeric (_, _, A.SIGNED, A.CHAR, _)) = Spec.SCHAR
# Line 109  Line 111 
111              typeref (tid, fn _ => bug "missing typedef info")              typeref (tid, fn _ => bug "missing typedef info")
112            | valty A.Error = err "Error type"            | valty A.Error = err "Error type"
113    
114            and valty_nonvoid t = valty t handle VoidType => err "void variable type"
115    
116          and typeref (tid, otherwise) =          and typeref (tid, otherwise) =
117              case Tidtab.find (tidtab, tid) of              case Tidtab.find (tidtab, tid) of
118                  NONE => bug "tid not bound in tidtab"                  NONE => bug "tid not bound in tidtab"
# Line 266  Line 270 
270              ty              ty
271          end          end
272    
273          and cobj t = (constness t, valty t)          and cobj t = (constness t, valty_nonvoid t)
274    
275          and fptrty f = Spec.FPTR (cft f)          and fptrty f = Spec.FPTR (cft f)
276    
277          and cft (res, args) =          and cft (res, args) =
278              { res = case getCoreType res of              { res = case getCoreType res of
279                          A.Void => NONE                          A.Void => NONE
280                        | _ => SOME (valty res),                        | _ => SOME (valty_nonvoid res),
281                args = case args of                args = case args of
282                           [arg] => (case getCoreType arg of                           [arg] => (case getCoreType arg of
283                                         A.Void => []                                         A.Void => []
284                                       | _ => [valty arg])                                       | _ => [valty_nonvoid arg])
285                         | _ => map valty args }                         | _ => map valty_nonvoid args }
286    
287          fun functionName (f: A.id) = let          fun functionName (f: A.id) = let
288              val n = Symbol.name (#name f)              val n = Symbol.name (#name f)
# Line 313  Line 317 
317          fun declaration (A.TypeDecl { tid, ... }) =          fun declaration (A.TypeDecl { tid, ... }) =
318              (* Spec.SINT is an arbitrary choice; the value gets              (* Spec.SINT is an arbitrary choice; the value gets
319               * ignored anyway *)               * ignored anyway *)
320              ignore (typeref (tid, fn _ => Spec.SINT))              (ignore (typeref (tid, fn _ => Spec.SINT))
321                 handle VoidType => ())     (* ignore type aliases for void *)
322            | declaration (A.VarDecl (v, _)) = varDecl v            | declaration (A.VarDecl (v, _)) = varDecl v
323    
324          fun coreExternalDecl (A.ExternalDecl d) = declaration d          fun coreExternalDecl (A.ExternalDecl d) = declaration d

Legend:
Removed from v.845  
changed lines
  Added in v.846

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