Skip to content

Commit a44ad56

Browse files
authored
Complete replacing member data with decorations in the ir tree (elastic#64825)
This change replaces all the member data in the ir nodes with decorations instead. This completes the transition to a decoration system in the ir tree. This change allows for maximum flexibility when modifying existing phases or adding additional phases.
1 parent 56a25bf commit a44ad56

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

55 files changed

+1190
-1632
lines changed

modules/lang-painless/src/main/java/org/elasticsearch/painless/ir/BlockNode.java

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -39,19 +39,7 @@ public List<StatementNode> getStatementsNodes() {
3939
return statementNodes;
4040
}
4141

42-
/* ---- end tree structure, begin node data ---- */
43-
44-
private boolean doAllEscape;
45-
46-
public void setAllEscape(boolean doAllEscape) {
47-
this.doAllEscape = doAllEscape;
48-
}
49-
50-
public boolean doAllEscape() {
51-
return doAllEscape;
52-
}
53-
54-
/* ---- end node data, begin visitor ---- */
42+
/* ---- end tree structure, begin visitor ---- */
5543

5644
@Override
5745
public <Scope> void visit(IRTreeVisitor<Scope> irTreeVisitor, Scope scope) {

modules/lang-painless/src/main/java/org/elasticsearch/painless/ir/BooleanNode.java

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -20,24 +20,11 @@
2020
package org.elasticsearch.painless.ir;
2121

2222
import org.elasticsearch.painless.Location;
23-
import org.elasticsearch.painless.Operation;
2423
import org.elasticsearch.painless.phase.IRTreeVisitor;
2524

2625
public class BooleanNode extends BinaryNode {
2726

28-
/* ---- begin node data ---- */
29-
30-
private Operation operation;
31-
32-
public void setOperation(Operation operation) {
33-
this.operation = operation;
34-
}
35-
36-
public Operation getOperation() {
37-
return operation;
38-
}
39-
40-
/* ---- end node data, begin visitor ---- */
27+
/* ---- begin visitor ---- */
4128

4229
@Override
4330
public <Scope> void visit(IRTreeVisitor<Scope> irTreeVisitor, Scope scope) {

modules/lang-painless/src/main/java/org/elasticsearch/painless/ir/CastNode.java

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -20,24 +20,11 @@
2020
package org.elasticsearch.painless.ir;
2121

2222
import org.elasticsearch.painless.Location;
23-
import org.elasticsearch.painless.lookup.PainlessCast;
2423
import org.elasticsearch.painless.phase.IRTreeVisitor;
2524

2625
public class CastNode extends UnaryNode {
2726

28-
/* ---- begin node data ---- */
29-
30-
private PainlessCast cast;
31-
32-
public void setCast(PainlessCast cast) {
33-
this.cast = cast;
34-
}
35-
36-
public PainlessCast getCast() {
37-
return cast;
38-
}
39-
40-
/* ---- end node data, begin visitor ---- */
27+
/* ---- begin visitor ---- */
4128

4229
@Override
4330
public <Scope> void visit(IRTreeVisitor<Scope> irTreeVisitor, Scope scope) {

modules/lang-painless/src/main/java/org/elasticsearch/painless/ir/CatchNode.java

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -26,26 +26,8 @@ public class CatchNode extends StatementNode {
2626

2727
/* ---- begin tree structure ---- */
2828

29-
private Class<?> exceptionType;
30-
private String symbol;
3129
private BlockNode blockNode;
3230

33-
public void setExceptionType(Class<?> exceptionType) {
34-
this.exceptionType = exceptionType;
35-
}
36-
37-
public Class<?> getExceptionType() {
38-
return exceptionType;
39-
}
40-
41-
public void setSymbol(String symbol) {
42-
this.symbol = symbol;
43-
}
44-
45-
public String getSymbol() {
46-
return symbol;
47-
}
48-
4931
public void setBlockNode(BlockNode blockNode) {
5032
this.blockNode = blockNode;
5133
}

modules/lang-painless/src/main/java/org/elasticsearch/painless/ir/ClassNode.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121

2222
import org.elasticsearch.painless.Location;
2323
import org.elasticsearch.painless.phase.IRTreeVisitor;
24+
import org.elasticsearch.painless.symbol.IRDecorations.IRCAllEscape;
2425
import org.elasticsearch.painless.symbol.ScriptScope;
2526
import org.objectweb.asm.util.Printer;
2627

@@ -107,7 +108,7 @@ public ClassNode(Location location) {
107108
super(location);
108109

109110
clinitBlockNode = new BlockNode(new Location("internal$clinit$blocknode", 0));
110-
clinitBlockNode.setAllEscape(true);
111+
clinitBlockNode.attachCondition(IRCAllEscape.class);
111112
}
112113

113114
}

modules/lang-painless/src/main/java/org/elasticsearch/painless/ir/ComparisonNode.java

Lines changed: 1 addition & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -20,38 +20,11 @@
2020
package org.elasticsearch.painless.ir;
2121

2222
import org.elasticsearch.painless.Location;
23-
import org.elasticsearch.painless.Operation;
24-
import org.elasticsearch.painless.lookup.PainlessLookupUtility;
2523
import org.elasticsearch.painless.phase.IRTreeVisitor;
2624

2725
public class ComparisonNode extends BinaryNode {
2826

29-
/* ---- begin node data ---- */
30-
31-
private Operation operation;
32-
private Class<?> comparisonType;
33-
34-
public void setOperation(Operation operation) {
35-
this.operation = operation;
36-
}
37-
38-
public Operation getOperation() {
39-
return operation;
40-
}
41-
42-
public void setComparisonType(Class<?> comparisonType) {
43-
this.comparisonType = comparisonType;
44-
}
45-
46-
public Class<?> getComparisonType() {
47-
return comparisonType;
48-
}
49-
50-
public String getComparisonCanonicalTypeName() {
51-
return PainlessLookupUtility.typeToCanonicalTypeName(comparisonType);
52-
}
53-
54-
/* ---- end node data, begin visitor ---- */
27+
/* ---- begin visitor ---- */
5528

5629
@Override
5730
public <Scope> void visit(IRTreeVisitor<Scope> irTreeVisitor, Scope scope) {

modules/lang-painless/src/main/java/org/elasticsearch/painless/ir/ConstantNode.java

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -24,19 +24,7 @@
2424

2525
public class ConstantNode extends ExpressionNode {
2626

27-
/* ---- begin node data ---- */
28-
29-
private Object constant;
30-
31-
public void setConstant(Object constant) {
32-
this.constant = constant;
33-
}
34-
35-
public Object getConstant() {
36-
return constant;
37-
}
38-
39-
/* ---- end node data, begin visitor ---- */
27+
/* ---- begin visitor ---- */
4028

4129
@Override
4230
public <Scope> void visit(IRTreeVisitor<Scope> irTreeVisitor, Scope scope) {

modules/lang-painless/src/main/java/org/elasticsearch/painless/ir/DeclarationNode.java

Lines changed: 1 addition & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
package org.elasticsearch.painless.ir;
2121

2222
import org.elasticsearch.painless.Location;
23-
import org.elasticsearch.painless.lookup.PainlessLookupUtility;
2423
import org.elasticsearch.painless.phase.IRTreeVisitor;
2524

2625
public class DeclarationNode extends StatementNode {
@@ -37,32 +36,7 @@ public ExpressionNode getExpressionNode() {
3736
return expressionNode;
3837
}
3938

40-
/* ---- end tree structure, begin node data ---- */
41-
42-
protected String name;
43-
protected Class<?> declarationType;
44-
45-
public void setName(String name) {
46-
this.name = name;
47-
}
48-
49-
public String getName() {
50-
return name;
51-
}
52-
53-
public void setDeclarationType(Class<?> declarationType) {
54-
this.declarationType = declarationType;
55-
}
56-
57-
public Class<?> getDeclarationType() {
58-
return declarationType;
59-
}
60-
61-
public String getDeclarationCanonicalTypeName() {
62-
return PainlessLookupUtility.typeToCanonicalTypeName(declarationType);
63-
}
64-
65-
/* ---- end node data, begin visitor ---- */
39+
/* ---- end tree structure, begin visitor ---- */
6640

6741
@Override
6842
public <Scope> void visit(IRTreeVisitor<Scope> irTreeVisitor, Scope scope) {

modules/lang-painless/src/main/java/org/elasticsearch/painless/ir/DefInterfaceReferenceNode.java

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -22,21 +22,9 @@
2222
import org.elasticsearch.painless.Location;
2323
import org.elasticsearch.painless.phase.IRTreeVisitor;
2424

25-
public class DefInterfaceReferenceNode extends ReferenceNode {
25+
public class DefInterfaceReferenceNode extends ExpressionNode {
2626

27-
/* ---- begin node data ---- */
28-
29-
private String defReferenceEncoding;
30-
31-
public void setDefReferenceEncoding(String defReferenceEncoding) {
32-
this.defReferenceEncoding = defReferenceEncoding;
33-
}
34-
35-
public String getDefReferenceEncoding() {
36-
return defReferenceEncoding;
37-
}
38-
39-
/* ---- end node data, begin visitor ---- */
27+
/* ---- begin visitor ---- */
4028

4129
@Override
4230
public <Scope> void visit(IRTreeVisitor<Scope> irTreeVisitor, Scope scope) {

modules/lang-painless/src/main/java/org/elasticsearch/painless/ir/DoWhileLoopNode.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
import org.elasticsearch.painless.Location;
2323
import org.elasticsearch.painless.phase.IRTreeVisitor;
2424

25-
public class DoWhileLoopNode extends LoopNode {
25+
public class DoWhileLoopNode extends ConditionNode {
2626

2727
/* ---- begin visitor ---- */
2828

modules/lang-painless/src/main/java/org/elasticsearch/painless/ir/DupNode.java

Lines changed: 1 addition & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -24,28 +24,7 @@
2424

2525
public class DupNode extends UnaryNode {
2626

27-
/* ---- begin node data ---- */
28-
29-
private int size;
30-
private int depth;
31-
32-
public void setSize(int size) {
33-
this.size = size;
34-
}
35-
36-
public int getSize() {
37-
return size;
38-
}
39-
40-
public void setDepth(int depth) {
41-
this.depth = depth;
42-
}
43-
44-
public int getDepth() {
45-
return depth;
46-
}
47-
48-
/* ---- end node data, begin visitor ---- */
27+
/* ---- begin visitor ---- */
4928

5029
@Override
5130
public <Scope> void visit(IRTreeVisitor<Scope> irTreeVisitor, Scope scope) {

modules/lang-painless/src/main/java/org/elasticsearch/painless/ir/FieldNode.java

Lines changed: 1 addition & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -20,46 +20,11 @@
2020
package org.elasticsearch.painless.ir;
2121

2222
import org.elasticsearch.painless.Location;
23-
import org.elasticsearch.painless.lookup.PainlessLookupUtility;
2423
import org.elasticsearch.painless.phase.IRTreeVisitor;
2524

2625
public class FieldNode extends IRNode {
2726

28-
/* ---- begin node data ---- */
29-
30-
private int modifiers;
31-
private Class<?> fieldType;
32-
private String name;
33-
34-
public void setModifiers(int modifiers) {
35-
this.modifiers = modifiers;
36-
}
37-
38-
public int getModifiers() {
39-
return modifiers;
40-
}
41-
42-
public void setFieldType(Class<?> fieldType) {
43-
this.fieldType = fieldType;
44-
}
45-
46-
public Class<?> getFieldType() {
47-
return fieldType;
48-
}
49-
50-
public String getFieldCanonicalTypeName() {
51-
return PainlessLookupUtility.typeToCanonicalTypeName(fieldType);
52-
}
53-
54-
public void setName(String name) {
55-
this.name = name;
56-
}
57-
58-
public String getName() {
59-
return name;
60-
}
61-
62-
/* ---- end node data, begin visitor ---- */
27+
/* ---- begin visitor ---- */
6328

6429
@Override
6530
public <Scope> void visit(IRTreeVisitor<Scope> irTreeVisitor, Scope scope) {

0 commit comments

Comments
 (0)