Skip to content
Snippets Groups Projects
Commit 0f517bdf authored by Nicolas Voirol's avatar Nicolas Voirol
Browse files

SimpleSymbols for default symbol implementations

parent a3c19dd2
No related branches found
No related tags found
No related merge requests found
/* Copyright 2009-2016 EPFL, Lausanne */
package inox
package ast
trait SimpleSymbols { self: Trees =>
class Symbols(
val functions: Map[Identifier, FunDef],
val adts: Map[Identifier, ADTDefinition]
) extends AbstractSymbols {
def transform(t: TreeTransformer) = new Symbols(
functions.mapValues(fd => new FunDef(
fd.id,
fd.tparams, // type parameters can't be transformed!
fd.params.map(vd => t.transform(vd)),
t.transform(fd.returnType),
t.transform(fd.fullBody),
fd.flags)),
adts.mapValues {
case sort: ADTSort => sort
case cons: ADTConstructor => new ADTConstructor(
cons.id,
cons.tparams,
cons.sort,
cons.fields.map(t.transform),
cons.flags)
})
def extend(functions: Seq[FunDef] = Seq.empty, adts: Seq[ADTDefinition] = Seq.empty) = new Symbols(
this.functions ++ functions.map(fd => fd.id -> fd),
this.adts ++ adts.map(cd => cd.id -> cd)
)
}
}
......@@ -41,41 +41,10 @@ package object inox {
}
}
object trees extends ast.Trees {
object trees extends ast.Trees with ast.SimpleSymbols {
object deconstructor extends {
protected val s: trees.type = trees
protected val t: trees.type = trees
} with ast.TreeDeconstructor
class Symbols(
val functions: Map[Identifier, FunDef],
val adts: Map[Identifier, ADTDefinition]
) extends AbstractSymbols {
def transform(t: TreeTransformer) = new Symbols(
functions.mapValues(fd => new FunDef(
fd.id,
fd.tparams, // type parameters can't be transformed!
fd.params.map(vd => t.transform(vd)),
t.transform(fd.returnType),
t.transform(fd.fullBody),
fd.flags)),
adts.mapValues {
case sort: ADTSort => sort
case cons: ADTConstructor => new ADTConstructor(
cons.id,
cons.tparams,
cons.sort,
cons.fields.map(t.transform),
cons.flags)
})
def extend(functions: Seq[FunDef] = Seq.empty, adts: Seq[ADTDefinition] = Seq.empty) = new Symbols(
this.functions ++ functions.map(fd => fd.id -> fd),
this.adts ++ adts.map(cd => cd.id -> cd)
)
}
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment