SCM Repository
View of /branches/vis12/src/compiler/basis/basis.sml
Parent Directory
|
Revision Log
Revision 1926 -
(download)
(annotate)
Sat Jun 23 18:01:57 2012 UTC (8 years, 6 months ago) by jhr
File size: 2960 byte(s)
Sat Jun 23 18:01:57 2012 UTC (8 years, 6 months ago) by jhr
File size: 2960 byte(s)
Switch to using "image" to load images (instead of "load").
(* basis.sml * * COPYRIGHT (c) 2010 The Diderot Project (http://diderot-language.cs.uchicago.edu) * All rights reserved. * * Type definitions for Basis functions. *) structure Basis : sig val env : Env.env (* certain operations are restricted to only appear at global scope (i.e., not in an * strand body). This function returns true for such operations. *) val isRestricted : AST.var -> bool end = struct structure N = BasisNames structure BV = BasisVars structure ATbl = AtomTable (* non-overloaded operators, etc. *) val basisFunctions = [ (* non-overloaded operators *) BV.op_cross, BV.op_outer, BV.op_D, BV.op_Dotimes, BV.op_norm, BV.op_not, (* functions *) BV.fn_image, BV.fn_inside, BV.fn_length, BV.fn_load, BV.fn_max, BV.fn_min, BV.fn_modulate, BV.fn_normalize, BV.fn_principleEvec, BV.fn_trace ] @ (List.map #2 BV.mathFns) val basisVars = [ (* kernels *) BV.kn_bspln3, BV.kn_bspln5, BV.kn_ctmr, BV.kn_tent, BV.kn_c1tent, BV.kn_c2ctmr ] (* overloaded operators and functions *) val overloads = [ (N.op_at, [BV.at_Td, BV.at_dT, BV.at_dd]), (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_add, [BV.add_ii, BV.add_tt, BV.add_ff]), (N.op_sub, [BV.sub_ii, BV.sub_tt, BV.sub_ff]), (N.op_mul, [BV.mul_ii, BV.mul_rr, BV.mul_rt, BV.mul_tr, BV.mul_rf, BV.mul_fr]), (N.op_div, [BV.div_ii, BV.div_rr, BV.div_tr, BV.div_tr]), (N.op_exp, [BV.exp_ri, BV.exp_rr]), (N.op_convolve, [BV.convolve_vk, BV.convolve_kv]), (N.op_lt, [BV.lt_ii, BV.lt_rr]), (N.op_neg, [BV.neg_i, BV.neg_t, BV.neg_f]), (N.fn_clamp, [BV.clamp_rrr, BV.clamp_vvv]), (N.fn_lerp, [BV.lerp5, BV.lerp3]), (N.fn_evals, [BV.evals2x2, BV.evals3x3]), (N.fn_evecs, [BV.evecs2x2, BV.evecs3x3]), (* assignment operators are bound to the corresponding binary operator *) (N.asgn_add, [BV.add_ii, BV.add_tt, BV.add_ff]), (N.asgn_sub, [BV.sub_ii, BV.sub_tt, BV.sub_ff]), (N.asgn_mul, [BV.mul_ii, BV.mul_rr, BV.mul_tr, BV.mul_fr]), (N.asgn_div, [BV.div_ii, BV.div_rr, BV.div_tr, BV.div_tr]) ] (* seed the basis environment *) val env = let fun insF (x, env) = Env.insertFunc(env, Atom.atom(Var.nameOf x), [x]) fun insV (x, env) = Env.insertGlobal(env, Atom.atom(Var.nameOf x), x) fun insOvld ((f, fns), env) = Env.insertFunc(env, f, fns) val env = List.foldl insF (Env.new()) basisFunctions val env = List.foldl insV env basisVars val env = List.foldl insOvld env overloads in env end local val restricted = List.foldl Var.Set.add' Var.Set.empty [ BV.fn_image, BV.fn_load ] in fun isRestricted x = Var.Set.member (restricted, x) end (* local *) end
root@smlnj-gforge.cs.uchicago.edu | ViewVC Help |
Powered by ViewVC 1.0.0 |