Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions engine/common/src/main/java/org/enso/common/HostEnsoUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@
import org.graalvm.polyglot.PolyglotException;

public final class HostEnsoUtils {
private HostEnsoUtils() {
}
private HostEnsoUtils() {}

/**
* Extracts a string representation for a polyglot exception.
Expand All @@ -14,12 +13,13 @@ private HostEnsoUtils() {
* @return message representing the exception
*/
public static String findExceptionMessage(Throwable ex) {
return ex.getMessage() != null ? ex.getMessage() : switch (ex) {
case PolyglotException exception when exception.isHostException() ->
exception.asHostException().getClass().getName();
default ->
ex.getClass().getName();
};
return ex.getMessage() != null
? ex.getMessage()
: switch (ex) {
case PolyglotException exception when exception.isHostException() ->
exception.asHostException().getClass().getName();
default -> ex.getClass().getName();
};
}

/**
Expand Down
15 changes: 8 additions & 7 deletions engine/runner/src/main/java/org/enso/runner/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -1018,11 +1018,11 @@ private void runRepl(
var mainMethodName = "internal_repl_entry_point___";
var dummySourceToTriggerRepl =
"""
from Standard.Base import all
import Standard.Base.Runtime.Debug
from Standard.Base import all
import Standard.Base.Runtime.Debug

$mainMethodName = Debug.breakpoint
"""
$mainMethodName = Debug.breakpoint
"""
.replace("$mainMethodName", mainMethodName);
var replModuleName = "Internal_Repl_Module___";
var projectRoot = projectPath != null ? projectPath : "";
Expand Down Expand Up @@ -1267,7 +1267,7 @@ private boolean shouldEnableIrCaches(CommandLine line) {
if (line.hasOption(ENABLE_STATIC_ANALYSIS_OPTION)) {
if (line.hasOption(IR_CACHES_OPTION)) {
throw exitFail(
""
""
+ ENABLE_STATIC_ANALYSIS_OPTION
+ " requires IR caches to be disabled, so --"
+ IR_CACHES_OPTION
Expand Down Expand Up @@ -1602,8 +1602,9 @@ private void launch(String[] args) throws IOException, InterruptedException, URI
launchJvm(originalCwdOrNull, line, props, component, javaExecutable);
return;
} else {
throw exitFail("Cannot find java executable to run in JVM mode. JVM mode " +
"was enforced either by `--jvm` option or by project configuration.");
throw exitFail(
"Cannot find java executable to run in JVM mode. JVM mode "
+ "was enforced either by `--jvm` option or by project configuration.");
}
}
}
Expand Down
9 changes: 5 additions & 4 deletions engine/runner/src/main/java/org/enso/runner/Repl.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,11 @@ final class Repl implements SessionManager {
switch (content) {
case ":list", ":l" -> {
var bindings = executor.listBindings();
bindings.foreachEntry((name, value) -> {
replIO.println(name + " = " + value);
return null;
});
bindings.foreachEntry(
(name, value) -> {
replIO.println(name + " = " + value);
return null;
});
}
case ":quit", "q" -> {
continueRunning = false;
Expand Down
21 changes: 11 additions & 10 deletions engine/runner/src/test/java/org/enso/runner/UtilsTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,14 @@ public void printStackTrace1() throws Exception {
var f = folder.newFile("p.enso");
var code =
"""
from Standard.Base import all
from Standard.Base import all
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, somebody fixed the formatting of the text blocks.


a = b
b = c
c = Panic.throw "foo"
a = b
b = c
c = Panic.throw "foo"

main = a
""";
main = a
""";
Files.writeString(f.toPath(), code);

var lines = new ArrayList<String>();
Expand All @@ -55,10 +55,11 @@ public void printStackTrace1() throws Exception {

assertEquals(
"""
Execution finished with an error: foo
at <enso> throw(Internal)
at <enso> c(Internal)
at <enso> main(Internal)""",
Execution finished with an error: foo
at <enso> throw(Internal)
at <enso> c(Internal)
at <enso> main(Internal)\
""",
lines.stream().collect(Collectors.joining("\n")));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ public String createExpression(List<String> identifiers, int size) {

return switch (size) {
case 0 -> nextLiteral();
// Either a single identifier or a method call on the identifier
// Either a single identifier or a method call on the identifier
case 1 -> {
var sb = new StringBuilder();
var ident = chooseIdentifier(identifiers);
Expand All @@ -174,7 +174,7 @@ public String createExpression(List<String> identifiers, int size) {
}
yield sb.toString();
}
// Method call or binary operator
// Method call or binary operator
case 2 -> {
var sb = new StringBuilder();
var shouldCallMethod = random.nextBoolean();
Expand All @@ -196,7 +196,7 @@ public String createExpression(List<String> identifiers, int size) {
}
yield sb.toString();
}
// Split into two expressions with random size
// Split into two expressions with random size
default -> {
var sb = new StringBuilder();
var shouldCallMethod = random.nextBoolean();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public class ImportStandardLibrariesBenchmark {
"Connection_Options.Connection_Options");

private static final String IMPORTS =
"""
"""
from Standard.Base import all
from Standard.Table import all
from Standard.Database import all
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,20 +72,20 @@ public void setup(BenchmarkParams params) throws IOException {
for (int i = 0; i < ERRORS_CNT; i++) {
var rndInt = random.nextInt(0, 3);
switch (rndInt) {
// Expression with unknown identifiers
// Expression with unknown identifiers
case 0 -> {
var expr = codeGen.createExpression(UNDEFINED_IDENTIFIERS, EXPR_SIZE);
sb.append(" ").append(expr).append(System.lineSeparator());
}
// Inline type ascription with unknown identifier
// Inline type ascription with unknown identifier
case 1 -> {
var expr = codeGen.createExpression(definedIdentifiers, EXPR_SIZE);
sb.append(" ")
.append(" var : (Type.Constructor.Foo Bar.Baz A B) = ")
.append(expr)
.append(System.lineSeparator());
}
// Put arrows before, after, and between expressions
// Put arrows before, after, and between expressions
case 2 -> {
var expr1 = codeGen.createExpression(definedIdentifiers, EXPR_SIZE);
var expr2 = codeGen.createExpression(definedIdentifiers, EXPR_SIZE);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ private void createNestedBlocks(int nestedBlockIdx) {
.append(System.lineSeparator());
createNestedBlocks(nestedBlockIdx + 1);
}
// Create a nested anonymous function
// Create a nested anonymous function
case 3 -> {
var argsCnt = random.nextInt(1, ANONYMOUS_FUNC_MAX_ARGS);
sb.append(spaces);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
public class CallableBenchmarks {
private static final long HUNDRED_MILLION = 100_000_000L;
private static final String SUM_TCO_FROM_CALL_CODE =
"""
"""
from Standard.Base.Data.Numbers import all

type Foo
Expand All @@ -40,7 +40,7 @@ public class CallableBenchmarks {
""";

private static final String SUM_TCO_METHOD_CALL_CODE =
"""
"""
summator = acc -> current ->
if current == 0 then acc else @Tail_Call summator (acc + current) (current - 1)

Expand All @@ -50,7 +50,7 @@ public class CallableBenchmarks {
""";

private static final String SUM_TCO_METHOD_CALL_WITH_NAMED_ARGUMENTS_CODE =
"""
"""
summator = acc -> current ->
if current == 0 then acc else @Tail_Call summator (current = current - 1) (acc = acc + current)

Expand All @@ -60,7 +60,7 @@ public class CallableBenchmarks {
""";

private static final String SUM_TCO_METHOD_CALL_WITH_DEFAULTED_ARGUMENTS_CODE =
"""
"""
summator = (acc = 0) -> current ->
if current == 0 then acc else @Tail_Call summator (current = current - 1) (acc = acc + current)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,39 +60,39 @@ public void initializeBenchmark(BenchmarkParams params) throws Exception {
var codeBuilder =
new StringBuilder(
"""
import Standard.Base.Data.Range.Extensions
import Standard.Base.Data.Numbers.Number
import Standard.Base.Data.Ordering.Ordering
import Standard.Base.Data.Ordering.Comparable

type Num
Value n

Num.from (that:Number) = Num.Value that
Comparable.from (_:Number) = Num_Comparator
Comparable.from (_:Num) = Num_Comparator

type Num_Comparator
compare x:Num y:Num = Ordering.compare x.n y.n
hash x:Num = Ordering.hash x.n

type Node
C1 f1
C2 f1 f2
C3 f1 f2 f3
C4 f1 f2 f3 f4
C5 f1 f2 f3 f4 f5
Nil
Value value

eq_vec vec1 vec2 =
(0.up_to vec1.length).map idx->
v1 = vec1.at idx
v2 = vec2.at idx
v1 == v2

eq x y = x == y
""");
import Standard.Base.Data.Range.Extensions
import Standard.Base.Data.Numbers.Number
import Standard.Base.Data.Ordering.Ordering
import Standard.Base.Data.Ordering.Comparable

type Num
Value n

Num.from (that:Number) = Num.Value that
Comparable.from (_:Number) = Num_Comparator
Comparable.from (_:Num) = Num_Comparator

type Num_Comparator
compare x:Num y:Num = Ordering.compare x.n y.n
hash x:Num = Ordering.hash x.n

type Node
C1 f1
C2 f1 f2
C3 f1 f2 f3
C4 f1 f2 f3 f4
C5 f1 f2 f3 f4 f5
Nil
Value value

eq_vec vec1 vec2 =
(0.up_to vec1.length).map idx->
v1 = vec1.at idx
v2 = vec2.at idx
v1 == v2

eq x y = x == y
""");
// Indexes where `True` is expected. Inside the generated vectors, on a predefined indexes,
// we put "constant" values, such that when the elements at these indexes are compared,
// `True` is returned.
Expand Down Expand Up @@ -169,7 +169,8 @@ public void initializeBenchmark(BenchmarkParams params) throws Exception {
default -> throw new IllegalStateException("Unexpected benchmark: " + params.getBenchmark());
}

codeBuilder.append("""
codeBuilder.append(
"""
bench _ = eq_vec vec1 vec2
""");

Expand Down Expand Up @@ -418,8 +419,8 @@ public String createSource() {
case 3 -> "(Node.C3 ";
case 4 -> "(Node.C4 ";
case 5 -> "(Node.C5 ";
default -> throw new AssertionError(
"Unexpected number of children: " + children.size());
default ->
throw new AssertionError("Unexpected number of children: " + children.size());
};
var sb = new StringBuilder();
sb.append(ctor);
Expand Down
Loading
Loading