SCM Repository
View of /trunk/src/basis/basis.sml
Parent Directory
|
Revision Log
Revision 79 -
(download)
(annotate)
Tue May 25 01:55:48 2010 UTC (10 years, 9 months ago) by jhr
File size: 1996 byte(s)
Tue May 25 01:55:48 2010 UTC (10 years, 9 months ago) by jhr
File size: 1996 byte(s)
Working on typechecker
(* basis.sml * * COPYRIGHT (c) 2010 The Diderot Project (http://diderot.cs.uchicago.edu) * All rights reserved. * * Type definitions for Basis functions. *) structure Basis : sig val env : Env.env (* find an operator by name; this returns a singleton list for regular operators (including * type-index operators) and a list of variables for overloaded operators. *) val findOp : Atom.atom -> AST.var list end = struct structure N = BasisNames structure BV = BasisVars structure ATbl = AtomTable (* non-overloaded operators, etc. *) val basis = [ (* non-overloaded operators *) BV.op_at, BV.op_D, BV.op_norm, BV.op_not, (* functions *) BV.fn_CL, BV.fn_convolve, BV.fn_cos, BV.fn_dot, BV.fn_inside, BV.fn_load, BV.fn_pow, (* val fn_principleEvec = Atom.atom "principleEvec" *) BV.fn_sin, (* kernels *) BV.kn_bspln3, BV.kn_tent ] (* seed the basis environment *) val env = let fun ins (x, env) = Env.insertGlobal(env, Atom.atom(Var.nameOf x), x) in List.foldl ins (Env.new()) basis end (* overloaded operators *) val overloads = [ (N.op_add, [BV.add_ii, BV.add_tt]), (N.op_sub, [BV.sub_ii, BV.sub_tt]), (N.op_mul, [BV.mul_ii, BV.mul_rr, BV.mul_rt, BV.mul_tr]), (N.op_div, [BV.div_ii, BV.div_rr, BV.div_tr]), (N.op_lt, [BV.lt_ii, BV.lt_rr]), (N.op_lte, [BV.lte_ii, BV.lte_rr]), (N.op_equ, [BV.equ_bb, BV.equ_ii, BV.equ_ss, BV.equ_rr]), (N.op_neq, [BV.neq_bb, BV.neq_ii, BV.neq_ss, BV.neq_rr]), (N.op_gte, [BV.gte_ii, BV.gte_rr]), (N.op_gt, [BV.gt_ii, BV.gt_rr]), (N.op_neg, [BV.neg_i, BV.neg_t, BV.neg_f]) ] local val lookup = let val tbl = ATbl.mkTable(64, Fail "op table") in List.app (ATbl.insert tbl) overloads; ATbl.lookup tbl end in fun findOp name = (case Env.findVar(env, name) of SOME x => [x] | NONE => lookup name (* end case *)) end (* local *) end
root@smlnj-gforge.cs.uchicago.edu | ViewVC Help |
Powered by ViewVC 1.0.0 |