Skip to content

Commit

Permalink
Merge branch 'master' of github.com:objectionary/eo
Browse files Browse the repository at this point in the history
  • Loading branch information
yegor256 committed May 8, 2024
2 parents 676f7ae + 423270c commit 8e3997b
Show file tree
Hide file tree
Showing 5 changed files with 241 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,10 @@ SOFTWARE.
<rusts>
<xsl:comment>"Rust inserts"</xsl:comment>
<xsl:for-each select="//o">
<xsl:if test="../attribute(base) = '.rust' and attribute(base) = 'org.eolang.string'">
<xsl:if test="(../attribute(base) = 'org.eolang.rust' or (../attribute(base) = '.rust' and ../o[1]/attribute(base) = '.eolang' and ../o[1]/o[1]/attribute(base) = '.org' and ../o[1]/o[1]/o[1]/attribute(base) = 'Q')) and (attribute(base) = 'org.eolang.string' or (attribute(base) = '.string' and o[1]/attribute(base) = '.eolang' and o[1]/o[1]/attribute(base) = '.org' and o[1]/o[1]/o[1]/attribute(base) = 'Q'))">
<rust>
<xsl:attribute name="code">
<xsl:value-of select="./o/text()"/>
<xsl:value-of select="./o[@data = 'bytes']/text()"/>
</xsl:attribute>
<xsl:attribute name="code_loc">
<xsl:value-of select="attribute(loc)"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ void binarizesTwiceRustProgram(@TempDir final Path temp) throws Exception {
@ClasspathSource(value = "org/eolang/maven/binarize/add_rust/", glob = "**.yaml")
void createsDependenciesSection(final String yaml) {
MatcherAssert.assertThat(
BinarizeParseTest.TO_ADD_MESSAGE,
"Yaml tests should pass",
new XaxStory(yaml),
Matchers.is(true)
);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,166 @@
# The MIT License (MIT)
#
# Copyright (c) 2016-2024 Objectionary.com
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included
# in all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
---
sheets:
- /org/eolang/maven/add_rust/add_rust.xsl
document:
<!--Check the case if string has base ".string" instead of "org.eolang.string"-->
<program>
<objects>
<o abstract=""
line="29"
loc="Φ.org.eolang.rust-with-string-fqn"
name="rust-with-string-fqn"
original-name="rust-with-string-fqn"
pos="0">
<o base=".rust"
line="33"
loc="Φ.org.eolang.rust-with-string-fqn.r"
name="r"
pos="2">
<o base=".eolang"
line="32"
loc="Φ.org.eolang.rust-with-string-fqn.r.ρ"
pos="2">
<o base=".org"
line="31"
loc="Φ.org.eolang.rust-with-string-fqn.r.ρ.ρ"
pos="2">
<o base="Q"
line="30"
loc="Φ.org.eolang.rust-with-string-fqn.r.ρ.ρ.ρ"
pos="2"/>
</o>
</o>
<o as="0"
base=".string"
line="37"
loc="Φ.org.eolang.rust-with-string-fqn.r.α0"
pos="4">
<o base=".eolang"
line="36"
loc="Φ.org.eolang.rust-with-string-fqn.r.α0.ρ"
pos="4">
<o base=".org"
line="35"
loc="Φ.org.eolang.rust-with-string-fqn.r.α0.ρ.ρ"
pos="4">
<o base="Q"
line="34"
loc="Φ.org.eolang.rust-with-string-fqn.r.α0.ρ.ρ.ρ"
pos="4"/>
</o>
</o>
<o as="0"
base="org.eolang.bytes"
data="bytes"
line="41"
loc="Φ.org.eolang.rust-with-string-fqn.r.α0.α0"
pos="6">75 73 65 20 65 6F 3A 3A 50 6F 72 74 61 6C 3B 0A 75 73 65 20 65 6F 3A 3A 65 6F 5F 65 6E 75 6D 3A 3A 45 4F 3B 0A 75 73 65 20 65 6F 3A 3A 65 6F 5F 65 6E 75 6D 3A 3A 45 4F 3A 3A 7B 45 4F 49 6E 74 7D 3B 0A 0A 70 75 62 20 66 6E 20 66 6F 6F 28 5F 70 6F 72 74 61 6C 3A 20 26 6D 75 74 20 50 6F 72 74 61 6C 29 20 2D 3E 20 4F 70 74 69 6F 6E 3C 45 4F 3E 20 7B 0A 20 20 70 72 69 6E 74 6C 6E 21 28 22 48 65 6C 6C 6F 20 77 6F 72 6C 64 20 66 72 6F 6D 20 72 75 73 74 22 29 3B 0A 20 20 53 6F 6D 65 28 45 4F 49 6E 74 28 32 29 29 0A 7D</o>
</o>
<o as="1"
base="rust-with-string-fqn$t0$a2"
cut="8"
line="43"
loc="Φ.org.eolang.rust-with-string-fqn.r.α1"
pos="4"
ref="43"/>
<o as="2"
base=".empty"
line="48"
loc="Φ.org.eolang.rust-with-string-fqn.r.α2"
pos="4">
<o base=".tuple"
line="47"
loc="Φ.org.eolang.rust-with-string-fqn.r.α2.ρ"
pos="4">
<o base=".eolang"
line="46"
loc="Φ.org.eolang.rust-with-string-fqn.r.α2.ρ.ρ"
pos="4">
<o base=".org"
line="45"
loc="Φ.org.eolang.rust-with-string-fqn.r.α2.ρ.ρ.ρ"
pos="4">
<o base="Q"
line="44"
loc="Φ.org.eolang.rust-with-string-fqn.r.α2.ρ.ρ.ρ.ρ"
pos="4"/>
</o>
</o>
</o>
</o>
</o>
<o base=".eq"
line="51"
loc="Φ.org.eolang.rust-with-string-fqn.φ"
name="@"
pos="2">
<o base=".r"
line="50"
loc="Φ.org.eolang.rust-with-string-fqn.φ.ρ"
pos="2">
<o base="$"
line="49"
loc="Φ.org.eolang.rust-with-string-fqn.φ.ρ.ρ"
pos="2"/>
</o>
<o as="0"
base=".int"
line="55"
loc="Φ.org.eolang.rust-with-string-fqn.φ.α0"
pos="4">
<o base=".eolang"
line="54"
loc="Φ.org.eolang.rust-with-string-fqn.φ.α0.ρ"
pos="4">
<o base=".org"
line="53"
loc="Φ.org.eolang.rust-with-string-fqn.φ.α0.ρ.ρ"
pos="4">
<o base="Q"
line="52"
loc="Φ.org.eolang.rust-with-string-fqn.φ.α0.ρ.ρ.ρ"
pos="4"/>
</o>
</o>
<o as="0"
base="org.eolang.bytes"
data="bytes"
line="59"
loc="Φ.org.eolang.rust-with-string-fqn.φ.α0.α0"
pos="6">00 00 00 00 00 00 00 02</o>
</o>
</o>
</o>
<o abstract=""
ancestors="1"
as="1"
line="43"
loc="Φ.org.eolang.rust-with-string-fqn$t0$a2"
name="rust-with-string-fqn$t0$a2"
parent="rust-with-string-fqn"
pos="4"/>
</objects>
</program>
asserts:
- /program/rusts/rust[@code_loc='Φ.org.eolang.rust-with-string-fqn.r.α0' and @code='75 73 65 20 65 6F 3A 3A 50 6F 72 74 61 6C 3B 0A 75 73 65 20 65 6F 3A 3A 65 6F 5F 65 6E 75 6D 3A 3A 45 4F 3B 0A 75 73 65 20 65 6F 3A 3A 65 6F 5F 65 6E 75 6D 3A 3A 45 4F 3A 3A 7B 45 4F 49 6E 74 7D 3B 0A 0A 70 75 62 20 66 6E 20 66 6F 6F 28 5F 70 6F 72 74 61 6C 3A 20 26 6D 75 74 20 50 6F 72 74 61 6C 29 20 2D 3E 20 4F 70 74 69 6F 6E 3C 45 4F 3E 20 7B 0A 20 20 70 72 69 6E 74 6C 6E 21 28 22 48 65 6C 6C 6F 20 77 6F 72 6C 64 20 66 72 6F 6D 20 72 75 73 74 22 29 3B 0A 20 20 53 6F 6D 65 28 45 4F 49 6E 74 28 32 29 29 0A 7D']
7 changes: 4 additions & 3 deletions eo-runtime/src/main/java/EOorg/EOeolang/EOrust.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
import java.util.Base64;
import java.util.HashMap;
import java.util.Map;
import java.util.Optional;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.atomic.AtomicReference;
import org.eolang.AtVoid;
Expand Down Expand Up @@ -139,9 +140,9 @@ public EOrust(final Phi sigma) {

@Override
public Phi lambda() throws Exception {
final String name = NAMES.get(
this.take("code").locator().split(":")[0]
);
final String locator = this.take("code").locator().split(":")[0];
final String name = Optional.ofNullable(NAMES.get(locator))
.orElseThrow(() -> new ExNative("No native function for %s", locator));
final Method method = Class.forName(
String.format(
"EOrust.natives.%s",
Expand Down
68 changes: 68 additions & 0 deletions eo-runtime/src/test/eo/org/eolang/rust-tests.eo
Original file line number Diff line number Diff line change
Expand Up @@ -391,3 +391,71 @@
eq. > @
applied.content
"qwerty"

# This is the default 64+ symbols comment in front of named abstract object.
[] > rust-with-string-fqn
Q
.org
.eolang
.rust > r
Q
.org
.eolang
.string:0
Q
.org
.eolang
.bytes:0
75-73-65-20-65-6F-3A-3A-50-6F-72-74-61-6C-3B-0A-75-73-65-20-65-6F-3A-3A-65-6F-5F-65-6E-75-6D-3A-3A-45-4F-3B-0A-75-73-65-20-65-6F-3A-3A-65-6F-5F-65-6E-75-6D-3A-3A-45-4F-3A-3A-7B-45-4F-49-6E-74-7D-3B-0A-0A-70-75-62-20-66-6E-20-66-6F-6F-28-5F-70-6F-72-74-61-6C-3A-20-26-6D-75-74-20-50-6F-72-74-61-6C-29-20-2D-3E-20-4F-70-74-69-6F-6E-3C-45-4F-3E-20-7B-0A-20-20-70-72-69-6E-74-6C-6E-21-28-22-48-65-6C-6C-6F-20-77-6F-72-6C-64-20-66-72-6F-6D-20-72-75-73-74-22-29-3B-0A-20-20-53-6F-6D-65-28-45-4F-49-6E-74-28-32-29-29-0A-7D
[]:1
Q
.org
.eolang
.tuple
.empty:2
$
.r
.eq > @
Q
.org
.eolang
.int:0
Q
.org
.eolang
.bytes:0
00-00-00-00-00-00-00-02

# This is the default 64+ symbols comment in front of named abstract object.
[] > rust-reversed-notation
rust. > r
eolang.
org.
Q
string.:0
eolang.
org.
Q
bytes.:0
eolang.
org.
Q
75-73-65-20-65-6F-3A-3A-50-6F-72-74-61-6C-3B-0A-75-73-65-20-65-6F-3A-3A-65-6F-5F-65-6E-75-6D-3A-3A-45-4F-3B-0A-75-73-65-20-65-6F-3A-3A-65-6F-5F-65-6E-75-6D-3A-3A-45-4F-3A-3A-7B-45-4F-49-6E-74-7D-3B-0A-0A-70-75-62-20-66-6E-20-66-6F-6F-28-5F-70-6F-72-74-61-6C-3A-20-26-6D-75-74-20-50-6F-72-74-61-6C-29-20-2D-3E-20-4F-70-74-69-6F-6E-3C-45-4F-3E-20-7B-0A-20-20-70-72-69-6E-74-6C-6E-21-28-22-48-65-6C-6C-6F-20-77-6F-72-6C-64-20-66-72-6F-6D-20-72-75-73-74-22-29-3B-0A-20-20-53-6F-6D-65-28-45-4F-49-6E-74-28-32-29-29-0A-7D
[]:1
empty.:2
tuple.
eolang.
org.
Q
eq. > @
r.
$
int.:0
eolang.
org.
Q
bytes.:0
eolang.
org.
Q
00-00-00-00-00-00-00-02

0 comments on commit 8e3997b

Please sign in to comment.