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

SCM Repository

[diderot] View of /branches/charisee/src/compiler/ein/hash-ein.sml
ViewVC logotype

View of /branches/charisee/src/compiler/ein/hash-ein.sml

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2555 - (download) (annotate)
Mon Mar 3 19:14:57 2014 UTC (7 years, 6 months ago) by cchiw
File size: 1274 byte(s)
Code Clean up
(*hashs Ein Function after substitution*)
structure hashEin = struct
    local
    structure E = Ein
    in

(*hash value of the expression *)
fun hashfn(Ein.EIN{params, index, body})= let
   val changed =ref false
 

   fun hash(body)=(case body
        of E.Const _ =>  0w3
        | E.Tensor _=>  0w5
        | E.Field _ =>  0w7
        | E.Krn _ =>  0w11
        | E.Delta _ =>  0w13
        | E.Value _ =>  0w17
        | E.Epsilon _=> 0w19
        | E.Partial _ =>  0w23
        | E.Conv _=> 0w29
        | E.Sum(c,e)=> 0w31+ hash(e)
        | E.Neg e =>  0w37+ hash(e)
        | E.Add es =>let
            fun addhash([])=0w41
            |addhash(e::es)=hash(e)+addhash(es)
            in addhash(es) end
        | E.Sub(e1,e2) =>  0w43+hash(e1)+ hash (e2)
        | E.Div(e1,e2)=>  0w47+ hash(e1)+ hash (e2)
        | E.Apply(e1,e2)=>  0w53+hash(e1)+ hash(e2)
        | E.Probe(e1,e2)=>  0w59+hash(e1)+hash(e2)
        | E.Img (fid,alpha,es) =>  let
            fun addhash([])=0w61
            |addhash(e::es)=hash(e)+addhash(es)
            in addhash(es) end
        | E.Prod es=> let
            fun addhash([])=0w67
            |addhash(e::es)=hash(e)+addhash(es)
            in addhash(es) end
        (*end case*))
   in hash(body) end

end (* local *)

end 

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