Skip to content

Commit

Permalink
Various fixes and improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
propensive committed Jun 22, 2022
1 parent c5db71a commit a2cd5a6
Show file tree
Hide file tree
Showing 8 changed files with 239 additions and 213 deletions.
100 changes: 50 additions & 50 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,13 @@ RUN unzip -q -o -d /irk/bin /irk/scala/dist/target/pack/lib/flexmark-ext-tables-
RUN rm -r /irk/bin/META-INF
ADD src /irk/src
ADD one.jar /irk/one.jar
RUN unzip -q /irk/one.jar -d /irk
RUN unzip -q /irk/one.jar -d /

RUN javac -classpath /irk/lib/jna.jar \
-d /irk/bin \
/irk/one/mod/profanity/src/java/profanity/Termios.java
/one/mod/profanity/src/java/profanity/Termios.java

RUN cp -r /irk/one/mod/gesticulate/res/gesticulate /irk/bin/
RUN cp -r /one/mod/gesticulate/res/gesticulate /irk/bin/

RUN cd /irk && scala/bin/scalac \
-classpath bin \
Expand All @@ -53,42 +53,42 @@ RUN cd /irk && scala/bin/scalac \
-language:experimental.saferExceptions \
-language:experimental.erasedDefinitions \
-d bin \
one/mod/acyclicity/src/core/*.scala \
one/mod/adversaria/src/core/*.scala \
one/mod/caesura/src/core/*.scala \
one/mod/cataract/src/core/*.scala \
one/mod/clairvoyant/src/css/*.scala \
one/mod/clairvoyant/src/file/*.scala \
one/mod/clairvoyant/src/html/*.scala \
one/mod/clairvoyant/src/http/*.scala \
one/mod/clairvoyant/src/time/*.scala \
one/mod/clairvoyant/src/uri/*.scala \
one/mod/contextual/src/core/*.scala \
one/mod/cosmopolite/src/core/*.scala \
one/mod/escapade/src/core/*.scala \
one/mod/escritoire/src/core/*.scala \
one/mod/eucalyptus/src/core/*.scala \
one/mod/euphemism/src/core/*.scala \
one/mod/exoskeleton/src/core/*.scala \
one/mod/gastronomy/src/core/*.scala \
one/mod/gesticulate/src/core/*.scala \
one/mod/gossamer/src/core/*.scala \
one/mod/guillotine/src/core/*.scala \
one/mod/harlequin/src/core/*.scala \
one/mod/imperial/src/core/*.scala \
one/mod/iridescence/src/core/*.scala \
one/mod/jovian/src/core/*.scala \
one/mod/kaleidoscope/src/core/*.scala \
one/mod/probably/src/cli/*.scala \
one/mod/probably/src/core/*.scala \
one/mod/probably/src/tolerance/*.scala \
one/mod/profanity/src/core/*.scala \
one/mod/profanity/src/java/**/*.java \
one/mod/rudiments/src/core/*.scala \
one/mod/slalom/src/core/*.scala \
one/mod/turbulence/src/core/*.scala \
one/mod/wisteria/src/core/*.scala \
one/mod/xylophone/src/core/*.scala
/one/mod/acyclicity/src/core/*.scala \
/one/mod/adversaria/src/core/*.scala \
/one/mod/caesura/src/core/*.scala \
/one/mod/cataract/src/core/*.scala \
/one/mod/clairvoyant/src/css/*.scala \
/one/mod/clairvoyant/src/file/*.scala \
/one/mod/clairvoyant/src/html/*.scala \
/one/mod/clairvoyant/src/http/*.scala \
/one/mod/clairvoyant/src/time/*.scala \
/one/mod/clairvoyant/src/uri/*.scala \
/one/mod/contextual/src/core/*.scala \
/one/mod/cosmopolite/src/core/*.scala \
/one/mod/escapade/src/core/*.scala \
/one/mod/escritoire/src/core/*.scala \
/one/mod/eucalyptus/src/core/*.scala \
/one/mod/euphemism/src/core/*.scala \
/one/mod/exoskeleton/src/core/*.scala \
/one/mod/gastronomy/src/core/*.scala \
/one/mod/gesticulate/src/core/*.scala \
/one/mod/gossamer/src/core/*.scala \
/one/mod/guillotine/src/core/*.scala \
/one/mod/harlequin/src/core/*.scala \
/one/mod/imperial/src/core/*.scala \
/one/mod/iridescence/src/core/*.scala \
/one/mod/jovian/src/core/*.scala \
/one/mod/kaleidoscope/src/core/*.scala \
/one/mod/probably/src/cli/*.scala \
/one/mod/probably/src/core/*.scala \
/one/mod/probably/src/tolerance/*.scala \
/one/mod/profanity/src/core/*.scala \
/one/mod/profanity/src/java/**/*.java \
/one/mod/rudiments/src/core/*.scala \
/one/mod/slalom/src/core/*.scala \
/one/mod/turbulence/src/core/*.scala \
/one/mod/wisteria/src/core/*.scala \
/one/mod/xylophone/src/core/*.scala

RUN cd /irk && scala/bin/scalac \
-classpath bin \
Expand All @@ -97,7 +97,7 @@ RUN cd /irk && scala/bin/scalac \
-language:experimental.saferExceptions \
-language:experimental.erasedDefinitions \
-d bin \
one/mod/honeycomb/src/core/*.scala
/one/mod/honeycomb/src/core/*.scala

RUN cd /irk && scala/bin/scalac \
-classpath bin \
Expand All @@ -106,14 +106,14 @@ RUN cd /irk && scala/bin/scalac \
-language:experimental.saferExceptions \
-language:experimental.erasedDefinitions \
-d bin \
one/mod/punctuation/src/ansi/*.scala \
one/mod/punctuation/src/core/*.scala \
one/mod/punctuation/src/html/*.scala \
one/mod/scintillate/src/core/*.scala \
one/mod/scintillate/src/server/*.scala \
one/mod/scintillate/src/servlet/*.scala \
one/mod/scintillate/src/uri/*.scala \
one/mod/tarantula/src/core/*.scala
/one/mod/punctuation/src/ansi/*.scala \
/one/mod/punctuation/src/core/*.scala \
/one/mod/punctuation/src/html/*.scala \
/one/mod/scintillate/src/core/*.scala \
/one/mod/scintillate/src/server/*.scala \
/one/mod/scintillate/src/servlet/*.scala \
/one/mod/scintillate/src/uri/*.scala \
/one/mod/tarantula/src/core/*.scala

RUN cd /irk && scala/bin/scalac \
-classpath bin \
Expand All @@ -133,7 +133,7 @@ RUN unzip -q -o -d /irk/bin /irk/scala/dist/target/pack/lib/scala3-staging*.jar
RUN unzip -q -o -d /irk/bin /irk/scala/dist/target/pack/lib/scala3-interfaces*.jar
RUN unzip -q -o -d /irk/bin /irk/scala/dist/target/pack/lib/scala3-tasty-inspector*.jar
RUN unzip -q -o -d /irk/bin /irk/scala/dist/target/pack/lib/scala-asm*.jar
RUN cp /irk/one/mod/exoskeleton/res/exoskeleton/invoke /irk/bin/exoskeleton/invoke
RUN cp /one/mod/exoskeleton/res/exoskeleton/invoke /irk/bin/exoskeleton/invoke
ADD doc/.version /irk/.version
RUN echo 'Manifest-Version: 1.0' > /irk/manifest
RUN echo -n 'Created-By: Irk ' >> /irk/manifest
Expand Down Expand Up @@ -189,7 +189,7 @@ RUN jar cmf /irk/manifest /irk/irk.jar \
-C /irk/bin wisteria \
-C /irk/bin xylophone

RUN cat /irk/one/mod/exoskeleton/res/exoskeleton/invoke /irk/irk.jar > /irk/bootstrap
RUN cat /one/mod/exoskeleton/res/exoskeleton/invoke /irk/irk.jar > /irk/bootstrap
RUN chmod +x /irk/bootstrap
RUN rm /irk/irk.jar
ADD build.irk /irk/build.irk
Expand Down
5 changes: 3 additions & 2 deletions build.irk
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,10 @@
"id": "irk/core",
"links": ["harlequin/core", "xylophone/core", "profanity/core", "guillotine/core",
"acyclicity/core", "jovian/core", "scintillate/core", "euphemism/core", "honeycomb/core",
"exoskeleton/core", "clairvoyant/time", "imperial/core", "tarantula/core"],
"exoskeleton/core", "clairvoyant/time", "imperial/core", "tarantula/core",
"escritoire/core"],
"sources": ["src/core"],
"version": "0.5.1",
"version": "0.5.3",
"docs": ["doc"],
"artifact": {
"main": "irk.Irk",
Expand Down
2 changes: 1 addition & 1 deletion doc/.version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.5.1
0.5.3
62 changes: 37 additions & 25 deletions src/core/compilation.scala
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import rudiments.*
import gossamer.*
import jovian.*
import escapade.*
import slalom.*

import rendering.ansi

Expand All @@ -20,7 +21,7 @@ object Compiler:

private var Scala3 = new dotty.tools.dotc.Compiler()

def compile(id: Text, files: List[File], inputs: Set[DiskPath], out: Directory, script: File,
def compile(id: Text, pwd: Directory, files: List[File], inputs: Set[DiskPath], out: Directory, script: File,
cancel: Promise[Unit])
(using Stdout)
: Result =
Expand All @@ -32,8 +33,8 @@ object Compiler:
try
val separator: Text = try Sys.path.separator() catch case err: KeyNotFoundError => t":"

val classpath: List[Text] = inputs.map:
path => if path.isDirectory then t"${path.fullname}/" else path.fullname
val classpath: List[Text] = inputs.map: path =>
if path.isDirectory then t"${path.fullname}/" else path.fullname
.to(List) :+ Irk.irkJar(script).fullname

val classpathText = classpath.reverse.join(separator)
Expand All @@ -45,50 +46,61 @@ object Compiler:

override def onSourceCompiled(source: interfaces.SourceFile): Unit = ()


object driver extends dotc.Driver:
val currentCtx =
val ctx = initCtx.fresh

setup(Array[String]("-d", out.fullname.s, "-deprecation", "-feature", "-Wunused:all",
"-new-syntax", "-Yrequire-targetName", "-Ysafe-init", "-Yexplicit-nulls",
"-Xmax-inlines", "64",
"-Ycheck-all-patmat", "-classpath", classpathText.s, ""), ctx).map(_(1)).get
"-Xmax-inlines", "64", "-Ycheck-all-patmat", "-classpath", classpathText.s, ""),
ctx).map(_(1)).get

def run(files: List[File], classpath: Text): List[Diagnostic] =
val ctx = currentCtx.fresh

val features = List(t"fewerBraces", t"saferExceptions", t"erasedDefinitions").map:
f => t"experimental.$f".s

val ctx2 = ctx
.setReporter(reporter)
.setCompilerCallback(callbackApi)
.setSetting(ctx.settings.language, List("experimental.fewerBraces", "experimental.saferExceptions", "experimental.erasedDefinitions"))
.setSetting(ctx.settings.language, features)
.setSetting(ctx.settings.classpath, classpath.s)

val sources = files.to(List).map:
file => PlainFile(Path(file.fullname.s))

val run: Run = Scala3.newRun(using ctx2)
cancel.future.andThen:
_ => run.isCancelled = true

cancel.future.andThen: _ =>
run.isCancelled = true

run.compile(sources)
finish(Scala3, run)(using ctx2)
reporter.errors.to(List)

driver.run(files, classpathText).foldLeft(Result.Complete(Nil)):
(prev, diagnostic) =>
if diagnostic.position.isPresent then
val pos = diagnostic.position.get.nn
val line = pos.line
val file = pos.source.nn.name.nn
val content = pos.source.nn.content.nn
val level = diagnostic.level match
case 0 => Level.Info
case 1 => Level.Warn
case 2 => Level.Error
case _ => Level.Info

prev + Result.Complete(List(Issue(level, id, file.show, line, pos.startColumn, pos.endColumn,
pos.endLine, diagnostic.message.show, content.unsafeImmutable)))
else prev + Result.Complete(Nil)
driver.run(files, classpathText).foldLeft(Result.Complete(Nil)): (prev, diagnostic) =>
if diagnostic.position.isPresent then
val pos = diagnostic.position.get.nn
val line = pos.line
val file = pos.source.nn.path.nn
val content = pos.source.nn.content.nn

val level = diagnostic.level match
case 0 => Level.Info
case 1 => Level.Warn
case 2 => Level.Error
case _ => Level.Info

val path =
try
Unix.parse(file.show).relativeTo(pwd.path).getOrElse(Relative.Self)
catch case err: InvalidPathError =>
Relative.parse(file.show)

prev + Result.Complete(List(Issue(level, id, path, line, pos.startColumn, pos.endColumn,
pos.endLine, diagnostic.message.show, content.immutable(using Unsafe))))
else prev + Result.Complete(Nil)

catch case err: Throwable =>
if !cancel.isCompleted then
Expand Down
Loading

0 comments on commit a2cd5a6

Please sign in to comment.