Commit 08b6e8f0 authored by Kunshan Wang's avatar Kunshan Wang

Scala 2.12.2, deprecated, clientsupport

Switched Scala version to 2.12.2, the most recent stable version.  It
will now require Java 1.8.

Fixed existing uses of deprecated features.

Removed the `uvm.clientsupport` package.  This package was intended to
help Mu clients build text-based Mu IR bundles.  However, we started
using the IR Builder API instead, and the `uvm.clientsupport` package
remained unused.  The same capability can be provided by the
`mu-tool-compiler` project
(https://gitlab.anu.edu.au/mu/mu-tool-compiler).  `uvm.clientsupport`
provided a non-SSA-to-ssa converter, which can be useful for clients.
If there are needs of resurrecting that feature, please checkout the
previous commit.
parent 9fcd3c14
...@@ -17,12 +17,12 @@ Specification](https://gitlab.anu.edu.au/mu/mu-spec). ...@@ -17,12 +17,12 @@ Specification](https://gitlab.anu.edu.au/mu/mu-spec).
* Install JDK 8. If you use Mac, download from * Install JDK 8. If you use Mac, download from
[Oracle](http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html). [Oracle](http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html).
* If you use Mac, install [Homebrew](http://brew.sh/). * If you use Mac, install [Homebrew](http://brew.sh/).
* Install [Scala](http://scala-lang.org/) 2.11. If you use Mac and Homebrew, * Install [Scala](http://scala-lang.org/) 2.12. If you use Mac and Homebrew,
`brew install scala`. `brew install scala`.
* Install [sbt](http://www.scala-sbt.org/) 0.13. If you use Mac and Homebrew, * Install [sbt](http://www.scala-sbt.org/) 0.13. If you use Mac and Homebrew,
`brew install sbt`. `brew install sbt`.
* Install [Scala IDE](http://scala-ide.org/) 4.x (Eclipse with pre-installed * Install [Scala IDE](http://scala-ide.org/) 4.6 or later (Eclipse with
plugins for Scala). pre-installed plugins for Scala).
* Clone this repository: * Clone this repository:
```bash ```bash
...@@ -49,7 +49,7 @@ sbt update genSrc eclipse ...@@ -49,7 +49,7 @@ sbt update genSrc eclipse
The reference implementation is developed and tested with Java VM 8. You need a The reference implementation is developed and tested with Java VM 8. You need a
JRE to build the Scala/Java part, and a JDK to build the C binding. JRE to build the Scala/Java part, and a JDK to build the C binding.
You also need [Scala](http://scala-lang.org/) 2.11 and You also need [Scala](http://scala-lang.org/) 2.12 and
[sbt](http://www.scala-sbt.org/) 0.13. It is recommended to install them using [sbt](http://www.scala-sbt.org/) 0.13. It is recommended to install them using
the package manager of your operating system or distribution (such as apt-get, the package manager of your operating system or distribution (such as apt-get,
yum, pacman, etc. for GNU/Linux distributions and Homebrew for Mac OS X) if such yum, pacman, etc. for GNU/Linux distributions and Homebrew for Mac OS X) if such
...@@ -69,7 +69,7 @@ compile this project. Or you can do it step by step: ...@@ -69,7 +69,7 @@ compile this project. Or you can do it step by step:
update`. update`.
* To generate the Mu IR parser from the Antlr grammar, invoke `sbt genSrc`. The * To generate the Mu IR parser from the Antlr grammar, invoke `sbt genSrc`. The
generated sources will be in the `target/scala-2.11/src_managed` directory. generated sources will be in the `target/scala-2.12/src_managed` directory.
* To compile, invoke `sbt compile`. This will also generate the Mu IR parser * To compile, invoke `sbt compile`. This will also generate the Mu IR parser
using Antlr. using Antlr.
......
...@@ -17,19 +17,21 @@ lazy val root = (project in file(".")). ...@@ -17,19 +17,21 @@ lazy val root = (project in file(".")).
licenses := Seq("CC BY-SA 4.0" -> url("https://creativecommons.org/licenses/by-sa/4.0/legalcode")), licenses := Seq("CC BY-SA 4.0" -> url("https://creativecommons.org/licenses/by-sa/4.0/legalcode")),
scalaVersion := "2.11.11", scalaVersion := "2.12.2",
libraryDependencies ++= Seq( libraryDependencies ++= Seq(
"org.antlr" % "antlr4" % "4.7", "org.antlr" % "antlr4" % "4.7",
"com.typesafe.scala-logging" %% "scala-logging" % "3.5.0", "com.typesafe.scala-logging" %% "scala-logging" % "3.7.1",
"ch.qos.logback" % "logback-classic" % "1.2.3", "ch.qos.logback" % "logback-classic" % "1.2.3",
"com.github.jnr" % "jnr-ffi" % "2.1.5", "com.github.jnr" % "jnr-ffi" % "2.1.6",
"com.github.jnr" % "jffi" % "1.2.15" classifier "native", "com.github.jnr" % "jffi" % "1.2.16" classifier "native",
"com.github.jnr" % "jnr-posix" % "3.0.41", "com.github.jnr" % "jnr-posix" % "3.0.41",
"org.scalatest" %% "scalatest" % "3.0.3" % "test", "org.scalatest" %% "scalatest" % "3.0.3" % "test",
"junit" % "junit" % "4.12" % "test" "junit" % "junit" % "4.12" % "test"
), ),
scalacOptions += "-language:implicitConversions",
testOptions in Test += Tests.Argument("-oF"), // print full stack trace when testing testOptions in Test += Tests.Argument("-oF"), // print full stack trace when testing
parallelExecution in Test := false, // disable parallel tests because the refimpl2 is not thread-safe parallelExecution in Test := false, // disable parallel tests because the refimpl2 is not thread-safe
......
package uvm.clientsupport.text
import java.util
import scala.collection.JavaConversions._
/**
* A Mu IR bundle. This class is more representation-oriented rather than semantic oriented. For example, there are
* "type definitions" rather than "types". Similarly "function definitions" and "function declarations" are separated
* rather than contained in each other.
*/
class Bundle(
cTypeDefs: TraversableOnce[(TypeName, TypeCtor)],
cFuncSigDefs: TraversableOnce[(FuncSigName, FuncSig)],
cConstDefs: TraversableOnce[(GlobalVarName, Const)],
cGlobalCellDefs: TraversableOnce[(GlobalVarName, TypeName)],
cFuncDecls: TraversableOnce[(GlobalVarName, FuncSigName)],
cFuncVers: TraversableOnce[(FuncVerName, PostFuncVer)],
cFuncExpDefs: TraversableOnce[(GlobalVarName, Expose)],
cComments: TraversableOnce[(GlobalName, String)]
) {
private def buildMap[K, V](seq: TraversableOnce[(K, V)]): util.Map[K, V] = {
val map = new util.LinkedHashMap[K, V]
seq foreach { case (k, v) => map.put(k, v) }
map
}
lazy val typeDefs = buildMap(cTypeDefs)
lazy val funcSigDefs = buildMap(cFuncSigDefs)
lazy val constDefs = buildMap(cConstDefs)
lazy val globalCellDefs = buildMap(cGlobalCellDefs)
lazy val funcDecls = buildMap(cFuncDecls)
lazy val funcVers = buildMap(cFuncVers)
lazy val funcExpDefs = buildMap(cFuncExpDefs)
lazy val comments = buildMap(cComments)
override lazy val toString = {
val sb = new StringBuilder
def printBlock[N <: GlobalName, V](block: util.Map[N, V])(fn: (N, V) => Unit): Unit =
if (!block.isEmpty) {
sb append "\n"
block foreach { case (name, value) =>
Option(comments get name) foreach (_ split '\n' map ("// " + _ + "\n") foreach sb.append)
fn(name, value)
}
}
printBlock(typeDefs)((name, ctor) => sb append s".typedef $name = $ctor\n")
printBlock(funcSigDefs)((name, sig) => sb append s".funcsig $name = $sig\n")
printBlock(constDefs)((name, const) => sb append s".const $name <${const.ty}> = $const\n")
printBlock(globalCellDefs)((name, ty) => sb append s".global $name <$ty>\n")
printBlock(funcDecls)((name, sig) => sb append s".funcdecl $name <$sig>\n")
printBlock(funcExpDefs)((name, exp) => sb append s".expose $name = $exp\n")
printBlock(funcVers)((name, ver) =>
sb append s".funcdef ${ver.func} VERSION $name <${ver.sig}> $ver\n\n")
sb.toString
}
}
package uvm.clientsupport.text
import java.util
import scala.collection.JavaConversions
class IList[T](members: TraversableOnce[T]) extends util.AbstractList[T] with Traversable[T] {
def this(membersIterable: java.lang.Iterable[T]) =
this(JavaConversions iterableAsScalaIterable membersIterable)
private val vector = members.toVector
override def get(index: Int): T = vector(index)
override def size: Int = vector.length
override def isEmpty: Boolean = vector.isEmpty
override def toString = vector mkString " "
override def foreach[U](f: (T) => U): Unit = vector foreach f
def apply(idx: Int): T = vector(idx)
}
object IList {
def apply[T](members: T*): IList[T] = new IList(members)
def empty[T]: IList[T] = new IList[T](Nil)
}
This diff is collapsed.
This diff is collapsed.
package uvm.clientsupport.text
sealed abstract class TypeCtor(str: => String) {
override lazy val toString: String = str
}
object TypeCtor {
def Void = Singletons.Void; type Void = Singletons.Void.type
case class Int(bits: scala.Int) extends TypeCtor(s"int<$bits>")
def Float = Singletons.Float; type Float = Singletons.Float.type
def Double = Singletons.Double; type Double = Singletons.Double.type
def ThreadRef = Singletons.ThreadRef; type ThreadRef = Singletons.ThreadRef.type
def StackRef = Singletons.StackRef; type StackRef = Singletons.StackRef.type
def FrameCursorRef = Singletons.FrameCursorRef; type FrameCursorRef = Singletons.FrameCursorRef.type
case class Ref(ty: TypeCtor) extends TypeCtor(s"ref<$ty>")
case class IRef(ty: TypeCtor) extends TypeCtor(s"iref<$ty>")
case class WeakRef(ty: TypeCtor) extends TypeCtor(s"weakref<$ty>")
case class FuncRef(sig: FuncSigName) extends TypeCtor(s"funcref<$sig>")
case class UPtr(ty: TypeCtor) extends TypeCtor(s"uptr<$ty>")
case class UFuncPtr(sig: FuncSigName) extends TypeCtor(s"ufuncptr<$sig>")
def TagRef64 = Singletons.TagRef64; type TagRef64 = Singletons.TagRef64.type
case class Array(ty: TypeCtor, len: scala.Long) extends TypeCtor(s"array<$ty $len>")
case class Vector(ty: TypeCtor, len: scala.Int) extends TypeCtor(s"vector<$ty $len>")
case class Hybrid(fixedTy: TypeCtor, varTy: TypeCtor) extends TypeCtor(s"hybrid<$fixedTy $varTy>")
case class Struct(types: IList[TypeCtor]) extends TypeCtor(s"struct<${types mkString " "}>")
object Singletons {
case object Void extends TypeCtor("void")
case object Float extends TypeCtor("float")
case object Double extends TypeCtor("double")
case object ThreadRef extends TypeCtor("threadref")
case object StackRef extends TypeCtor("stackref")
case object FrameCursorRef extends TypeCtor("framecursorref")
case object TagRef64 extends TypeCtor("tagref64")
}
}
sealed trait MuName {
def name: String
}
sealed trait GlobalName extends MuName {
override lazy val toString = "@" + name
}
sealed trait LocalName extends MuName {
override lazy val toString = "%" + name
}
sealed trait VarName extends MuName
case class TypeName(name: String) extends TypeCtor("@" + name) with GlobalName
case class FuncSigName(name: String) extends GlobalName
case class FuncVerName(name: String) extends GlobalName
case class GlobalVarName(name: String) extends GlobalName with VarName
case class LocalVarName(name: String) extends LocalName with VarName
case class LabelName(name: String) extends LocalName
final class Flag(cName: String) {
val name = cName.toUpperCase.replaceAll("[^A-Z_]", "")
override def toString = "#" + name
}
package uvm.clientsupport.text
sealed abstract class Const(str: => String) {
def ty: TypeName
override def toString = str
}
object Const {
case class Null(ty: TypeName) extends Const("NULL")
case class Int(ty: TypeName, value: scala.Long) extends Const(value.toString)
case class Float(ty: TypeName, value: scala.Float)
extends Const(s"bitsf(0x${Integer.toHexString(java.lang.Float.floatToRawIntBits(value))})")
case class Double(ty: TypeName, value: scala.Double)
extends Const(s"bitsd(0x${java.lang.Long.toHexString(java.lang.Double.doubleToRawLongBits(value))})")
case class Pointer(ty: TypeName, addr: scala.Long) extends Const(addr.toString)
case class List(ty: TypeName, fields: IList[GlobalVarName]) extends Const(s"{$fields}")
}
case class FuncSig(paramTy: IList[TypeName], retTy: IList[TypeName]) {
override def toString = s"($paramTy) -> ($retTy)"
}
case class PreFuncVer(
func: GlobalVarName,
sig: FuncSigName,
params: IList[LocalVarName],
bbs: IList[PreBasicBlock]
) {
override lazy val toString = "(" + params + ") {\n" + (bbs mkString "\n") + "\n}"
}
case class PostFuncVer(func: GlobalVarName, sig: FuncSigName, bbs: IList[PostBasicBlock]) {
override lazy val toString = "{\n" + (bbs mkString "\n") + "\n}"
}
case class Expose(func: GlobalVarName, callConv: Flag, cookie: GlobalVarName) {
override def toString = s"$func $callConv $cookie"
}
trait Context {
def resolve(typeName: TypeName): Option[TypeCtor]
def resolve(funcSigName: FuncSigName): Option[FuncSig]
def typeDef(ctor: TypeCtor): TypeName
def funcSig(args: IList[TypeName], ret: IList[TypeName]): FuncSigName
def constDef(c: Const): GlobalVarName
}
\ No newline at end of file
package uvm.ir.irbuilder package uvm.ir.irbuilder
import scala.collection.mutable.ArrayBuffer
import uvm._ import uvm._
import uvm.ir.irbuilder.IRBuilderNode._
import uvm.ssavariables._ import uvm.ssavariables._
import uvm.types._ import uvm.types._
import uvm.utils.Later import uvm.utils.Later
import uvm.utils.Later._ import uvm.utils.Later._
import uvm.ir.irbuilder.IRBuilderNode._
import scala.collection.mutable.ArrayBuffer
/** This class converts the soup of ID-referenced nodes into the refimpl's internal AST. */ /** This class converts the soup of ID-referenced nodes into the refimpl's internal AST. */
class BundleConstructor(idNameMap: Map[MuID, MuName], nodeList: Seq[IRBuilderNode], globalBundle: GlobalBundle) { class BundleConstructor(idNameMap: Map[MuID, MuName], nodeList: Seq[IRBuilderNode], globalBundle: GlobalBundle) {
......
package uvm.ir.textinput package uvm.ir.textinput
import scala.collection.JavaConversions._ import scala.collection.JavaConverters._
import scala.collection.mutable.ArrayBuffer import scala.collection.mutable.ArrayBuffer
import org.antlr.v4.runtime._ import org.antlr.v4.runtime._
...@@ -41,11 +41,11 @@ class UIRTextReader(val defaultIDFactory: IDFactory, val recordSourceInfo: Boole ...@@ -41,11 +41,11 @@ class UIRTextReader(val defaultIDFactory: IDFactory, val recordSourceInfo: Boole
def read(ir: String, globalBundle: GlobalBundle, idFactory : IDFactory): TrantientBundle = { def read(ir: String, globalBundle: GlobalBundle, idFactory : IDFactory): TrantientBundle = {
logger.debug("Creating ANTLRInputStream...") logger.debug("Creating ANTLRInputStream...")
val input = new ANTLRInputStream(ir) val input = CharStreams.fromString(ir)
read(ir, input, globalBundle, idFactory) read(ir, input, globalBundle, idFactory)
} }
def parse(source: String, ais: ANTLRInputStream): IrContext = { def parse(source: String, ais: CharStream): IrContext = {
logger.debug("Creating AccumulativeAntlrErrorListener...") logger.debug("Creating AccumulativeAntlrErrorListener...")
val ea = new AccumulativeAntlrErrorListener(source) val ea = new AccumulativeAntlrErrorListener(source)
...@@ -67,11 +67,11 @@ class UIRTextReader(val defaultIDFactory: IDFactory, val recordSourceInfo: Boole ...@@ -67,11 +67,11 @@ class UIRTextReader(val defaultIDFactory: IDFactory, val recordSourceInfo: Boole
ast ast
} }
def read(source: String, ais: ANTLRInputStream, globalBundle: GlobalBundle): TrantientBundle = { def read(source: String, ais: CharStream, globalBundle: GlobalBundle): TrantientBundle = {
read(source, ais, globalBundle, defaultIDFactory) read(source, ais, globalBundle, defaultIDFactory)
} }
def read(source: String, ais: ANTLRInputStream, globalBundle: GlobalBundle, idFactory: IDFactory): TrantientBundle = { def read(source: String, ais: CharStream, globalBundle: GlobalBundle, idFactory: IDFactory): TrantientBundle = {
val ast = parse(source, ais) val ast = parse(source, ais)
logger.debug("Antlr parsed. Reading UIR AST into a Bundle...") logger.debug("Antlr parsed. Reading UIR AST into a Bundle...")
val instanceReader = new InstanceUIRTextReader(idFactory, source, ast, globalBundle, recordSourceInfo) val instanceReader = new InstanceUIRTextReader(idFactory, source, ast, globalBundle, recordSourceInfo)
...@@ -118,11 +118,11 @@ private[textinput] class InstanceUIRTextReader(idFactory: IDFactory, source: Str ...@@ -118,11 +118,11 @@ private[textinput] class InstanceUIRTextReader(idFactory: IDFactory, source: Str
def resFuncByName(name: String): Function = cascadeLookup(name, bundle.funcNs, globalBundle.funcNs) def resFuncByName(name: String): Function = cascadeLookup(name, bundle.funcNs, globalBundle.funcNs)
implicit def convFlag(f: FlagContext): Flag = Flag(f.FLAG().getText) implicit def convFlag(f: FlagContext): Flag = Flag(f.FLAG().getText)
implicit def convFlagList(a: FlagListContext): Seq[Flag] = a.flag().map(convFlag) implicit def convFlagList(a: FlagListContext): Seq[Flag] = a.flag().asScala.map(convFlag)
// Resolve global entities from special structures. // Resolve global entities from special structures.
implicit def resTypeList(a: TypeListContext): Seq[Type] = a.`type`.map(resTy) implicit def resTypeList(a: TypeListContext): Seq[Type] = a.`type`.asScala.map(resTy)
implicit def resFuncSigList(a: FuncSigListContext): Seq[FuncSig] = a.funcSig().map(resSig) implicit def resFuncSigList(a: FuncSigListContext): Seq[FuncSig] = a.funcSig().asScala.map(resSig)
// Resolve special structures // Resolve special structures
...@@ -189,8 +189,8 @@ private[textinput] class InstanceUIRTextReader(idFactory: IDFactory, source: Str ...@@ -189,8 +189,8 @@ private[textinput] class InstanceUIRTextReader(idFactory: IDFactory, source: Str
case t: TypeDoubleContext => TypeDouble() case t: TypeDoubleContext => TypeDouble()
case t: TypeUPtrContext => TypeUPtr(null).later(phase1) { _.ty = t.ty } case t: TypeUPtrContext => TypeUPtr(null).later(phase1) { _.ty = t.ty }
case t: TypeUFuncPtrContext => TypeUFuncPtr(null).later(phase1) { _.sig = t.funcSig } case t: TypeUFuncPtrContext => TypeUFuncPtr(null).later(phase1) { _.sig = t.funcSig }
case t: TypeStructContext => TypeStruct(null).later(phase1) { _.fieldTys = t.fieldTys.map(resTy) } case t: TypeStructContext => TypeStruct(null).later(phase1) { _.fieldTys = t.fieldTys.asScala.map(resTy) }
case t: TypeHybridContext => TypeHybrid(null, null).later(phase1) { tt => tt.fieldTys = t.fieldTys.map(resTy); tt.varTy = t.varTy } case t: TypeHybridContext => TypeHybrid(null, null).later(phase1) { tt => tt.fieldTys = t.fieldTys.asScala.map(resTy); tt.varTy = t.varTy }
case t: TypeArrayContext => TypeArray(null, t.length.longValue()).later(phase1) { _.elemTy = t.ty } case t: TypeArrayContext => TypeArray(null, t.length.longValue()).later(phase1) { _.elemTy = t.ty }
case t: TypeVectorContext => TypeVector(null, t.length.longValue()).later(phase1) { _.elemTy = t.ty } case t: TypeVectorContext => TypeVector(null, t.length.longValue()).later(phase1) { _.elemTy = t.ty }
case t: TypeVoidContext => TypeVoid() case t: TypeVoidContext => TypeVoid()
...@@ -209,14 +209,14 @@ private[textinput] class InstanceUIRTextReader(idFactory: IDFactory, source: Str ...@@ -209,14 +209,14 @@ private[textinput] class InstanceUIRTextReader(idFactory: IDFactory, source: Str
def mkSig(fsc: FuncSigConstructorContext): FuncSig = { def mkSig(fsc: FuncSigConstructorContext): FuncSig = {
val sig = FuncSig(null, null).later(phase1) { sig => val sig = FuncSig(null, null).later(phase1) { sig =>
sig.retTys = for (t <- fsc.retTys) yield resTy(t) sig.retTys = for (t <- fsc.retTys.asScala) yield resTy(t)
sig.paramTys = for (t <- fsc.paramTys) yield resTy(t) sig.paramTys = for (t <- fsc.paramTys.asScala) yield resTy(t)
} }
return sig return sig
} }
logger.debug("Reading types and sigs...") logger.debug("Reading types and sigs...")
ir.topLevelDef.map(_.getChild(0)).foreach { ir.topLevelDef.asScala.map(_.getChild(0)).foreach {
case td: TypeDefContext => { case td: TypeDefContext => {
val ty = mkType(td.typeConstructor) val ty = mkType(td.typeConstructor)
val name = td.nam val name = td.nam
...@@ -246,7 +246,7 @@ private[textinput] class InstanceUIRTextReader(idFactory: IDFactory, source: Str ...@@ -246,7 +246,7 @@ private[textinput] class InstanceUIRTextReader(idFactory: IDFactory, source: Str
case cc: CtorFloatContext => ConstFloat(t, cc.floatLiteral) case cc: CtorFloatContext => ConstFloat(t, cc.floatLiteral)
case cc: CtorDoubleContext => ConstDouble(t, cc.doubleLiteral) case cc: CtorDoubleContext => ConstDouble(t, cc.doubleLiteral)
case cc: CtorListContext => ConstSeq(t, null).later(phase2) { case cc: CtorListContext => ConstSeq(t, null).later(phase2) {
_.elems = for (gn <- cc.globalVar()) yield resGlobalVar(gn) _.elems = for (gn <- cc.globalVar().asScala) yield resGlobalVar(gn)
} }
case _: CtorNullContext => ConstNull(t) case _: CtorNullContext => ConstNull(t)
case cc: CtorExternContext => ConstExtern(t, cc.symbol) case cc: CtorExternContext => ConstExtern(t, cc.symbol)
...@@ -287,7 +287,7 @@ private[textinput] class InstanceUIRTextReader(idFactory: IDFactory, source: Str ...@@ -287,7 +287,7 @@ private[textinput] class InstanceUIRTextReader(idFactory: IDFactory, source: Str
logger.debug("Reading consts, globals, funcdefs, funcdecls and expfuncs...") logger.debug("Reading consts, globals, funcdefs, funcdecls and expfuncs...")
val funcDefs = new ArrayBuffer[(Function, FuncDefContext)] val funcDefs = new ArrayBuffer[(Function, FuncDefContext)]
ir.topLevelDef().map(_.getChild(0)).foreach { ir.topLevelDef().iterator.asScala.map(_.getChild(0)).foreach {
case cdctx: ConstDefContext => { case cdctx: ConstDefContext => {
val ty = resTy(cdctx.ty) val ty = resTy(cdctx.ty)
val con = mkConst(ty, cdctx.constConstructor) val con = mkConst(ty, cdctx.constConstructor)
...@@ -385,7 +385,7 @@ private[textinput] class InstanceUIRTextReader(idFactory: IDFactory, source: Str ...@@ -385,7 +385,7 @@ private[textinput] class InstanceUIRTextReader(idFactory: IDFactory, source: Str
param param
} }
bb.norParams = label.bbParam.map { p => bb.norParams = label.bbParam.asScala.map { p =>
val param = mkNorParam(p.`type`(), p.name()) val param = mkNorParam(p.`type`(), p.name())
val sourceInfo = toSourceInfo(p) val sourceInfo = toSourceInfo(p)
addLocalVar(param, sourceInfo) addLocalVar(param, sourceInfo)
...@@ -418,9 +418,9 @@ private[textinput] class InstanceUIRTextReader(idFactory: IDFactory, source: Str ...@@ -418,9 +418,9 @@ private[textinput] class InstanceUIRTextReader(idFactory: IDFactory, source: Str
} }
} }
implicit def resArgList(a: ArgListContext): Seq[SSAVariable] = a.value.map(resVar) implicit def resArgList(a: ArgListContext): Seq[SSAVariable] = a.value.asScala.map(resVar)
implicit def resKA(ka: KeepaliveClauseContext): Seq[LocalVariable] = ka.value.map(resLocalVar) implicit def resKA(ka: KeepaliveClauseContext): Seq[LocalVariable] = ka.value.asScala.map(resLocalVar)
def resFuncCallBody(fcb: FuncCallBodyContext): (FuncSig, SSAVariable, Seq[SSAVariable]) = def resFuncCallBody(fcb: FuncCallBodyContext): (FuncSig, SSAVariable, Seq[SSAVariable]) =
(fcb.funcSig, fcb.callee, fcb.argList) (fcb.funcSig, fcb.callee, fcb.argList)
...@@ -463,7 +463,7 @@ private[textinput] class InstanceUIRTextReader(idFactory: IDFactory, source: Str ...@@ -463,7 +463,7 @@ private[textinput] class InstanceUIRTextReader(idFactory: IDFactory, source: Str
return 0 return 0
} }
var status = 0 var status = 0
val texts = flagList.flag().map(_.getText) val texts = flagList.flag().asScala.map(_.getText)
val ordered = Seq("#N", "#Z", "#C", "#V").filter(t => texts.contains(t)) val ordered = Seq("#N", "#Z", "#C", "#V").filter(t => texts.contains(t))
if(ordered != texts ) { if(ordered != texts ) {
...@@ -515,7 +515,7 @@ private[textinput] class InstanceUIRTextReader(idFactory: IDFactory, source: Str ...@@ -515,7 +515,7 @@ private[textinput] class InstanceUIRTextReader(idFactory: IDFactory, source: Str
case ii: InstSwitchContext => case ii: InstSwitchContext =>
InstSwitch(ii.`type`, null, null, null).later(phase4) { i => InstSwitch(ii.`type`, null, null, null).later(phase4) { i =>
i.opnd = ii.opnd; i.defDest = ii.defDest i.opnd = ii.opnd; i.defDest = ii.defDest
i.cases = (for ((v, d) <- ii.caseVal.zip(ii.caseDest)) yield (resConst(v), resDestClause(d))).to[ArrayBuffer] i.cases = (for ((v, d) <- (ii.caseVal.asScala zip ii.caseDest.asScala)) yield (resConst(v), resDestClause(d))).to[ArrayBuffer]
} }
case ii: InstCallContext => case ii: InstCallContext =>
InstCall(null, null, null, null, null).later(phase4) { i => InstCall(null, null, null, null, null).later(phase4) { i =>
...@@ -528,7 +528,7 @@ private[textinput] class InstanceUIRTextReader(idFactory: IDFactory, source: Str ...@@ -528,7 +528,7 @@ private[textinput] class InstanceUIRTextReader(idFactory: IDFactory, source: Str
} }
case ii: InstRetContext => case ii: InstRetContext =>
InstRet(ver, null).later(phase4) { i => InstRet(ver, null).later(phase4) { i =>
i.retVals = ii.retVals.vals.map(resVar) i.retVals = ii.retVals.vals.asScala.map(resVar)
} }
case ii: InstThrowContext => case ii: InstThrowContext =>
InstThrow(null).later(phase4) { i => InstThrow(null).later(phase4) { i =>
...@@ -663,7 +663,7 @@ private[textinput] class InstanceUIRTextReader(idFactory: IDFactory, source: Str ...@@ -663,7 +663,7 @@ private[textinput] class InstanceUIRTextReader(idFactory: IDFactory, source: Str
val instRess: ArrayBuffer[InstResult] = Option(instDef.instResults) match { val instRess: ArrayBuffer[InstResult] = Option(instDef.instResults) match {
case None => ArrayBuffer() case None => ArrayBuffer()
case Some(r) => (for ((instResDef, index) <- r.results.zipWithIndex) yield { case Some(r) => (for ((instResDef, index) <- r.results.asScala.zipWithIndex) yield {
val resName = globalize(instResDef.getText, bbName) val resName = globalize(instResDef.getText, bbName)
val instRes = InstResult(inst, index) val instRes = InstResult(inst, index)
...@@ -681,12 +681,12 @@ private[textinput] class InstanceUIRTextReader(idFactory: IDFactory, source: Str ...@@ -681,12 +681,12 @@ private[textinput] class InstanceUIRTextReader(idFactory: IDFactory, source: Str
return inst return inst
} }
bb.insts = bbCtx.inst.map(i => mkInst(bb, i)).to[ArrayBuffer] bb.insts = bbCtx.inst.asScala.map(i => mkInst(bb, i)).to[ArrayBuffer]
return bb return bb
} }
val bbs = fDefCtx.funcBody.basicBlock().map(makeBB).to[ArrayBuffer] val bbs = fDefCtx.funcBody.basicBlock().asScala.map(makeBB).to[ArrayBuffer]
ver.bbs = bbs ver.bbs = bbs
......
...@@ -152,11 +152,11 @@ object VMConf { ...@@ -152,11 +152,11 @@ object VMConf {
val ReConf = """^\s*(\w+)=(\S+)\s*$""".r val ReConf = """^\s*(\w+)=(\S+)\s*$""".r
def apply(confStr: String): VMConf = { def apply(confStr: String): VMConf = {
val kvs = confStr.lines map { val kvs = confStr.lines.map {
case ReComment() => None case ReComment() => None
case ReBlank() => None case ReBlank() => None
case ReConf(key, value) => Some((key, value)) case ReConf(key, value) => Some((key, value))
} flatten }.flatten
val map = kvs.toMap val map = kvs.toMap
......
...@@ -39,7 +39,7 @@ class TransitiveClosure[T](initialElems: Seq[T]) { ...@@ -39,7 +39,7 @@ class TransitiveClosure[T](initialElems: Seq[T]) {
} }
} }
def +=(elem: T): TransitiveClosure[T] = { maybeEnqueue(elem); this } def +=(elem: T): TransitiveClosure[T] = { maybeEnqueue(elem); this }
def ++=(elems: Seq[T]): TransitiveClosure[T] = { elems.foreach(this +=); this } def ++=(elems: Seq[T]): TransitiveClosure[T] = { elems.foreach(e => this += e); this }
} }
object TransitiveClosureBuilder { object TransitiveClosureBuilder {
...@@ -381,7 +381,7 @@ class TransitiveClosureBuilder(initialSet: Seq[TopLevel], val primordial: Primor ...@@ -381,7 +381,7 @@ class TransitiveClosureBuilder(initialSet: Seq[TopLevel], val primordial: Primor
} }
override def visitFuncRefField(objRef: Word, iRef: Word, toFunc: Option[Function]): Unit = { override def visitFuncRefField(objRef: Word, iRef: Word, toFunc: Option[Function]): Unit = {
toFunc.foreach(tls+=) toFunc.foreach(f => tls += f)
} }
override def visitUPtrField(objRef: Word, iRef: Word, toAddr: Word): Unit = { override def visitUPtrField(objRef: Word, iRef: Word, toAddr: Word): Unit = {
......
...@@ -11,7 +11,7 @@ class NativeArgv(args: Seq[String]) extends AutoCloseable { ...@@ -11,7 +11,7 @@ class NativeArgv(args: Seq[String]) extends AutoCloseable {
for ((arg, i) <- (args).zipWithIndex) { for ((arg, i) <- (args).zipWithIndex) {
argvOffs(i) = argvSB.length argvOffs(i) = argvSB.length
argvSB ++= arg += '\0' argvSB ++= arg += '\u0000'
} }
val cArgvMem = NativeSupport.allocateManual(argvOffs.length * WORD_SIZE_BYTES.toInt) val cArgvMem = NativeSupport.allocateManual(argvOffs.length * WORD_SIZE_BYTES.toInt)
......
...@@ -2,12 +2,10 @@ package uvm.refimpl.hail ...@@ -2,12 +2,10 @@ package uvm.refimpl.hail
import java.io.Reader import java.io.Reader
import scala.collection.JavaConversions._ import scala.collection.JavaConverters._
import scala.collection.mutable.HashMap import scala.collection.mutable.HashMap
import org.antlr.v4.runtime.ANTLRInputStream import org.antlr.v4.runtime._
import org.antlr.v4.runtime.CommonTokenStream
import org.antlr.v4.runtime.ParserRuleContext
import org.slf4j.LoggerFactory import org.slf4j.LoggerFactory
import com.typesafe.scalalogging.Logger import com.typesafe.scalalogging.Logger
...@@ -40,7 +38,7 @@ class HailScriptLoader(recordSourceInfo: Boolean = true)(implicit microVM: Micro ...@@ -40,7 +38,7 @@ class HailScriptLoader(recordSourceInfo: Boolean = true)(implicit microVM: Micro
} }
def loadHail(hailScript: String): Unit = { def loadHail(hailScript: String): Unit = {
val ais = new ANTLRInputStream(hailScript) val ais = CharStreams.fromString(hailScript)
val ea = new AccumulativeAntlrErrorListener(hailScript) val ea = new AccumulativeAntlrErrorListener(hailScript)
val lexer = new HAILLexer(ais) val lexer = new HAILLexer(ais)
...@@ -78,7 +76,7 @@ class InstanceHailScriptLoader(microVM: MicroVM, memorySupport: MemorySupport, m ...@@ -78,7 +76,7 @@ class InstanceHailScriptLoader(microVM: MicroVM, memorySupport: MemorySupport, m
val hailObjMap = new HailObjMap val hailObjMap = new HailObjMap
def loadTopLevel(ast: HailContext): Unit = { def loadTopLevel(ast: HailContext): Unit = {
ast.topLevelDef.map(_.getChild(0)) foreach { ast.topLevelDef.asScala.map(_.getChild(0)) foreach {
case tl: FixedAllocContext => { case tl: FixedAllocContext => {
val hailName = tl.nam.getText val hailName = tl.nam.getText
...@@ -208,7 +206,7 @@ class InstanceHailScriptLoader(microVM: MicroVM, memorySupport: MemorySupport, m ...@@ -208,7 +206,7 @@ class InstanceHailScriptLoader(microVM: MicroVM, memorySupport: MemorySupport, m
var cur: LValue = base var cur: LValue = base
for (ic <- lv.indices) { for (ic <- lv.indices.iterator.asScala) {
val index = evalIntExpr(ic.intExpr()).toLong val index = evalIntExpr(ic.intExpr()).toLong
val newCur = cur.indexInto(index, ic)