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 3174 - (download) (annotate)
Mon Mar 30 11:46:58 2015 UTC (3 years, 11 months ago) by cchiw
File size: 2187 byte(s)
hack
(*hash Ein operator*)
structure HashEin = struct
    local
    structure E = Ein
    in

    (*hasfn:EIN->hash value
    *hash value of the expression
    *)
    fun hashfn(Ein.EIN{body,...})= let
        

        fun hash body =let
            fun hashint i = Word.fromInt i
            fun iter[e]=hash e
              | iter(e1::es)=hash e1+iter es
            fun hashMu (E.C c)=hashint c+0w17
              | hashMu (E.V v)=hashint v
            fun hashAlpha []=0w3
              | hashAlpha(e1::es)=hashMu(e1)+hashAlpha es
            fun hashDels([])=0w3
              | hashDels((i,j)::es)=hashMu i+hashMu j +hashDels es
            in (case body
                of E.Const _ =>  0w3
                | E.ConstR _ => 0w5
                | E.Delta _ =>  0w7
                | E.Value _ =>  0w11
                | E.Epsilon _=> 0w13
                | E.Eps2 _    => 0w17
                | E.Partial alpha =>  0w19+hashAlpha alpha
                | E.Tensor (_,alpha)=>  0w23+hashAlpha alpha
                | E.Field(_,alpha) =>  0w29+hashAlpha alpha
                | E.Conv(_,alpha,_,dx)=> 0w37+hashAlpha alpha +hashAlpha dx
                | E.Krn (_,dels,pos) =>  0w41+ hashDels dels+hash pos
                | E.Img (_,alpha,es) => 0w43+hashAlpha alpha +iter es
                | E.Sum(c,e)=> 0w53+ hash e
                | E.Neg e =>  0w59+ hash e
                | E.Lift e =>  0w61+ hash e
                | E.Sqrt e =>  0w67+ hash e
                | E.Add es =>0w71+iter es
                | E.Sub(e1,e2) =>  0w79+iter[e1,e2]
                | E.Div(e1,e2)=>  0w83+iter[e1,e2]
                | E.Apply(e1,e2)=>  0w97+iter[e1,e2]
                | E.Probe(e1,e2)=>  0w101+iter[e1,e2]
                | E.Prod es=> 0w103+iter es
                | E.PowInt(e,_)=> 0w107+hash e
                | E.PowReal(e,_)=> 0w109+hash e
                | E.Cosine e1          =>0w113 + hash e1
                | E.ArcCosine e1       =>0w127 + hash e1
                | E.Sine e1            =>0w131 +  hash e1
                | E.ArcSine e1            =>0w137 +  hash e1
                (*end case*))
            end
        in
            hash body
        end

end (* local *)

end 

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