Skip to content

Commit

Permalink
Merge pull request #3736 from objectionary/3735
Browse files Browse the repository at this point in the history
show file name and line number
  • Loading branch information
yegor256 authored Dec 23, 2024
2 parents 8dc9d33 + 219b645 commit 55637d4
Show file tree
Hide file tree
Showing 15 changed files with 264 additions and 440 deletions.
4 changes: 3 additions & 1 deletion eo-maven-plugin/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,9 @@ SOFTWARE.
<configuration combine.self="override">
<skipInstallation>${skipITs}</skipInstallation>
<skipInvocation>${skipITs}</skipInvocation>
<pomExcludes/>
<pomExcludes>
<exclude>fibonacci/pom.xml</exclude>
</pomExcludes>
</configuration>
</plugin>
<plugin>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -404,7 +404,7 @@ SOFTWARE.
<xsl:value-of select="$indent"/>
<xsl:value-of select="eo:tabs(1)"/>
<xsl:value-of select="$name"/>
<xsl:text> = new PhLocated(</xsl:text>
<xsl:text> = new PhSafe(</xsl:text>
<xsl:value-of select="$name"/>
<xsl:text>, "</xsl:text>
<xsl:value-of select="/program/@name"/>
Expand Down Expand Up @@ -538,9 +538,9 @@ SOFTWARE.
<xsl:value-of select="eo:eol(3 + $indent)"/>
<xsl:text>new Dataized(</xsl:text>
<xsl:value-of select="eo:eol(4 + $indent)"/>
<xsl:text>new PhSafe(new </xsl:text>
<xsl:text>new </xsl:text>
<xsl:value-of select="eo:class-name(@name, eo:suffix(@line, @pos))"/>
<xsl:text>())</xsl:text>
<xsl:text>()</xsl:text>
<xsl:value-of select="eo:eol(3 + $indent)"/>
<xsl:text>).asBool()</xsl:text>
<xsl:value-of select="eo:eol(2 + $indent)"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,14 @@ sheets:
- /org/eolang/parser/blank-xsd-schema.xsl
asserts:
- /program[not(errors)]
- //java[contains(text(), 'new PhLocated(ret, "scenario", 3, 2, "Φ.foo.φ")')]
- //java[contains(text(), 'new PhLocated(ret_base, "scenario", 6, 4, "Φ.foo.other.φ.ρ")')]
- //java[contains(text(), 'new PhLocated(ret, "scenario", 6, 6, "Φ.foo.other.φ")')]
- //java[contains(text(), 'new PhLocated(ret_1, "scenario", 6, 12, "Φ.foo.other.φ.α0")')]
- //java[contains(text(), 'new PhLocated(ret_base, "scenario", 10, 2, "Φ.bar.φ.ρ")')]
- //java[contains(text(), 'new PhLocated(ret, "scenario", 10, 4, "Φ.bar.φ")')]
- //java[contains(text(), 'new PhLocated(ret_1, "scenario", 10, 10, "Φ.bar.φ.α0")')]
- //java[contains(text(), 'new PhLocated(ret, "scenario", 11, 2, "Φ.bar.five")')]
- //java[contains(text(), 'new PhSafe(ret, "scenario", 3, 2, "Φ.foo.φ")')]
- //java[contains(text(), 'new PhSafe(ret_base, "scenario", 6, 4, "Φ.foo.other.φ.ρ")')]
- //java[contains(text(), 'new PhSafe(ret, "scenario", 6, 6, "Φ.foo.other.φ")')]
- //java[contains(text(), 'new PhSafe(ret_1, "scenario", 6, 12, "Φ.foo.other.φ.α0")')]
- //java[contains(text(), 'new PhSafe(ret_base, "scenario", 10, 2, "Φ.bar.φ.ρ")')]
- //java[contains(text(), 'new PhSafe(ret, "scenario", 10, 4, "Φ.bar.φ")')]
- //java[contains(text(), 'new PhSafe(ret_1, "scenario", 10, 10, "Φ.bar.φ.α0")')]
- //java[contains(text(), 'new PhSafe(ret, "scenario", 11, 2, "Φ.bar.five")')]
input: |
# No comments.
[] > foo
Expand Down
6 changes: 4 additions & 2 deletions eo-runtime/src/main/java/EOorg/EOeolang/EObytes$EOslice.java
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,11 @@ public Phi lambda() {
.must(integer -> integer >= 0)
.otherwise("must be a positive integer")
.it();
final byte[] array = new Dataized(this.take(Attr.RHO)).take();
return new Data.ToPhi(
Arrays.copyOfRange(array, start, start + length)
Arrays.copyOfRange(
new Dataized(this.take(Attr.RHO)).take(),
start, start + length
)
);
}
}
18 changes: 18 additions & 0 deletions eo-runtime/src/main/java/EOorg/EOeolang/EOerror.java
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,15 @@ public ExError(final Phi enclosure) {
this(enclosure, Collections.emptyList());
}

/**
* Ctor.
* @param cause Previous error
* @param message New message
*/
public ExError(final Phi cause, final String message) {
this(cause, Collections.singletonList(message));
}

/**
* Ctor.
* @param cause Previous error
Expand All @@ -119,6 +128,15 @@ public ExError(final Phi enclosure, final Collection<String> before) {
this.trace = before;
}

@Override
public String toString() {
return String.format(
"%s +%s",
super.toString(),
this.trace.size()
);
}

/**
* Take it.
* @return The enclosed object
Expand Down
9 changes: 4 additions & 5 deletions eo-runtime/src/main/java/EOorg/EOeolang/EOtry.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
import org.eolang.Data;
import org.eolang.Dataized;
import org.eolang.PhDefault;
import org.eolang.PhSafe;
import org.eolang.Phi;
import org.eolang.XmirObject;

Expand All @@ -59,11 +58,11 @@ public EOtry() {
public Phi lambda() {
byte[] result;
try {
result = new Dataized(new PhSafe(this.take("main"))).take();
result = new Dataized(this.take("main")).take();
} catch (final EOerror.ExError ex) {
final Phi caught = this.take("catch").copy();
caught.put(0, ex.enclosure());
result = new Dataized(caught).take();
final Phi catcher = this.take("catch").copy();
catcher.put(0, ex.enclosure());
result = new Dataized(catcher).take();
} finally {
new Dataized(this.take("finally")).take();
}
Expand Down
4 changes: 2 additions & 2 deletions eo-runtime/src/main/java/org/eolang/Expect.java
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ public Expect<T> otherwise(final String message) {
return this.sup.get();
} catch (final ExFailure ex) {
throw new ExFailure(
String.format("%s %s", this.subject, message),
String.format("%s %s %s", this.subject, ex.getMessage(), message),
ex
);
}
Expand All @@ -118,7 +118,7 @@ public Expect<T> must(final Function<T, Boolean> fun) {
final T ret = this.sup.get();
if (!fun.apply(ret)) {
throw new ExFailure(
String.format("%s (%s)", this.subject, ret)
String.format("(%s)", ret)
);
}
return ret;
Expand Down
216 changes: 0 additions & 216 deletions eo-runtime/src/main/java/org/eolang/PhLocated.java

This file was deleted.

Loading

0 comments on commit 55637d4

Please sign in to comment.