Skip to content

Commit

Permalink
Merge pull request #459 from wiwa/d/refactor
Browse files Browse the repository at this point in the history
Rename private vals for easier debugging
  • Loading branch information
wiwa committed Jul 24, 2019
2 parents af6b9ad + 53c28ea commit 97637a9
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 17 deletions.
8 changes: 4 additions & 4 deletions rsc/src/main/scala/rsc/symtab/Envs.scala
Original file line number Diff line number Diff line change
Expand Up @@ -8,24 +8,24 @@ import rsc.semantics._
import rsc.util._

trait Envs {
private val impl = new HashMap[Symbol, Env]
private val envsImpl = new HashMap[Symbol, Env]

private val caseTemplateEnvs = new HashMap[Symbol, Env]

object envs {
def apply(sym: Symbol): Env = {
val env = impl.get(sym)
val env = envsImpl.get(sym)
if (env == null) crash(sym)
env
}

def put(sym: Symbol, env: Env): Unit = {
if (impl.containsKey(sym) && !sym.desc.isPackage) {
if (envsImpl.containsKey(sym) && !sym.desc.isPackage) {
crash(sym)
}
sym match {
case NoSymbol => crash(env)
case other => impl.put(other, env)
case other => envsImpl.put(other, env)
}
}
}
Expand Down
16 changes: 8 additions & 8 deletions rsc/src/main/scala/rsc/symtab/Outlines.scala
Original file line number Diff line number Diff line change
Expand Up @@ -8,39 +8,39 @@ import rsc.syntax._
import rsc.util._

trait Outlines {
private val impl = new LinkedHashMap[Symbol, Outline]
private val outlinesImpl = new LinkedHashMap[Symbol, Outline]

object outlines {
def apply(sym: Symbol): Outline = {
val outline = impl.get(sym)
val outline = outlinesImpl.get(sym)
if (outline == null) crash(sym)
outline
}

def contains(sym: Symbol): Boolean = {
impl.containsKey(sym)
outlinesImpl.containsKey(sym)
}

def get(sym: Symbol): Option[Outline] = {
val outline = impl.get(sym)
val outline = outlinesImpl.get(sym)
if (outline != null) Some(outline)
else None
}

def put(sym: Symbol, outline: Outline): Unit = {
if (impl.containsKey(sym) && !sym.desc.isPackage) {
val existingOutline = impl.get(sym)
if (outlinesImpl.containsKey(sym) && !sym.desc.isPackage) {
val existingOutline = outlinesImpl.get(sym)
if (outline == existingOutline) return
crash(sym)
}
sym match {
case NoSymbol => crash(outline)
case other => impl.put(other, outline)
case other => outlinesImpl.put(other, outline)
}
}

def result: LinkedList[Outline] = {
new LinkedList(impl.values)
new LinkedList(outlinesImpl.values)
}
}
}
10 changes: 5 additions & 5 deletions rsc/src/main/scala/rsc/symtab/Sketches.scala
Original file line number Diff line number Diff line change
Expand Up @@ -8,24 +8,24 @@ import rsc.syntax._
import rsc.util._

trait Sketches {
private val impl = new HashMap[Sketchy, Sketch]
private val sketchesImpl = new HashMap[Sketchy, Sketch]

object sketches {
def apply(tree: Sketchy): Sketch = {
val sketch = impl.get(tree)
val sketch = sketchesImpl.get(tree)
if (sketch == null) crash(tree)
sketch
}

def contains(tree: Sketchy): Boolean = {
impl.containsKey(tree)
sketchesImpl.containsKey(tree)
}

def put(tree: Sketchy, sketch: Sketch): Unit = {
if (impl.containsKey(tree)) {
if (sketchesImpl.containsKey(tree)) {
crash(tree)
}
impl.put(tree, sketch)
sketchesImpl.put(tree, sketch)
}
}
}

0 comments on commit 97637a9

Please sign in to comment.