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

Nicer abstract Symbol member overrides

parent 074c1ac8
No related branches found
No related tags found
No related merge requests found
...@@ -234,6 +234,9 @@ trait Extractors { self: Trees => ...@@ -234,6 +234,9 @@ trait Extractors { self: Trees =>
val deconstructor: TreeDeconstructor { val deconstructor: TreeDeconstructor {
val s: self.type val s: self.type
val t: self.type val t: self.type
} = new TreeDeconstructor {
protected val s: self.type = self
protected val t: self.type = self
} }
/** Operator Extractor to extract any Expression in a consistent way. /** Operator Extractor to extract any Expression in a consistent way.
......
...@@ -5,19 +5,18 @@ package ast ...@@ -5,19 +5,18 @@ package ast
trait SimpleSymbols { self: Trees => trait SimpleSymbols { self: Trees =>
val NoSymbols = new Symbols(Map.empty, Map.empty) val NoSymbols = Symbols(Map.empty, Map.empty)
class Symbols( val Symbols: (Map[Identifier, FunDef], Map[Identifier, ADTDefinition]) => Symbols
val functions: Map[Identifier, FunDef],
val adts: Map[Identifier, ADTDefinition]
) extends AbstractSymbols {
def withFunctions(functions: Seq[FunDef]): Symbols = new Symbols( abstract class SimpleSymbols extends AbstractSymbols { self: Symbols =>
def withFunctions(functions: Seq[FunDef]): Symbols = Symbols(
this.functions ++ functions.map(fd => fd.id -> fd), this.functions ++ functions.map(fd => fd.id -> fd),
this.adts this.adts
) )
def withADTs(adts: Seq[ADTDefinition]): Symbols = new Symbols( def withADTs(adts: Seq[ADTDefinition]): Symbols = Symbols(
this.functions, this.functions,
this.adts ++ adts.map(adt => adt.id -> adt) this.adts ++ adts.map(adt => adt.id -> adt)
) )
......
...@@ -42,9 +42,9 @@ package object inox { ...@@ -42,9 +42,9 @@ package object inox {
} }
object trees extends ast.Trees with ast.SimpleSymbols { object trees extends ast.Trees with ast.SimpleSymbols {
object deconstructor extends { case class Symbols(
protected val s: trees.type = trees functions: Map[Identifier, FunDef],
protected val t: trees.type = trees adts: Map[Identifier, ADTDefinition]
} with ast.TreeDeconstructor ) extends SimpleSymbols
} }
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment