Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Poc] Generate IR definitions - superclass approach #11770

Draft
wants to merge 138 commits into
base: develop
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
138 commits
Select commit Hold shift + click to select a range
6e33120
Add parser-dsl and parser-processor projects
Akirathan Oct 6, 2024
69f9247
Add JModule
Akirathan Oct 6, 2024
0e4ceb0
Fix module declaration - no compiler module dependency
Akirathan Oct 7, 2024
9891eb7
Add annotation processor testing.
Akirathan Oct 7, 2024
a3bf203
Rewrite some IR elements to IRNode annotated interfaces
Akirathan Oct 9, 2024
08b0571
IRProcessor does some sanity checks
Akirathan Oct 9, 2024
51796ba
IRNode does not have name parameter
Akirathan Oct 9, 2024
3ea7a90
IRProcessor generates source file for record
Akirathan Oct 9, 2024
f6bf733
Add imports and overriden IR methods to generated record
Akirathan Oct 10, 2024
1870ef2
Add field processing
Akirathan Oct 10, 2024
826245d
IRProcessor generates classes, not records
Akirathan Oct 14, 2024
fc89b3d
IRProcessor generates overrides for user-defined parameterless methods
Akirathan Oct 14, 2024
1fc0497
Add Field.isExpression method
Akirathan Oct 17, 2024
d2bb8c3
sbt picks up Scala case classes generated by Java annotation processor
Akirathan Oct 18, 2024
68a070b
IRProcessor generates Scala classes.
Akirathan Oct 18, 2024
cf08781
Revert "sbt picks up Scala case classes generated by Java annotation …
Akirathan Oct 21, 2024
f930e53
Revert "IRProcessor generates Scala classes."
Akirathan Oct 21, 2024
298c883
IRProcessor handles primitive fields
Akirathan Oct 21, 2024
bc1e9c9
Remove unused methods
Akirathan Oct 21, 2024
ef05c64
IRProcessor fails fast
Akirathan Oct 21, 2024
aa0a5b6
IRProcessor can collect fields from super interfaces
Akirathan Oct 21, 2024
c6def78
Fix collecting fields from super interfaces.
Akirathan Oct 22, 2024
8cea491
Prepare IRNodeProcessor for processing multiple nested interfaces
Akirathan Oct 22, 2024
f5cb331
IRNodeProcessor handles multiple nested interfaces
Akirathan Oct 22, 2024
2393e18
runtime-parser-processor does not depend on runtime-parser
Akirathan Oct 22, 2024
cf1d079
Move parser processor tests to a separate project
Akirathan Oct 22, 2024
f63bda1
runtime-parser-processor does not depend on runtime-parser
Akirathan Oct 22, 2024
158a4f1
runtime-parser depends on runtime-parser-processor
Akirathan Oct 22, 2024
1289374
IRProcessor adds package
Akirathan Oct 25, 2024
73a9d31
ParserDependenciesTest ensures that IRNodeProcessor is on class path
Akirathan Oct 25, 2024
be4396c
runtime-parser-processor module provides annotation processor service
Akirathan Oct 25, 2024
3665232
Fix getSimpleTypeName in ReferenceField
Akirathan Oct 25, 2024
260d11d
No nested @IRNode annotation
Akirathan Oct 25, 2024
df95a4e
JModule extends IR
Akirathan Oct 25, 2024
7918fd2
IRNodeProcessor handles parametrized List child
Akirathan Oct 25, 2024
9ae8e3f
runtime-parser-processor-tests runs with enabled assertions
Akirathan Oct 25, 2024
cf264cf
Test IRNode with List of children
Akirathan Oct 25, 2024
0f21885
All IR interfaces use scala list, not java.util.List
Akirathan Oct 25, 2024
18b2d10
Do not process already overriden methods
Akirathan Oct 25, 2024
26239a3
Enable IRProcessor in runtime-parser
Akirathan Oct 29, 2024
9c3a580
Ensure that only fields from current interface and its super interfac…
Akirathan Oct 29, 2024
c6b1987
Implement passData, location and diagnostics methods
Akirathan Oct 30, 2024
399ca43
Override duplicate method
Akirathan Oct 30, 2024
7a97c61
Fix duplicate method generation
Akirathan Oct 30, 2024
8acfa30
Move duplicate method generation to a separate class
Akirathan Oct 31, 2024
7988276
Duplicate method duplicates also non-child fields
Akirathan Oct 31, 2024
c84ebb7
Simplify tests
Akirathan Oct 31, 2024
8a778f0
During runtime-parser-processor-test compilation, IRNodeProcessor runs
Akirathan Oct 31, 2024
86d1b0e
docs
Akirathan Oct 31, 2024
8aa64bd
Add some IR interfaces to the testing code
Akirathan Oct 31, 2024
e91f09e
test generated list children
Akirathan Oct 31, 2024
dd34e5d
DuplicateMethodGenerator duplicates also meta fields
Akirathan Nov 1, 2024
2a2b6d3
Builder allows setting meta fields
Akirathan Nov 1, 2024
7def7b1
Add tests for duplicated metadata
Akirathan Nov 1, 2024
66aba89
Add runtime-parser-processor-tests to the enso aggregate
Akirathan Nov 1, 2024
f6b75ed
Add IRCopyMethod annotation
Akirathan Nov 1, 2024
9bccf1c
Iteration over super interfaces is handled only via SuperInterfaceVis…
Akirathan Nov 1, 2024
f027307
Simplify super interface iteration
Akirathan Nov 1, 2024
687d0e1
Builder has a copy constructor
Akirathan Nov 1, 2024
bd9b7e4
Implement CopyMethodGenerator
Akirathan Nov 1, 2024
98f4743
Fix all tests
Akirathan Nov 1, 2024
92d9004
Test copy method generation
Akirathan Nov 1, 2024
69728be
Do not try to override static or default methods
Akirathan Nov 1, 2024
7709597
docs
Akirathan Nov 1, 2024
7d012fe
Allow multiple copy methods
Akirathan Nov 4, 2024
cb06f03
CopyMethodGenerator generates copy method with correct order of param…
Akirathan Nov 4, 2024
c08c035
Test valid parameter names for copy method
Akirathan Nov 4, 2024
43ed045
More tests
Akirathan Nov 4, 2024
69258cf
Generate mapExpressions method
Akirathan Nov 5, 2024
f888cee
Add mock definition of JCallArgument
Akirathan Nov 5, 2024
57c5bff
Use qualified type names in mapExpressions method
Akirathan Nov 6, 2024
be2d374
Implement JBlank.create factory method
Akirathan Nov 6, 2024
b828603
JExpression overrides duplicate and mapExpressions
Akirathan Nov 6, 2024
814d031
Merge branch 'develop' into wip/akirathan/java-ir
Akirathan Dec 2, 2024
419dca0
Remove unused import
Akirathan Dec 2, 2024
c8cbc98
Move all the sample `JXyz` interfaces to tests
Akirathan Dec 2, 2024
fd6ad5b
Generate identifiedLocation method override
Akirathan Dec 2, 2024
e066374
Fix compilation after the move
Akirathan Dec 2, 2024
68389f4
Move sample `JXyz` interfaces to a dedicated test package
Akirathan Dec 2, 2024
1b7a120
Add sample definition of JEmpty
Akirathan Dec 2, 2024
aa345ed
Replace Scala Empty with Java Empty annotated with @IRNode
Akirathan Dec 2, 2024
fa26144
Refactor Utils.findMethod
Akirathan Dec 2, 2024
c4a669e
Fix test after merge of develop
Akirathan Dec 2, 2024
e4222f0
Fix TestIRProcessorInline after `J*` classes were moved to test dir
Akirathan Dec 2, 2024
4d5b214
Implement SetLocationMethodGenerator
Akirathan Dec 2, 2024
5ef1bde
fmt
Akirathan Dec 2, 2024
9b48ed4
Ensure only a single IR interface is extended
Akirathan Dec 2, 2024
5ac716a
Fix compilation after Refactoring Empty to an interface with @IRNode
Akirathan Dec 2, 2024
4a0ea14
Empty extends Expression
Akirathan Dec 2, 2024
9b5f1b2
Override equals and hashCode
Akirathan Dec 2, 2024
e294877
Explicitly list all the processor classes in javacOptions
Akirathan Dec 2, 2024
00ad5f6
Refactor field class to field package
Akirathan Dec 3, 2024
e6c7609
Refactor method generation classes to methodgen package
Akirathan Dec 3, 2024
c8b7e34
Introduce utils package
Akirathan Dec 3, 2024
fadf973
Add GenerateIR annotation
Akirathan Dec 4, 2024
b549bf7
Remove tests using the IRNode annotation
Akirathan Dec 4, 2024
f6f0e4d
Revert "Empty extends Expression"
Akirathan Dec 4, 2024
70deaca
Revert "Fix compilation after Refactoring Empty to an interface with …
Akirathan Dec 4, 2024
f02b645
Revert "Replace Scala Empty with Java Empty annotated with @IRNode"
Akirathan Dec 4, 2024
088b614
Remove all test interfaces using IRNode annotation
Akirathan Dec 4, 2024
3a3cc14
Remove TestGeneratedIR
Akirathan Dec 4, 2024
11d2a25
Update TestIRPRocessorInline.
Akirathan Dec 4, 2024
e6205f1
GenerateIR uses IR as the default interface
Akirathan Dec 4, 2024
ea17b2f
Skeleton of implementation
Akirathan Dec 5, 2024
d978592
Remove IRNode
Akirathan Dec 5, 2024
54d9c25
Better error msg in FieldCollector
Akirathan Dec 5, 2024
7507065
Add import in test
Akirathan Dec 5, 2024
e026c77
Ensure GenerateIR.interfaces is subtype of IR
Akirathan Dec 5, 2024
f66ded2
Add import in test
Akirathan Dec 5, 2024
363a838
Fix generic type introspection from VariableElement
Akirathan Dec 5, 2024
b8f6b8f
Fix imports in rest of the tests.
Akirathan Dec 5, 2024
a42d236
Generated constructor is protected
Akirathan Dec 5, 2024
6587692
Generate second constructor - with user fields
Akirathan Dec 5, 2024
3ea1bb3
style - add new line
Akirathan Dec 5, 2024
d61eca7
Add docs to the generated ctors.
Akirathan Dec 5, 2024
0ea630d
Add sample JExpression to tests
Akirathan Dec 5, 2024
006406f
fmt
Akirathan Dec 5, 2024
4973bb8
Add java docs to the generated class
Akirathan Dec 5, 2024
00cae90
Remove unused IRCopyMethod
Akirathan Dec 10, 2024
3cb8424
Replace scala Empty with generated IR
Akirathan Dec 10, 2024
371071b
Support scala.Option field
Akirathan Dec 10, 2024
a94a954
Add nl
Akirathan Dec 10, 2024
4368bd1
Add JCallArgument to tests
Akirathan Dec 11, 2024
6222615
Merge branch 'develop' into wip/akirathan/java-ir-superclass
Akirathan Dec 23, 2024
8f699f9
Test that annotated constructor can have meta parameter
Akirathan Dec 23, 2024
51420df
Constructor parameters must be annotated
Akirathan Dec 23, 2024
db713a7
Constructor parameters can be meta type
Akirathan Dec 23, 2024
f33af6e
Generated super class is abstract
Akirathan Dec 24, 2024
30f14d9
Annotated class must extend the generated super class
Akirathan Dec 24, 2024
ba602c4
Fix tests - annotated class must extend the generated super class
Akirathan Dec 24, 2024
9bae261
Use specific IRProcessingException.
Akirathan Dec 24, 2024
1b069ed
setLocation returns subclass type
Akirathan Dec 24, 2024
b3e262b
Reorder generated fields in JCallArgument
Akirathan Dec 24, 2024
1a87899
mapExpressions returns subclass type
Akirathan Dec 24, 2024
e7dc725
Add scala tests to runtime-parser-processor-tests
Akirathan Dec 24, 2024
0a1f5a8
[WIP] Demonstrate implementation of unapply
Akirathan Dec 24, 2024
83fe023
Revert "[WIP] Demonstrate implementation of unapply"
Akirathan Dec 27, 2024
c6d66c3
Merge branch 'develop' into wip/akirathan/java-ir-superclass
Akirathan Dec 27, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
64 changes: 63 additions & 1 deletion build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -353,6 +353,9 @@ lazy val enso = (project in file("."))
`runtime-compiler`,
`runtime-integration-tests`,
`runtime-parser`,
`runtime-parser-dsl`,
`runtime-parser-processor`,
`runtime-parser-processor-tests`,
`runtime-language-arrow`,
`runtime-language-epb`,
`runtime-instrument-common`,
Expand Down Expand Up @@ -3218,14 +3221,73 @@ lazy val `runtime-parser` =
Compile / moduleDependencies ++= Seq(
"org.netbeans.api" % "org-openide-util-lookup" % netbeansApiVersion
),
// Java compiler is not able to correctly find all the annotation processor, because
// one of the is on module-path. To overcome this, we explicitly list all of them here.
Compile / javacOptions ++= {
val processorClasses = Seq(
"org.enso.runtime.parser.processor.IRProcessor",
"org.enso.persist.impl.PersistableProcessor",
"org.netbeans.modules.openide.util.ServiceProviderProcessor",
"org.netbeans.modules.openide.util.NamedServiceProcessor"
).mkString(",")
Seq(
"-processor",
processorClasses
)
},
Compile / internalModuleDependencies := Seq(
(`syntax-rust-definition` / Compile / exportedModule).value,
(`persistance` / Compile / exportedModule).value
(`persistance` / Compile / exportedModule).value,
(`runtime-parser-dsl` / Compile / exportedModule).value,
(`runtime-parser-processor` / Compile / exportedModule).value
)
)
.dependsOn(`syntax-rust-definition`)
.dependsOn(`persistance`)
.dependsOn(`persistance-dsl` % "provided")
.dependsOn(`runtime-parser-dsl`)
.dependsOn(`runtime-parser-processor`)

lazy val `runtime-parser-dsl` =
(project in file("engine/runtime-parser-dsl"))
.enablePlugins(JPMSPlugin)
.settings(
frgaalJavaCompilerSetting
)

lazy val `runtime-parser-processor-tests` =
(project in file("engine/runtime-parser-processor-tests"))
.settings(
inConfig(Compile)(truffleRunOptionsSettings),
frgaalJavaCompilerSetting,
commands += WithDebugCommand.withDebug,
annotationProcSetting,
Compile / javacOptions ++= Seq(
"-processor",
"org.enso.runtime.parser.processor.IRProcessor"
),
Test / fork := true,
libraryDependencies ++= Seq(
"junit" % "junit" % junitVersion % Test,
"com.github.sbt" % "junit-interface" % junitIfVersion % Test,
"org.hamcrest" % "hamcrest-all" % hamcrestVersion % Test,
"com.google.testing.compile" % "compile-testing" % "0.21.0" % Test,
"org.scalatest" %% "scalatest" % scalatestVersion % Test
)
)
.dependsOn(`runtime-parser-processor`)
.dependsOn(`runtime-parser`)

lazy val `runtime-parser-processor` =
(project in file("engine/runtime-parser-processor"))
.enablePlugins(JPMSPlugin)
.settings(
frgaalJavaCompilerSetting,
Compile / internalModuleDependencies := Seq(
(`runtime-parser-dsl` / Compile / exportedModule).value
)
)
.dependsOn(`runtime-parser-dsl`)

lazy val `runtime-compiler` =
(project in file("engine/runtime-compiler"))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ case object LambdaConsolidate extends IRPass {
}

val shadower: IR =
mShadower.getOrElse(Empty(spec.identifiedLocation))
mShadower.getOrElse(new Empty(spec.identifiedLocation))

spec.getDiagnostics.add(
warnings.Shadowed
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@ case object SuspendedArguments extends IRPass {
} else if (args.length > signatureSegments.length) {
val additionalSegments = signatureSegments ::: List.fill(
args.length - signatureSegments.length
)(Empty(identifiedLocation = null))
)(new Empty(null))

args.zip(additionalSegments)
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class DiagnosticStorageTest extends CompilerTest {
def mkDiagnostic(name: String): Diagnostic = {
warnings.Shadowed.FunctionParam(
name,
Empty(identifiedLocation = null),
new Empty(null),
identifiedLocation = null
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,9 @@ class OperatorToFunctionTest extends MiniPassTest {
// === The Tests ============================================================
val opName =
Name.Literal("=:=", isMethod = true, null)
val left = Empty(null)
val right = Empty(null)
val rightArg = new CallArgument.Specified(None, Empty(null), false, null)
val left = new Empty(null)
val right = new Empty(null)
val rightArg = new CallArgument.Specified(None, new Empty(null), false, null)

val (operator, operatorFn) = genOprAndFn(opName, left, right)

Expand All @@ -96,11 +96,11 @@ class OperatorToFunctionTest extends MiniPassTest {
"Operators" should {
val opName =
Name.Literal("=:=", isMethod = true, identifiedLocation = null)
val left = Empty(identifiedLocation = null)
val right = Empty(identifiedLocation = null)
val left = new Empty(null)
val right = new Empty(null)
val rightArg = new CallArgument.Specified(
None,
Empty(identifiedLocation = null),
new Empty(null),
false,
identifiedLocation = null
)
Expand Down
3 changes: 3 additions & 0 deletions engine/runtime-parser-dsl/src/main/java/module-info.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module org.enso.runtime.parser.dsl {
exports org.enso.runtime.parser.dsl;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
package org.enso.runtime.parser.dsl;

import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

/**
* Parameters of the constructor annotated with this annotation will be scanned by the IR processor
* and <b>fields</b>will be generated for them. There can be only a single constructor with this
* annotation in a class. The enclosing class must be annotated with {@link GenerateIR}.
*
* <h2>Fields</h2>
*
* The generated class will contain 4 <b>meta</b> fields that are required to be present inside
* every IR element:
*
* <ul>
* <li>{@code private DiagnosticStorage diagnostics}
* <li>{@code private MetadataStorage passData}
* <li>{@code private IdentifiedLocation location}
* <li>{@code private UUID id}
* </ul>
*
* Apart from these <b>meta</b> fields, the generated class will also contain <b>user-defined</b>
* fields. User-defined fields are inferred from all the parameters of the constructor annotated
* with {@link GenerateFields}. The parameter of the constructor can be one of the following:
*
* <ul>
* <li>Any reference, or primitive type annotated with {@link IRField}
* <li>A subtype of {@code org.enso.compiler.ir.IR} annotated with {@link IRChild}
* <li>One of the <emph>meta</emph> types mentioned above
* </ul>
*
* <p>A user-defined field generated out of constructor parameter annotated with {@link IRChild} is
* a child element of this IR element. That means that it will be included in generated
* implementation of IR methods that iterate over the IR tree. For example {@code mapExpressions} or
* {@code children}.
*
* <p>A user-defined field generated out of constructor parameter annotated with {@link IRField}
* will be a field with generated getters. Such field however, will not be part of the IR tree
* traversal methods.
*
* <p>For a constructor parameter of a meta type, there will be no user-defined field generated, as
* the meta fields are always generated.
*
* <p>Other types of constructor parameters are forbidden.
*/
@Retention(RetentionPolicy.SOURCE)
@Target(ElementType.CONSTRUCTOR)
public @interface GenerateFields {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package org.enso.runtime.parser.dsl;

import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

/**
* A class annotated with this annotation will be processed by the IR processor. The processor will
* generate a super class that is meant to be extended by this class. The generated class will have
* the same package as this class, and its name will have the "Gen" suffix. Majority of the methods
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is possible to extract the name of the super class from class X extends MyParent definition. E.g. then the name of the super class could be arbitrary. It would have to be in the same package, but there would be no restriction on the Gen suffix.

* in the generated class will be either private or package-private, so that they are not accessible
* from the outside.
*
* <p>The class can be enclosed (nested inside) an interface.
*
* <p>The class must contain a single constructor annotated with {@link GenerateFields}.
*/
@Retention(RetentionPolicy.SOURCE)
@Target(ElementType.TYPE)
public @interface GenerateIR {

/**
* Name of the interfaces that the generated superclass must implement. All the interfaces must be
* subtypes of the {@code org.enso.compiler.ir.IR} interface. All the abstract parameterless
* methods from all the interfaces will be implemented by the generated class. Must not be empty.
*
* @return
*/
String interfaces() default "org.enso.compiler.core.IR";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess this is not used yet. I see plural being used here. In such case the value should be [] array. I would also suggest to use Class[] that way one prevents typos as the referenced classes must exist. Btw. looking at Block I see it implements IRKind.Primitive - that interface isn't subtype of IR...

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package org.enso.runtime.parser.dsl;

import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

/**
* Constructor parameter annotated with this annotation will be represented as a child field in the
* generated super class. Children of IR elements for a tree. A child will be part of the methods
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* generated super class. Children of IR elements for a tree. A child will be part of the methods
* generated super class. Children of IR elements form a tree. A child will be part of the methods

* traversing the tree, like {@code mapExpression} and {@code children}. The parameter type must be
* a subtype of {@code org.enso.compiler.ir.IR}.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* a subtype of {@code org.enso.compiler.ir.IR}.
* a subtype of {@link org.enso.compiler.ir.IR}.

*/
@Retention(RetentionPolicy.SOURCE)
@Target(ElementType.PARAMETER)
public @interface IRChild {
/** If true, the child will always be non-null. Otherwise, it can be null. */
boolean required() default true;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package org.enso.runtime.parser.dsl;

import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

/**
* A constructor parameter annotated with this annotation will have a corresponding user-defined
* field generated in the super class (See {@link GenerateFields} for docs about fields).
*
* <p>There is no restriction on the type of the parameter.
*/
@Retention(RetentionPolicy.SOURCE)
@Target(ElementType.PARAMETER)
public @interface IRField {
/** If true, the field will always be non-null. Otherwise, it can be null. */
boolean required() default true;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
package org.enso.runtime.parser.processor.test.gen.ir.core;

import java.util.function.Function;
import org.enso.compiler.core.IR;
import org.enso.compiler.core.ir.Expression;
import org.enso.compiler.core.ir.Name;
import org.enso.runtime.parser.dsl.GenerateFields;
import org.enso.runtime.parser.dsl.GenerateIR;
import org.enso.runtime.parser.dsl.IRChild;
import org.enso.runtime.parser.dsl.IRField;
import scala.Option;

/** Call-site arguments in Enso. */
public interface JCallArgument extends IR {
/** The name of the argument, if present. */
Option<Name> name();

/** The expression of the argument, if present. */
Expression value();

/** Flag indicating that the argument was generated by compiler. */
boolean isSynthetic();

@Override
JCallArgument mapExpressions(Function<Expression, Expression> fn);

@Override
JCallArgument duplicate(
boolean keepLocations,
boolean keepMetadata,
boolean keepDiagnostics,
boolean keepIdentifiers);

@GenerateIR(interfaces = "JCallArgument")
final class JSpecified extends JSpecifiedGen {
@GenerateFields
public JSpecified(
@IRField boolean isSynthetic, @IRChild Option<Name> name, @IRChild Expression value) {
super(isSynthetic, name, value);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
package org.enso.runtime.parser.processor.test.gen.ir.core;

import java.util.function.Function;
import org.enso.compiler.core.IR;
import org.enso.compiler.core.ir.Expression;
import org.enso.compiler.core.ir.Name;
import org.enso.runtime.parser.dsl.GenerateFields;
import org.enso.runtime.parser.dsl.GenerateIR;
import org.enso.runtime.parser.dsl.IRChild;
import org.enso.runtime.parser.dsl.IRField;
import scala.collection.immutable.List;

public interface JExpression extends IR {
@Override
JExpression mapExpressions(Function<Expression, Expression> fn);

@Override
JExpression duplicate(
boolean keepLocations,
boolean keepMetadata,
boolean keepDiagnostics,
boolean keepIdentifiers);

@GenerateIR(interfaces = "JExpression")
final class JBlock extends JBlockGen {
@GenerateFields
public JBlock(
@IRChild List<JExpression> expressions,
@IRChild JExpression returnValue,
@IRField boolean suspended) {
super(expressions, returnValue, suspended);
}
}

@GenerateIR(interfaces = "JExpression")
final class JBinding extends JBindingGen {
@GenerateFields
public JBinding(@IRChild Name name, @IRChild JExpression expression) {
super(name, expression);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
/**
* Contains hierarchy of interfaces that should correspond to the previous {@link
* org.enso.compiler.core.IR} element hierarchy. All the classes inside this package have {@code J}
* prefix. So for example {@code JCallArgument} correspond to {@code CallArgument}.
*
* <p>The motivation to put these classes here is to test the generation of {@link
* org.enso.runtime.parser.processor.IRProcessor}.
*/
package org.enso.runtime.parser.processor.test.gen.ir.core;
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
/**
* Contains interfaces with parser-dsl annotations. There will be generated classes for these
* interfaces and they are tested. All these interfaces are only for testing.
*/
package org.enso.runtime.parser.processor.test.gen.ir;
Loading
Loading