-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1144 from utwente-fmt/vcllvm
Vcllvm
- Loading branch information
Showing
79 changed files
with
3,245 additions
and
3,513 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package vct.col.ast.structure.api | ||
|
||
import java.nio.file.Path | ||
|
||
trait AllFamiliesGeneratorApi { | ||
def generate(out: Path, declaredFamilies: String, structuralFamilies: String): Unit | ||
} | ||
|
||
trait AllNodesGeneratorApi { | ||
def generate(out: Path, definitions: String): Unit | ||
} | ||
|
||
trait NodeGeneratorApi { | ||
def generate(out: Path, node: String): Unit | ||
} | ||
|
||
trait FamilyGeneratorApi { | ||
def generate(out: Path, family: String, kind: String, nodes: String): Unit | ||
} | ||
|
||
trait ImplTraitGeneratorApi { | ||
def fix(p: Path, opsNames: String): Unit | ||
def generate(p: Path, node: String, concrete: Boolean, family: Boolean): Unit | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,37 @@ | ||
package vct.col.ast.structure | ||
|
||
import vct.col.ast.structure.api._ | ||
|
||
import java.nio.file.Path | ||
import upickle.default.read | ||
|
||
trait AllFamiliesGenerator { | ||
trait AllFamiliesGenerator extends AllFamiliesGeneratorApi { | ||
override def generate(out: Path, declaredFamilies: String, structuralFamilies: String): Unit = | ||
generate(out, read[Seq[Name]](declaredFamilies), read[Seq[Name]](structuralFamilies)) | ||
def generate(out: Path, declaredFamilies: Seq[Name], structuralFamilies: Seq[Name]): Unit | ||
} | ||
|
||
trait AllNodesGenerator { | ||
trait AllNodesGenerator extends AllNodesGeneratorApi { | ||
override def generate(out: Path, definitions: String): Unit = | ||
generate(out, read[Seq[NodeDefinition]](definitions)) | ||
def generate(out: Path, definitions: Seq[NodeDefinition]): Unit | ||
} | ||
|
||
trait NodeGenerator { | ||
trait NodeGenerator extends NodeGeneratorApi { | ||
override def generate(out: Path, node: String): Unit = | ||
generate(out, read[NodeDefinition](node)) | ||
def generate(out: Path, node: NodeDefinition): Unit | ||
} | ||
|
||
trait FamilyGenerator { | ||
trait FamilyGenerator extends FamilyGeneratorApi { | ||
override def generate(out: Path, family: String, kind: String, nodes: String): Unit = | ||
generate(out, read[Name](family), read[NodeKind](kind), read[Seq[Name]](nodes)) | ||
def generate(out: Path, family: Name, kind: NodeKind, nodes: Seq[Name]): Unit | ||
} | ||
|
||
trait ImplTraitGenerator { | ||
trait ImplTraitGenerator extends ImplTraitGeneratorApi { | ||
override def fix(p: Path, opsNames: String): Unit = | ||
fix(p, read[Seq[String]](opsNames)) | ||
def fix(p: Path, opsNames: Seq[String]): Unit | ||
def generate(p: Path, node: String, concrete: Boolean, family: Boolean): Unit | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import mill.{Agg, define} | ||
import mill.scalalib.DepSyntax | ||
|
||
package object settings { | ||
val root = os.pwd | ||
val src = root / "src" | ||
val test = root / "test" | ||
val res = root / "res" | ||
val lib = root / "lib" | ||
val docs = root / "docs" | ||
val meta = root / "out" / "mill-build" | ||
|
||
object deps { | ||
val log = Agg( | ||
ivy"com.typesafe.scala-logging::scala-logging:3.9.5", | ||
ivy"ch.qos.logback:logback-classic:1.4.5", | ||
) | ||
|
||
val common = log ++ Agg( | ||
ivy"org.scala-lang.modules::scala-parallel-collections:1.0.4", | ||
) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
import mill._ | ||
import os.Path | ||
|
||
package object util { | ||
case class DataPoint(base: Path, coordinate: os.SubPath) { | ||
lazy val mtime = os.mtime(base / coordinate) | ||
|
||
override def equals(obj: Any): Boolean = obj match { | ||
case other: DataPoint => coordinate == other.coordinate | ||
} | ||
|
||
private lazy val _hashCode = coordinate.hashCode() | ||
override def hashCode(): Int = _hashCode | ||
|
||
def copyTo(dest: Path): Unit = { | ||
os.copy(base / coordinate, dest / coordinate, createFolders = true) | ||
} | ||
|
||
def copyOver(dest: Path): Unit = | ||
if(DataPoint(dest, coordinate).mtime != mtime) | ||
os.copy.over(base / coordinate, dest / coordinate) | ||
|
||
def delete(): Unit = | ||
os.remove(base / coordinate) | ||
} | ||
|
||
def quickCopy(target: Path, sourcePaths: Seq[PathRef]): Unit = { | ||
val sources = | ||
sourcePaths | ||
.map(_.path) | ||
.flatMap { base => | ||
os.walk.stream(base) | ||
.filter(os.isFile(_)) | ||
.map(p => DataPoint(base, p.subRelativeTo(base))) | ||
.toSeq | ||
} | ||
.toSet | ||
|
||
val targets = | ||
os.walk.stream(target) | ||
.filter(os.isFile(_)) | ||
.map(p => DataPoint(target, p.subRelativeTo(target))) | ||
.toSet | ||
|
||
for(toRemove <- targets if !sources.contains(toRemove)) { | ||
toRemove.delete() | ||
} | ||
|
||
for(toWrite <- sources if !targets.contains(toWrite)) { | ||
toWrite.copyTo(target) | ||
} | ||
|
||
for(toWriteOver <- sources if targets.contains(toWriteOver)) { | ||
toWriteOver.copyOver(target) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package util | ||
|
||
import me.pieterbos.mill.cpp.{CppModule => BaseCppModule, CppExecutableModule => BaseCppExecutableModule, _} | ||
import mill.T | ||
|
||
trait CppModule extends BaseCppModule { | ||
override def standard: T[options.CppStandard] = T[options.CppStandard] { options.CppStandard.Cpp20 } | ||
} | ||
|
||
trait CppExecutableModule extends BaseCppExecutableModule with CppModule |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package util | ||
|
||
import mill.{T, Module, pathReadWrite} | ||
|
||
trait GitModule extends Module { | ||
def url: T[String] | ||
|
||
def commitish: T[String] | ||
|
||
def fetchSubmodulesRecursively: T[Boolean] = false | ||
|
||
def repo = T { | ||
os.proc("git", "init", "-q").call(cwd = T.dest) | ||
os.proc("git", "remote", "add", "origin", url()).call(cwd = T.dest) | ||
os.proc("git", "fetch", "--depth", "1", "origin", commitish()).call(cwd = T.dest) | ||
os.proc("git", "config", "advice.detachedHead", "false").call(cwd = T.dest) | ||
os.proc("git", "checkout", "FETCH_HEAD").call(cwd = T.dest) | ||
if(fetchSubmodulesRecursively()) | ||
os.proc("git", "submodule", "update", "--init", "--recursive").call(cwd = T.dest) | ||
os.walk(T.dest).foreach(_.toIO.setWritable(true)) | ||
os.remove.all(T.dest / ".git") | ||
T.dest | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
package util | ||
|
||
import mill._ | ||
import scalalib.{JavaModule => BaseJavaModule} | ||
|
||
trait JavaModule extends BaseJavaModule { | ||
// https://github.com/viperproject/silicon/issues/748 | ||
// 32MB is enough stack space for silicon, a 100% marco guarantee | ||
override def forkArgs = Seq("-Xmx2G", "-Xss32m") | ||
|
||
def classPathFileElements = T { runClasspath().map(_.path.toString) } | ||
|
||
def unixClassPathArgumentFile = T { | ||
val cpString = classPathFileElements().mkString(":") | ||
val cpArg = "-cp " + cpString | ||
os.write(T.dest / "classpath", cpArg) | ||
T.dest / "classpath" | ||
} | ||
|
||
def strictOptionsFile = T.source { | ||
settings.root / ".compile-strict" | ||
} | ||
|
||
def strictOptions: T[Boolean] = T { | ||
os.exists(strictOptionsFile().path) | ||
} | ||
|
||
override def javacOptions = T { | ||
val shared = Seq( | ||
"--release", "17", | ||
"-deprecation", | ||
) | ||
|
||
if(strictOptions()) { | ||
Seq( | ||
"-Werror", | ||
) ++ shared | ||
} else { | ||
Seq ( | ||
// nothing here yet | ||
) ++ shared | ||
} | ||
} | ||
|
||
def windowsClassPathArgumentFile = T { | ||
val cpString = classPathFileElements().mkString(";") | ||
val cpArg = "-cp " + cpString | ||
os.write(T.dest / "classpath", cpArg) | ||
T.dest / "classpath" | ||
} | ||
|
||
def runScriptClasses = T { | ||
Map( | ||
"run" -> finalMainClass(), | ||
) | ||
} | ||
|
||
def runScript = T { | ||
// PB: this is nearly just Jvm.createLauncher, but you cannot set the filename, and uses a literal classpath instead of a file. | ||
for((name, mainClass) <- runScriptClasses()) { | ||
// thanks https://gist.github.com/lhns/ee821a5cd1b2031856b21a0e78e1ecc9 | ||
val quote = "\"" | ||
val header = "@ 2>/dev/null # 2>nul & echo off & goto BOF" | ||
val unix = Seq( | ||
":", | ||
s"java ${forkArgs().mkString(" ")} @${unixClassPathArgumentFile()} $mainClass $quote$$@$quote", | ||
"exit", | ||
) | ||
val batch = Seq( | ||
":BOF", | ||
s"java ${forkArgs().mkString(" ")} @${windowsClassPathArgumentFile()} $mainClass %*", | ||
"exit /B %errorlevel%", | ||
) | ||
val script = header + "\r\n" + unix.mkString("\n") + "\n\r\n" + batch.mkString("\r\n") + "\r\n" | ||
val isWin = scala.util.Properties.isWin | ||
val wantBatch = isWin && !org.jline.utils.OSUtils.IS_CYGWIN && !org.jline.utils.OSUtils.IS_MSYSTEM | ||
val fileName = if(wantBatch) name + ".bat" else name | ||
os.write(T.dest / fileName, script) | ||
if(!isWin) os.perms.set(T.dest / name, os.PermSet.fromString("rwxrwxr-x")) | ||
} | ||
T.dest | ||
} | ||
} |
Oops, something went wrong.