Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- case S.Prim(prim: L3TestPrimitive, args) => {
- implicit val p = UnknownPosition
- val ifTree = S.If(tree, S.Lit(BooleanLit(true)), S.Lit(BooleanLit(false)))
- transform(ifTree)(ctx)
- }
- case S.Prim(prim: L3ValuePrimitive, args) => args match {
- case Seq() => {
- val n = Symbol.fresh("n")
- C.LetP(n, prim, Seq[Symbol](), ctx(n))
- }
- case Seq(head, tail @ _*) => {
- //Creating the helper function
- def nCtx(s: Seq[S.Tree], symbols: Seq[Symbol]):(Symbol => C.Tree) = {
- //This function handles giving the variables
- //new names to be used by the LetP algorithm
- def f(v: Symbol):C.Tree = s match {
- //If the sequence is empty then we have exhausted
- //all of the expressions in the primitive
- case Seq() => {
- val syms = symbols :+ v
- val n = Symbol.fresh("n")
- C.LetP(n, prim, syms, ctx(n))
- }
- case Seq(head, tail @ _*) => {
- val syms = symbols :+ v
- transform(head)(nCtx(tail, syms))
- }
- }
- f
- }
- var f2 = nCtx(tail, Seq[Symbol]())
- transform(head)(f2)
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement