-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
74 changed files
with
3,576 additions
and
320 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
.idea | ||
target | ||
target-failed | ||
target-failed* | ||
target-standard* | ||
!src/it/decompile-compile/target |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
invoker.goals=clean test -e | ||
invoker.profiles=disassemble,decompile,ineo,compile,assemble | ||
invoker.profiles=disassemble,decompile,ineo,phi,compile,assemble |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
/* | ||
* The MIT License (MIT) | ||
* | ||
* Copyright (c) 2016-2023 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. | ||
*/ | ||
package org.eolang.opeo.ast; | ||
|
||
import java.util.Collections; | ||
import java.util.List; | ||
import org.eolang.jeo.representation.DataType; | ||
import org.eolang.jeo.representation.directives.DirectivesData; | ||
import org.eolang.jeo.representation.xmir.XmlNode; | ||
import org.objectweb.asm.Opcodes; | ||
import org.objectweb.asm.Type; | ||
import org.xembly.Directive; | ||
import org.xembly.Directives; | ||
|
||
/** | ||
* Constant. | ||
* This class represents LDC instruction in the JVM bytecode. | ||
* @since 0.2 | ||
* @todo #229:90min Do we need {@link Constant} class? | ||
* It seems that this class is rather similar to {@link Literal} class. | ||
* We need to investigate if we can remove this class and use {@link Literal} instead. | ||
* If we can't remove this class, we need to add more tests to cover all the cases | ||
* where {@link Constant} is used. | ||
*/ | ||
public final class Constant implements AstNode, Typed { | ||
|
||
/** | ||
* The constant value. | ||
*/ | ||
private final Object value; | ||
|
||
/** | ||
* Constructor. | ||
* @param node The XMIR node with value to parse. | ||
*/ | ||
public Constant(final XmlNode node) { | ||
this(Constant.parse(node)); | ||
} | ||
|
||
/** | ||
* Constructor. | ||
* @param value The constant value. | ||
*/ | ||
public Constant(final Object value) { | ||
this.value = value; | ||
} | ||
|
||
@Override | ||
public List<AstNode> opcodes() { | ||
return Collections.singletonList(new Opcode(Opcodes.LDC, this.value)); | ||
} | ||
|
||
@Override | ||
public Iterable<Directive> toXmir() { | ||
return new Directives().add("o") | ||
.attr("base", "load-constant") | ||
.append(new DirectivesData(this.value)) | ||
.up(); | ||
} | ||
|
||
@Override | ||
public Type type() { | ||
final Type result; | ||
if (this.value instanceof Type) { | ||
result = (Type) this.value; | ||
} else { | ||
result = Type.getType(this.value.getClass()); | ||
} | ||
return result; | ||
} | ||
|
||
/** | ||
* Parse the Constant value from XMIR representation. | ||
* @param node The node to parse. | ||
* @return The parsed value. | ||
*/ | ||
private static Object parse(final XmlNode node) { | ||
final XmlNode child = node.firstChild(); | ||
return DataType.find(child.attribute("base").orElseThrow()) | ||
.decode(child.text()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
944c2a6
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Puzzle
229-b419f9db
discovered inpom.xml
) and submitted as #274. Please, remember that the puzzle was not necessarily added in this particular commit. Maybe it was added earlier, but we discovered it only now.944c2a6
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Puzzle
229-f7413085
discovered insrc/main/java/org/eolang/opeo/ast/Constant.java
) and submitted as #275. Please, remember that the puzzle was not necessarily added in this particular commit. Maybe it was added earlier, but we discovered it only now.944c2a6
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Puzzle
229-1fb106a9
discovered insrc/main/java/org/eolang/opeo/ast/ConstructorDescriptor.java
) and submitted as #276. Please, remember that the puzzle was not necessarily added in this particular commit. Maybe it was added earlier, but we discovered it only now.944c2a6
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Puzzle
229-7fc7abda
discovered insrc/main/java/org/eolang/opeo/ast/Duplicate.java
) and submitted as #277. Please, remember that the puzzle was not necessarily added in this particular commit. Maybe it was added earlier, but we discovered it only now.944c2a6
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Puzzle
229-4ff35b41
discovered insrc/main/java/org/eolang/opeo/ast/Invocation.java
) and submitted as #278. Please, remember that the puzzle was not necessarily added in this particular commit. Maybe it was added earlier, but we discovered it only now.944c2a6
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Puzzle
229-cd34d827
discovered insrc/main/java/org/eolang/opeo/ast/Popped.java
) and submitted as #279. Please, remember that the puzzle was not necessarily added in this particular commit. Maybe it was added earlier, but we discovered it only now.944c2a6
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Puzzle
229-a73992aa
discovered insrc/main/java/org/eolang/opeo/compilation/JeoCompiler.java
) and submitted as #280. Please, remember that the puzzle was not necessarily added in this particular commit. Maybe it was added earlier, but we discovered it only now.944c2a6
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Puzzle
229-e1115bff
discovered insrc/main/java/org/eolang/opeo/compilation/JeoCompiler.java
) and submitted as #281. Please, remember that the puzzle was not necessarily added in this particular commit. Maybe it was added earlier, but we discovered it only now.944c2a6
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Puzzle
229-b768fbb7
discovered insrc/main/java/org/eolang/opeo/compilation/JeoCompiler.java
) and submitted as #282. Please, remember that the puzzle was not necessarily added in this particular commit. Maybe it was added earlier, but we discovered it only now.944c2a6
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Puzzle
229-5bb45fdb
discovered insrc/test/java/it/JeoAndOpeoTest.java
) and submitted as #283. Please, remember that the puzzle was not necessarily added in this particular commit. Maybe it was added earlier, but we discovered it only now.