Skip to content

Commit

Permalink
feat(objectionary#976): ugly solution for hex convertation
Browse files Browse the repository at this point in the history
  • Loading branch information
volodya-lombrozo committed Jan 22, 2025
1 parent fde473c commit 3516b8f
Showing 1 changed file with 20 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -303,9 +303,9 @@ Stream<String> checks(final String root) {
Stream.of(
instruction.concat("/@base"),
String.format(
"%s/o[contains(@base,'int')]/o[@base='org.eolang.bytes' and text()='%s']/@base",
"%s/o[contains(@base,'int')]/o[contains(@base,'number')]/o[contains(@base,'bytes') and text()='%s']/@base",
instruction,
new DirectivesValue(this.opcode).hex()
new DirectivesValue((double) this.opcode).hex()
)
),
this.arguments(instruction)
Expand All @@ -322,16 +322,30 @@ private Stream<String> arguments(final String instruction) {
.map(
arg -> {
final String result;
final DirectivesValue hex = new DirectivesValue(arg);
if (arg instanceof BytecodeLabel) {
if (arg instanceof Number) {
final DirectivesValue simple = new DirectivesValue(
arg
);
final DirectivesValue hex = new DirectivesValue(
((Number) arg).doubleValue()
);
result = String.format(
"%s/o[contains(@base,'%s')]/o[contains(@base,'number')]/o[contains(@base,'bytes') and text()='%s']/@base",
instruction,
simple.type(),
hex.hex()
);
} else if (arg instanceof BytecodeLabel) {
final DirectivesValue hex = new DirectivesValue(arg);
result = String.format(
"%s/o[contains(@base,'%s')]/o[@base='org.eolang.bytes']/@base",
"%s/o[contains(@base,'%s')]/o[contains(@base,'bytes')]/@base",
instruction,
hex.type()
);
} else {
final DirectivesValue hex = new DirectivesValue(arg);
result = String.format(
"%s/o[contains(@base,'%s')]/o[@base='org.eolang.bytes' and text()='%s']/@base",
"%s/o[contains(@base,'%s')]/o[contains(@base,'bytes') and text()='%s']/@base",
instruction,
hex.type(),
hex.hex()
Expand Down

0 comments on commit 3516b8f

Please sign in to comment.