mirror of
https://github.com/Eaglercraft-TeaVM-Fork/eagler-teavm.git
synced 2024-12-23 00:24:11 -08:00
Replace NodeModifier by ElementModifier
This commit is contained in:
parent
1be9ffb19e
commit
7679d12888
|
@ -19,15 +19,12 @@ import java.util.ArrayList;
|
||||||
import java.util.EnumSet;
|
import java.util.EnumSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
import org.teavm.model.ElementModifier;
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @author Alexey Andreev
|
|
||||||
*/
|
|
||||||
public class ClassNode {
|
public class ClassNode {
|
||||||
private String name;
|
private String name;
|
||||||
private String parentName;
|
private String parentName;
|
||||||
private Set<NodeModifier> modifiers = EnumSet.noneOf(NodeModifier.class);
|
private Set<ElementModifier> modifiers = EnumSet.noneOf(ElementModifier.class);
|
||||||
private List<FieldNode> fields = new ArrayList<>();
|
private List<FieldNode> fields = new ArrayList<>();
|
||||||
private List<MethodNode> methods = new ArrayList<>();
|
private List<MethodNode> methods = new ArrayList<>();
|
||||||
private List<String> interfaces = new ArrayList<>();
|
private List<String> interfaces = new ArrayList<>();
|
||||||
|
@ -57,7 +54,7 @@ public class ClassNode {
|
||||||
return interfaces;
|
return interfaces;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Set<NodeModifier> getModifiers() {
|
public Set<ElementModifier> getModifiers() {
|
||||||
return modifiers;
|
return modifiers;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,16 +17,13 @@ package org.teavm.ast;
|
||||||
|
|
||||||
import java.util.EnumSet;
|
import java.util.EnumSet;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
import org.teavm.model.ElementModifier;
|
||||||
import org.teavm.model.ValueType;
|
import org.teavm.model.ValueType;
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @author Alexey Andreev
|
|
||||||
*/
|
|
||||||
public class FieldNode {
|
public class FieldNode {
|
||||||
private String name;
|
private String name;
|
||||||
private ValueType type;
|
private ValueType type;
|
||||||
private Set<NodeModifier> modifiers = EnumSet.noneOf(NodeModifier.class);
|
private Set<ElementModifier> modifiers = EnumSet.noneOf(ElementModifier.class);
|
||||||
private Object initialValue;
|
private Object initialValue;
|
||||||
|
|
||||||
public FieldNode(String name, ValueType type) {
|
public FieldNode(String name, ValueType type) {
|
||||||
|
@ -38,7 +35,7 @@ public class FieldNode {
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Set<NodeModifier> getModifiers() {
|
public Set<ElementModifier> getModifiers() {
|
||||||
return modifiers;
|
return modifiers;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -18,11 +18,12 @@ package org.teavm.ast;
|
||||||
import java.util.EnumSet;
|
import java.util.EnumSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
import org.teavm.model.ElementModifier;
|
||||||
import org.teavm.model.MethodReference;
|
import org.teavm.model.MethodReference;
|
||||||
|
|
||||||
public abstract class MethodNode {
|
public abstract class MethodNode {
|
||||||
private MethodReference reference;
|
private MethodReference reference;
|
||||||
private Set<NodeModifier> modifiers = EnumSet.noneOf(NodeModifier.class);
|
private Set<ElementModifier> modifiers = EnumSet.noneOf(ElementModifier.class);
|
||||||
|
|
||||||
public MethodNode(MethodReference reference) {
|
public MethodNode(MethodReference reference) {
|
||||||
this.reference = reference;
|
this.reference = reference;
|
||||||
|
@ -33,7 +34,7 @@ public abstract class MethodNode {
|
||||||
return reference;
|
return reference;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Set<NodeModifier> getModifiers() {
|
public Set<ElementModifier> getModifiers() {
|
||||||
return modifiers;
|
return modifiers;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,27 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright 2016 Alexey Andreev.
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
package org.teavm.ast;
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @author Alexey Andreev
|
|
||||||
*/
|
|
||||||
public enum NodeModifier {
|
|
||||||
STATIC,
|
|
||||||
INTERFACE,
|
|
||||||
ENUM,
|
|
||||||
SYNCHRONIZED
|
|
||||||
}
|
|
|
@ -21,7 +21,6 @@ import java.util.Arrays;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.Deque;
|
import java.util.Deque;
|
||||||
import java.util.EnumSet;
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -37,7 +36,6 @@ import org.teavm.ast.GotoPartStatement;
|
||||||
import org.teavm.ast.IdentifiedStatement;
|
import org.teavm.ast.IdentifiedStatement;
|
||||||
import org.teavm.ast.MethodNode;
|
import org.teavm.ast.MethodNode;
|
||||||
import org.teavm.ast.NativeMethodNode;
|
import org.teavm.ast.NativeMethodNode;
|
||||||
import org.teavm.ast.NodeModifier;
|
|
||||||
import org.teavm.ast.RegularMethodNode;
|
import org.teavm.ast.RegularMethodNode;
|
||||||
import org.teavm.ast.SequentialStatement;
|
import org.teavm.ast.SequentialStatement;
|
||||||
import org.teavm.ast.Statement;
|
import org.teavm.ast.Statement;
|
||||||
|
@ -61,10 +59,10 @@ import org.teavm.model.ClassHolderSource;
|
||||||
import org.teavm.model.ElementModifier;
|
import org.teavm.model.ElementModifier;
|
||||||
import org.teavm.model.FieldHolder;
|
import org.teavm.model.FieldHolder;
|
||||||
import org.teavm.model.Instruction;
|
import org.teavm.model.Instruction;
|
||||||
import org.teavm.model.TextLocation;
|
|
||||||
import org.teavm.model.MethodHolder;
|
import org.teavm.model.MethodHolder;
|
||||||
import org.teavm.model.MethodReference;
|
import org.teavm.model.MethodReference;
|
||||||
import org.teavm.model.Program;
|
import org.teavm.model.Program;
|
||||||
|
import org.teavm.model.TextLocation;
|
||||||
import org.teavm.model.TryCatchBlock;
|
import org.teavm.model.TryCatchBlock;
|
||||||
import org.teavm.model.ValueType;
|
import org.teavm.model.ValueType;
|
||||||
import org.teavm.model.Variable;
|
import org.teavm.model.Variable;
|
||||||
|
@ -193,7 +191,7 @@ public class Decompiler {
|
||||||
ClassNode clsNode = new ClassNode(cls.getName(), cls.getParent());
|
ClassNode clsNode = new ClassNode(cls.getName(), cls.getParent());
|
||||||
for (FieldHolder field : cls.getFields()) {
|
for (FieldHolder field : cls.getFields()) {
|
||||||
FieldNode fieldNode = new FieldNode(field.getName(), field.getType());
|
FieldNode fieldNode = new FieldNode(field.getName(), field.getType());
|
||||||
fieldNode.getModifiers().addAll(mapModifiers(field.getModifiers()));
|
fieldNode.getModifiers().addAll(field.getModifiers());
|
||||||
fieldNode.setInitialValue(field.getInitialValue());
|
fieldNode.setInitialValue(field.getInitialValue());
|
||||||
clsNode.getFields().add(fieldNode);
|
clsNode.getFields().add(fieldNode);
|
||||||
}
|
}
|
||||||
|
@ -209,7 +207,7 @@ public class Decompiler {
|
||||||
clsNode.getMethods().add(methodNode);
|
clsNode.getMethods().add(methodNode);
|
||||||
}
|
}
|
||||||
clsNode.getInterfaces().addAll(cls.getInterfaces());
|
clsNode.getInterfaces().addAll(cls.getInterfaces());
|
||||||
clsNode.getModifiers().addAll(mapModifiers(cls.getModifiers()));
|
clsNode.getModifiers().addAll(cls.getModifiers());
|
||||||
return clsNode;
|
return clsNode;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -238,7 +236,7 @@ public class Decompiler {
|
||||||
}
|
}
|
||||||
NativeMethodNode methodNode = new NativeMethodNode(new MethodReference(method.getOwnerName(),
|
NativeMethodNode methodNode = new NativeMethodNode(new MethodReference(method.getOwnerName(),
|
||||||
method.getDescriptor()));
|
method.getDescriptor()));
|
||||||
methodNode.getModifiers().addAll(mapModifiers(method.getModifiers()));
|
methodNode.getModifiers().addAll(method.getModifiers());
|
||||||
methodNode.setGenerator(generator);
|
methodNode.setGenerator(generator);
|
||||||
methodNode.setAsync(asyncMethods.contains(method.getReference()));
|
methodNode.setAsync(asyncMethods.contains(method.getReference()));
|
||||||
return methodNode;
|
return methodNode;
|
||||||
|
@ -278,7 +276,7 @@ public class Decompiler {
|
||||||
|
|
||||||
Optimizer optimizer = new Optimizer();
|
Optimizer optimizer = new Optimizer();
|
||||||
optimizer.optimize(methodNode, method.getProgram());
|
optimizer.optimize(methodNode, method.getProgram());
|
||||||
methodNode.getModifiers().addAll(mapModifiers(method.getModifiers()));
|
methodNode.getModifiers().addAll(method.getModifiers());
|
||||||
int paramCount = Math.min(method.getSignature().length, program.variableCount());
|
int paramCount = Math.min(method.getSignature().length, program.variableCount());
|
||||||
for (int i = 0; i < paramCount; ++i) {
|
for (int i = 0; i < paramCount; ++i) {
|
||||||
Variable var = program.variableAt(i);
|
Variable var = program.variableAt(i);
|
||||||
|
@ -345,7 +343,7 @@ public class Decompiler {
|
||||||
|
|
||||||
Optimizer optimizer = new Optimizer();
|
Optimizer optimizer = new Optimizer();
|
||||||
optimizer.optimize(node, splitter);
|
optimizer.optimize(node, splitter);
|
||||||
node.getModifiers().addAll(mapModifiers(method.getModifiers()));
|
node.getModifiers().addAll(method.getModifiers());
|
||||||
int paramCount = Math.min(method.getSignature().length, program.variableCount());
|
int paramCount = Math.min(method.getSignature().length, program.variableCount());
|
||||||
for (int i = 0; i < paramCount; ++i) {
|
for (int i = 0; i < paramCount; ++i) {
|
||||||
Variable var = program.variableAt(i);
|
Variable var = program.variableAt(i);
|
||||||
|
@ -555,23 +553,6 @@ public class Decompiler {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private Set<NodeModifier> mapModifiers(Set<ElementModifier> modifiers) {
|
|
||||||
Set<NodeModifier> result = EnumSet.noneOf(NodeModifier.class);
|
|
||||||
if (modifiers.contains(ElementModifier.STATIC)) {
|
|
||||||
result.add(NodeModifier.STATIC);
|
|
||||||
}
|
|
||||||
if (modifiers.contains(ElementModifier.INTERFACE)) {
|
|
||||||
result.add(NodeModifier.INTERFACE);
|
|
||||||
}
|
|
||||||
if (modifiers.contains(ElementModifier.ENUM)) {
|
|
||||||
result.add(NodeModifier.ENUM);
|
|
||||||
}
|
|
||||||
if (modifiers.contains(ElementModifier.SYNCHRONIZED)) {
|
|
||||||
result.add(NodeModifier.SYNCHRONIZED);
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
private List<Block> createBlocks(int start) {
|
private List<Block> createBlocks(int start) {
|
||||||
List<Block> result = new ArrayList<>();
|
List<Block> result = new ArrayList<>();
|
||||||
while (currentNode != null && currentNode.getStart() == start) {
|
while (currentNode != null && currentNode.getStart() == start) {
|
||||||
|
|
12
core/src/main/java/org/teavm/cache/AstIO.java
vendored
12
core/src/main/java/org/teavm/cache/AstIO.java
vendored
|
@ -51,7 +51,6 @@ import org.teavm.ast.MonitorExitStatement;
|
||||||
import org.teavm.ast.NewArrayExpr;
|
import org.teavm.ast.NewArrayExpr;
|
||||||
import org.teavm.ast.NewExpr;
|
import org.teavm.ast.NewExpr;
|
||||||
import org.teavm.ast.NewMultiArrayExpr;
|
import org.teavm.ast.NewMultiArrayExpr;
|
||||||
import org.teavm.ast.NodeModifier;
|
|
||||||
import org.teavm.ast.OperationType;
|
import org.teavm.ast.OperationType;
|
||||||
import org.teavm.ast.PrimitiveCastExpr;
|
import org.teavm.ast.PrimitiveCastExpr;
|
||||||
import org.teavm.ast.QualificationExpr;
|
import org.teavm.ast.QualificationExpr;
|
||||||
|
@ -71,6 +70,7 @@ import org.teavm.ast.UnwrapArrayExpr;
|
||||||
import org.teavm.ast.VariableExpr;
|
import org.teavm.ast.VariableExpr;
|
||||||
import org.teavm.ast.VariableNode;
|
import org.teavm.ast.VariableNode;
|
||||||
import org.teavm.ast.WhileStatement;
|
import org.teavm.ast.WhileStatement;
|
||||||
|
import org.teavm.model.ElementModifier;
|
||||||
import org.teavm.model.FieldReference;
|
import org.teavm.model.FieldReference;
|
||||||
import org.teavm.model.MethodDescriptor;
|
import org.teavm.model.MethodDescriptor;
|
||||||
import org.teavm.model.MethodReference;
|
import org.teavm.model.MethodReference;
|
||||||
|
@ -80,7 +80,7 @@ import org.teavm.model.instructions.ArrayElementType;
|
||||||
import org.teavm.model.util.VariableType;
|
import org.teavm.model.util.VariableType;
|
||||||
|
|
||||||
public class AstIO {
|
public class AstIO {
|
||||||
private static final NodeModifier[] nodeModifiers = NodeModifier.values();
|
private static final ElementModifier[] nodeModifiers = ElementModifier.values();
|
||||||
private static final BinaryOperation[] binaryOperations = BinaryOperation.values();
|
private static final BinaryOperation[] binaryOperations = BinaryOperation.values();
|
||||||
private static final UnaryOperation[] unaryOperations = UnaryOperation.values();
|
private static final UnaryOperation[] unaryOperations = UnaryOperation.values();
|
||||||
private static final ArrayElementType[] arrayElementTypes = ArrayElementType.values();
|
private static final ArrayElementType[] arrayElementTypes = ArrayElementType.values();
|
||||||
|
@ -196,16 +196,16 @@ public class AstIO {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private int packModifiers(Set<NodeModifier> modifiers) {
|
private int packModifiers(Set<ElementModifier> modifiers) {
|
||||||
int packed = 0;
|
int packed = 0;
|
||||||
for (NodeModifier modifier : modifiers) {
|
for (ElementModifier modifier : modifiers) {
|
||||||
packed |= 1 << modifier.ordinal();
|
packed |= 1 << modifier.ordinal();
|
||||||
}
|
}
|
||||||
return packed;
|
return packed;
|
||||||
}
|
}
|
||||||
|
|
||||||
private Set<NodeModifier> unpackModifiers(int packed) {
|
private Set<ElementModifier> unpackModifiers(int packed) {
|
||||||
EnumSet<NodeModifier> modifiers = EnumSet.noneOf(NodeModifier.class);
|
EnumSet<ElementModifier> modifiers = EnumSet.noneOf(ElementModifier.class);
|
||||||
while (packed != 0) {
|
while (packed != 0) {
|
||||||
int shift = Integer.numberOfTrailingZeros(packed);
|
int shift = Integer.numberOfTrailingZeros(packed);
|
||||||
modifiers.add(nodeModifiers[shift]);
|
modifiers.add(nodeModifiers[shift]);
|
||||||
|
|
|
@ -44,7 +44,6 @@ import org.teavm.ast.NativeMethodNode;
|
||||||
import org.teavm.ast.NewArrayExpr;
|
import org.teavm.ast.NewArrayExpr;
|
||||||
import org.teavm.ast.NewExpr;
|
import org.teavm.ast.NewExpr;
|
||||||
import org.teavm.ast.NewMultiArrayExpr;
|
import org.teavm.ast.NewMultiArrayExpr;
|
||||||
import org.teavm.ast.NodeModifier;
|
|
||||||
import org.teavm.ast.PrimitiveCastExpr;
|
import org.teavm.ast.PrimitiveCastExpr;
|
||||||
import org.teavm.ast.QualificationExpr;
|
import org.teavm.ast.QualificationExpr;
|
||||||
import org.teavm.ast.RegularMethodNode;
|
import org.teavm.ast.RegularMethodNode;
|
||||||
|
@ -100,7 +99,7 @@ class NameFrequencyEstimator implements StatementVisitor, ExprVisitor, MethodNod
|
||||||
}
|
}
|
||||||
for (FieldNode field : cls.getFields()) {
|
for (FieldNode field : cls.getFields()) {
|
||||||
consumer.consume(new FieldReference(cls.getName(), field.getName()));
|
consumer.consume(new FieldReference(cls.getName(), field.getName()));
|
||||||
if (field.getModifiers().contains(NodeModifier.STATIC)) {
|
if (field.getModifiers().contains(ElementModifier.STATIC)) {
|
||||||
consumer.consume(cls.getName());
|
consumer.consume(cls.getName());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -113,11 +112,11 @@ class NameFrequencyEstimator implements StatementVisitor, ExprVisitor, MethodNod
|
||||||
if (asyncFamilyMethods.contains(method.getReference())) {
|
if (asyncFamilyMethods.contains(method.getReference())) {
|
||||||
consumer.consume(method.getReference());
|
consumer.consume(method.getReference());
|
||||||
}
|
}
|
||||||
if (clinit != null && (method.getModifiers().contains(NodeModifier.STATIC)
|
if (clinit != null && (method.getModifiers().contains(ElementModifier.STATIC)
|
||||||
|| method.getReference().getName().equals("<init>"))) {
|
|| method.getReference().getName().equals("<init>"))) {
|
||||||
consumer.consume(method.getReference());
|
consumer.consume(method.getReference());
|
||||||
}
|
}
|
||||||
if (!method.getModifiers().contains(NodeModifier.STATIC)) {
|
if (!method.getModifiers().contains(ElementModifier.STATIC)) {
|
||||||
consumer.consume(method.getReference().getDescriptor());
|
consumer.consume(method.getReference().getDescriptor());
|
||||||
consumer.consume(method.getReference());
|
consumer.consume(method.getReference());
|
||||||
}
|
}
|
||||||
|
|
|
@ -57,7 +57,6 @@ import org.teavm.ast.NativeMethodNode;
|
||||||
import org.teavm.ast.NewArrayExpr;
|
import org.teavm.ast.NewArrayExpr;
|
||||||
import org.teavm.ast.NewExpr;
|
import org.teavm.ast.NewExpr;
|
||||||
import org.teavm.ast.NewMultiArrayExpr;
|
import org.teavm.ast.NewMultiArrayExpr;
|
||||||
import org.teavm.ast.NodeModifier;
|
|
||||||
import org.teavm.ast.OperationType;
|
import org.teavm.ast.OperationType;
|
||||||
import org.teavm.ast.PrimitiveCastExpr;
|
import org.teavm.ast.PrimitiveCastExpr;
|
||||||
import org.teavm.ast.QualificationExpr;
|
import org.teavm.ast.QualificationExpr;
|
||||||
|
@ -382,7 +381,7 @@ public class Renderer implements ExprVisitor, StatementVisitor, RenderingContext
|
||||||
List<FieldNode> nonStaticFields = new ArrayList<>();
|
List<FieldNode> nonStaticFields = new ArrayList<>();
|
||||||
List<FieldNode> staticFields = new ArrayList<>();
|
List<FieldNode> staticFields = new ArrayList<>();
|
||||||
for (FieldNode field : cls.getFields()) {
|
for (FieldNode field : cls.getFields()) {
|
||||||
if (field.getModifiers().contains(NodeModifier.STATIC)) {
|
if (field.getModifiers().contains(ElementModifier.STATIC)) {
|
||||||
staticFields.add(field);
|
staticFields.add(field);
|
||||||
} else {
|
} else {
|
||||||
nonStaticFields.add(field);
|
nonStaticFields.add(field);
|
||||||
|
@ -443,7 +442,7 @@ public class Renderer implements ExprVisitor, StatementVisitor, RenderingContext
|
||||||
boolean needsClinit = clinit != null;
|
boolean needsClinit = clinit != null;
|
||||||
List<MethodNode> clinitMethods = new ArrayList<>();
|
List<MethodNode> clinitMethods = new ArrayList<>();
|
||||||
for (MethodNode method : cls.getMethods()) {
|
for (MethodNode method : cls.getMethods()) {
|
||||||
if (needsClinit && (method.getModifiers().contains(NodeModifier.STATIC)
|
if (needsClinit && (method.getModifiers().contains(ElementModifier.STATIC)
|
||||||
|| method.getReference().getName().equals("<init>"))) {
|
|| method.getReference().getName().equals("<init>"))) {
|
||||||
clinitMethods.add(method);
|
clinitMethods.add(method);
|
||||||
} else {
|
} else {
|
||||||
|
@ -463,10 +462,10 @@ public class Renderer implements ExprVisitor, StatementVisitor, RenderingContext
|
||||||
.append("();").softNewLine();
|
.append("();").softNewLine();
|
||||||
writer.outdent().append("}").newLine();
|
writer.outdent().append("}").newLine();
|
||||||
}
|
}
|
||||||
if (!cls.getModifiers().contains(NodeModifier.INTERFACE)) {
|
if (!cls.getModifiers().contains(ElementModifier.INTERFACE)) {
|
||||||
for (MethodNode method : cls.getMethods()) {
|
for (MethodNode method : cls.getMethods()) {
|
||||||
cls.getMethods();
|
cls.getMethods();
|
||||||
if (!method.getModifiers().contains(NodeModifier.STATIC)) {
|
if (!method.getModifiers().contains(ElementModifier.STATIC)) {
|
||||||
if (method.getReference().getName().equals("<init>")) {
|
if (method.getReference().getName().equals("<init>")) {
|
||||||
renderInitializer(method);
|
renderInitializer(method);
|
||||||
}
|
}
|
||||||
|
@ -512,7 +511,7 @@ public class Renderer implements ExprVisitor, StatementVisitor, RenderingContext
|
||||||
}
|
}
|
||||||
writer.append("],").ws();
|
writer.append("],").ws();
|
||||||
int flags = 0;
|
int flags = 0;
|
||||||
if (cls.getModifiers().contains(NodeModifier.ENUM)) {
|
if (cls.getModifiers().contains(ElementModifier.ENUM)) {
|
||||||
flags |= 1;
|
flags |= 1;
|
||||||
}
|
}
|
||||||
writer.append(flags).append(',').ws();
|
writer.append(flags).append(',').ws();
|
||||||
|
@ -528,11 +527,11 @@ public class Renderer implements ExprVisitor, StatementVisitor, RenderingContext
|
||||||
List<String> stubNames = new ArrayList<>();
|
List<String> stubNames = new ArrayList<>();
|
||||||
List<MethodNode> virtualMethods = new ArrayList<>();
|
List<MethodNode> virtualMethods = new ArrayList<>();
|
||||||
for (MethodNode method : cls.getMethods()) {
|
for (MethodNode method : cls.getMethods()) {
|
||||||
if (clinit != null && (method.getModifiers().contains(NodeModifier.STATIC)
|
if (clinit != null && (method.getModifiers().contains(ElementModifier.STATIC)
|
||||||
|| method.getReference().getName().equals("<init>"))) {
|
|| method.getReference().getName().equals("<init>"))) {
|
||||||
stubNames.add(naming.getFullNameFor(method.getReference()));
|
stubNames.add(naming.getFullNameFor(method.getReference()));
|
||||||
}
|
}
|
||||||
if (!method.getModifiers().contains(NodeModifier.STATIC)) {
|
if (!method.getModifiers().contains(ElementModifier.STATIC)) {
|
||||||
virtualMethods.add(method);
|
virtualMethods.add(method);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -665,7 +664,7 @@ public class Renderer implements ExprVisitor, StatementVisitor, RenderingContext
|
||||||
writer.append("function ").append(name).append("(");
|
writer.append("function ").append(name).append("(");
|
||||||
}
|
}
|
||||||
int startParam = 0;
|
int startParam = 0;
|
||||||
if (method.getModifiers().contains(NodeModifier.STATIC)) {
|
if (method.getModifiers().contains(ElementModifier.STATIC)) {
|
||||||
startParam = 1;
|
startParam = 1;
|
||||||
}
|
}
|
||||||
for (int i = startParam; i <= ref.parameterCount(); ++i) {
|
for (int i = startParam; i <= ref.parameterCount(); ++i) {
|
||||||
|
@ -784,7 +783,7 @@ public class Renderer implements ExprVisitor, StatementVisitor, RenderingContext
|
||||||
}
|
}
|
||||||
|
|
||||||
int firstToSave = 0;
|
int firstToSave = 0;
|
||||||
if (methodNode.getModifiers().contains(NodeModifier.STATIC)) {
|
if (methodNode.getModifiers().contains(ElementModifier.STATIC)) {
|
||||||
firstToSave = 1;
|
firstToSave = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -804,7 +803,7 @@ public class Renderer implements ExprVisitor, StatementVisitor, RenderingContext
|
||||||
writer.softNewLine();
|
writer.softNewLine();
|
||||||
writer.outdent().append("}").softNewLine();
|
writer.outdent().append("}").softNewLine();
|
||||||
|
|
||||||
if (methodNode.getModifiers().contains(NodeModifier.SYNCHRONIZED)) {
|
if (methodNode.getModifiers().contains(ElementModifier.SYNCHRONIZED)) {
|
||||||
writer.append("try").ws().append('{').indent().softNewLine();
|
writer.append("try").ws().append('{').indent().softNewLine();
|
||||||
}
|
}
|
||||||
writer.append(mainLoopName()).append(":").ws().append("while").ws().append("(true)")
|
writer.append(mainLoopName()).append(":").ws().append("while").ws().append("(true)")
|
||||||
|
@ -813,7 +812,7 @@ public class Renderer implements ExprVisitor, StatementVisitor, RenderingContext
|
||||||
.append('{').softNewLine();
|
.append('{').softNewLine();
|
||||||
for (int i = 0; i < methodNode.getBody().size(); ++i) {
|
for (int i = 0; i < methodNode.getBody().size(); ++i) {
|
||||||
writer.append("case ").append(i).append(":").indent().softNewLine();
|
writer.append("case ").append(i).append(":").indent().softNewLine();
|
||||||
if (i == 0 && methodNode.getModifiers().contains(NodeModifier.SYNCHRONIZED)) {
|
if (i == 0 && methodNode.getModifiers().contains(ElementModifier.SYNCHRONIZED)) {
|
||||||
writer.appendMethodBody(new MethodReference(Object.class, "monitorEnter",
|
writer.appendMethodBody(new MethodReference(Object.class, "monitorEnter",
|
||||||
Object.class, void.class));
|
Object.class, void.class));
|
||||||
writer.append("(");
|
writer.append("(");
|
||||||
|
@ -830,7 +829,7 @@ public class Renderer implements ExprVisitor, StatementVisitor, RenderingContext
|
||||||
writer.append("default:").ws().appendFunction("$rt_invalidPointer").append("();").softNewLine();
|
writer.append("default:").ws().appendFunction("$rt_invalidPointer").append("();").softNewLine();
|
||||||
writer.append("}}").softNewLine();
|
writer.append("}}").softNewLine();
|
||||||
|
|
||||||
if (methodNode.getModifiers().contains(NodeModifier.SYNCHRONIZED)) {
|
if (methodNode.getModifiers().contains(ElementModifier.SYNCHRONIZED)) {
|
||||||
writer.outdent().append("}").ws().append("finally").ws().append('{').indent().softNewLine();
|
writer.outdent().append("}").ws().append("finally").ws().append('{').indent().softNewLine();
|
||||||
writer.append("if").ws().append("(!").appendFunction("$rt_suspending").append("())")
|
writer.append("if").ws().append("(!").appendFunction("$rt_suspending").append("())")
|
||||||
.ws().append("{").indent().softNewLine();
|
.ws().append("{").indent().softNewLine();
|
||||||
|
@ -901,7 +900,7 @@ public class Renderer implements ExprVisitor, StatementVisitor, RenderingContext
|
||||||
}
|
}
|
||||||
|
|
||||||
private void appendMonitor(MethodNode methodNode) throws IOException {
|
private void appendMonitor(MethodNode methodNode) throws IOException {
|
||||||
if (methodNode.getModifiers().contains(NodeModifier.STATIC)) {
|
if (methodNode.getModifiers().contains(ElementModifier.STATIC)) {
|
||||||
writer.appendFunction("$rt_cls").append("(")
|
writer.appendFunction("$rt_cls").append("(")
|
||||||
.appendClass(methodNode.getReference().getClassName()).append(")");
|
.appendClass(methodNode.getReference().getClassName()).append(")");
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user