objectionary / jeo-maven-plugin

This Maven plugin converts Java Bytecode binary files to EOLANG programs that use the "opcode" atom
https://www.objectionary.com/jeo-maven-plugin/
MIT License
11 stars 3 forks source link

it's better to use different atoms for different opcodes #917

Open yegor256 opened 3 hours ago

yegor256 commented 3 hours ago

Currently, jeo:disassemble generates this phi (via XMIR):

φ ↦ Φ.jeo.seq.of6(
  α0 ↦ ξ.getstatic-25D7,
  α1 ↦ ξ.invokestatic-25E3,
  α2 ↦ ξ.invokedynamic-2600,
  α3 ↦ ξ.invokeinterface-2622,
  α4 ↦ ξ.invokeinterface-2627,
  α5 ↦ ξ.lreturn-2629
),

invokestatic-25E3 ↦ Φ.jeo.opcode( ... )

invokedynamic-2600 ↦ Φ.jeo.opcode( ... )

It's rather inconvenient for further processing. Instead, this would be better:

φ ↦ Φ.jeo.seq.of6(
  α0 ↦ ξ.a25D7,
  α1 ↦ ξ.a25E3,
  α2 ↦ ξ.a2600,
  α3 ↦ ξ.a2622,
  α4 ↦ ξ.a2627,
  α5 ↦ ξ.a2629
),

a25E3 ↦ Φ.jeo.opcode.invokestatic( ... )

a2600 ↦ Φ.jeo.opcode.invokedynamic( ... )

Possible?

yegor256 commented 3 hours ago

@volodya-lombrozo please, check

yegor256 commented 2 hours ago

@volodya-lombrozo actually, the name of the attribute (getstatic-25D7) doesn't matter at all, it may stay as is. What matters is the name of the atom/object being used (jeo.opcode.invokestatic).

volodya-lombrozo commented 1 hour ago

@yegor256 I don't clearly understand these phi expressions and haven't found any documentation on it. Can you please explain what does this mean:

α0 ↦ ξ.a25D7 - is it an object with base=α0 and name=a25D7 or something else? What is the difference between Φ and ξ?

As for the issue itself, simply saying, do you want instead of:

<o base="jeo.opcode" name="invokespecial-188">
...
</o>

have something like:

<o base="jeo.opcode.invokespecial" name="a188">
...
</o>

?

yegor256 commented 1 hour ago

@volodya-lombrozo yes, exactly

volodya-lombrozo commented 1 hour ago

@yegor256 Instead of 1 atom, we will get 202 of them. It might complicate things significantly and increase coupling. Is it necessary? Moreover it will require significant changes in opec-maven-plugin if we decide to continue with it.

yegor256 commented 1 hour ago

@volodya-lombrozo 202 atoms is fine. Without this we technically can't write a rule for eo-phi-normalizer. We can't do this (assuming the * is a wildcard):

*-25E3 ↦ Φ.jeo.opcode( ... )

We can only do this:

* ↦ Φ.jeo.opcode.invokestatic( ... )
volodya-lombrozo commented 1 hour ago

@yegor256 Well, ok, I will do it then.