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 3448 - (download) (annotate)
Fri Nov 20 20:33:38 2015 UTC (4 years ago) by cchiw
File size: 2762 byte(s)
merge over dev branch
(*hash Ein operator*)
structure HashEin = struct
    local
    structure E = Ein
    structure P = Printer
    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.B(E.Const _)       => 0w3
                | E.B(E.ConstR _)       => 0w5
                | E.Tensor (_,alpha)    => 0w23+hashAlpha alpha
                | E.G(E.Delta _)        => 0w7
                | E.G(E.Epsilon _ )     => 0w13
                | E.G(E.Eps2 _)         => 0w17
                | E.Field(_,alpha)      => 0w29+hashAlpha alpha
                | E.Lift e1             => 0w61+ hash e1
                | E.Conv(_,alpha,_,dx)  => 0w37+hashAlpha alpha+hashAlpha dx+hashint(length(dx))
                | E.Partial alpha       => 0w19+hashAlpha alpha
                | E.Apply(e1,e2)        => 0w97+iter[e1,e2]
                | E.Probe(e1,e2)        => 0w101+iter[e1,e2]
                | E.Value _             => 0w11
                | E.Img (_,alpha,es)    => 0w43+hashAlpha alpha +iter es
                | E.Krn (_,dels,pos)    => 0w41+ hashDels dels+hash pos
                | E.Sum(c,e1)           => 0w53+ hash e1
                | E.Op1(e1,e2)          => (case e1
                    of E.Cosine         => 0w113 + hash e2
                    | E.ArcCosine       => 0w127 + hash e2
                    | E.Sine            => 0w131 + hash e2
                    | E.ArcSine         => 0w137 + hash e2
                    | E.Tangent         => 0w139 + hash e2
                    | E.ArcTangent      => 0w149 + hash e2
                    | E.Neg             => 0w59 + hash e2
                    | E.Sqrt            => 0w67 + hash e2
                    | E.PowInt _        => 0w107+ hash e2
                    | E.PowReal _       => 0w109+ hash e2
                    | E.Exp             => 0w151+ hash e2
                    | E.PowEmb _        => 0w157+ hash e2
                    (* end case*))
                | E.Op2(E.Sub,e1,e2)    => 0w79+iter[e1,e2]
                | E.Op2(E.Div,e1,e2)    => 0w83+iter[e1,e2]
                | E.Opn(E.Add, es)      => 0w71+iter es
                | E.Opn(E.Prod ,es)     => 0w103+iter es
                (*end case*))
            end
        in  hash body
        end

end (* local *)

end 

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