Skip to content

Commit 8c8f6a8

Browse files
author
jossonsmith
committed
Revert *Parser history information
1 parent 665f8b6 commit 8c8f6a8

File tree

2 files changed

+37
-85
lines changed

2 files changed

+37
-85
lines changed

sources/net.sf.j2s.core/src/net/sf/j2s/core/astvisitors/ASTEmptyVisitor.java

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,38 @@
1919
*
2020
* @author zhou renjian
2121
*/
22-
public class ASTEmptyParser extends ASTJ2SMapVisitor {
22+
public class ASTEmptyVisitor extends ASTVisitor {
23+
24+
/**
25+
* Buffer that keep all compiled *.js.
26+
* @see ASTScriptVisitor#laterBuffer
27+
*/
28+
protected StringBuffer buffer = new StringBuffer();
29+
30+
/**
31+
* Return the buffer. Actually it is returning compiled *.js String
32+
* @return
33+
*/
34+
public StringBuffer getBuffer() {
35+
return buffer;
36+
}
37+
38+
/**
39+
* Buffer may be set to other buffer.
40+
* @see ASTScriptVisitor#visit(TypeDeclaration)
41+
* @param buffer
42+
*/
43+
public void setBuffer(StringBuffer buffer) {
44+
this.buffer = buffer;
45+
}
46+
47+
48+
/*
49+
* The following are empty super.* methods which will be use to help
50+
* developing Java2Script compiler.
51+
*
52+
* In the final release of Java2Script, it may be commented out.
53+
*/
2354

2455
public void endVisit(AnnotationTypeDeclaration node) {
2556
super.endVisit(node);

sources/net.sf.j2s.core/src/net/sf/j2s/core/astvisitors/ASTKeywordVisitor.java

Lines changed: 5 additions & 84 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,6 @@
5353
import org.eclipse.jdt.core.dom.ParenthesizedExpression;
5454
import org.eclipse.jdt.core.dom.PostfixExpression;
5555
import org.eclipse.jdt.core.dom.PrefixExpression;
56-
import org.eclipse.jdt.core.dom.PrimitiveType;
5756
import org.eclipse.jdt.core.dom.QualifiedName;
5857
import org.eclipse.jdt.core.dom.ReturnStatement;
5958
import org.eclipse.jdt.core.dom.SimpleName;
@@ -71,35 +70,24 @@
7170
import org.eclipse.jdt.core.dom.VariableDeclarationFragment;
7271
import org.eclipse.jdt.core.dom.VariableDeclarationStatement;
7372
import org.eclipse.jdt.core.dom.WhileStatement;
74-
import org.eclipse.jdt.core.dom.PrimitiveType.Code;
7573

7674
/**
7775
* This class will traverse most of the common keyword and
7876
* common expression.
7977
*
8078
* This class will not deal with binding.
8179
*
82-
* @author josson smith
80+
* @author zhou renjian
8381
*
8482
*/
85-
public class ASTKeywordParser extends ASTEmptyParser {
86-
87-
protected StringBuffer buffer = new StringBuffer();
83+
public class ASTKeywordVisitor extends ASTJ2SMapVisitor {
8884

8985
protected int blockLevel = 0;
9086

9187
protected Stack methodDeclareStack = new Stack();
9288

9389
protected int currentBlockForVisit = -1;
9490

95-
public StringBuffer getBuffer() {
96-
return buffer;
97-
}
98-
99-
public void setBuffer(StringBuffer buffer) {
100-
this.buffer = buffer;
101-
}
102-
10391
protected void visitList(List list, String seperator) {
10492
for (Iterator iter = list.iterator(); iter.hasNext();) {
10593
ASTNode element = (ASTNode) iter.next();
@@ -110,73 +98,6 @@ protected void visitList(List list, String seperator) {
11098
}
11199
}
112100

113-
protected void boxingNode(ASTNode element) {
114-
if (element instanceof Expression) {
115-
Expression exp = (Expression) element;
116-
if (exp.resolveBoxing()) {
117-
ITypeBinding typeBinding = exp.resolveTypeBinding();
118-
if (typeBinding.isPrimitive()) {
119-
String name = typeBinding.getName();
120-
Code type = PrimitiveType.toCode(name);
121-
String bigName = null;
122-
if (type == PrimitiveType.INT) {
123-
bigName = "Integer";
124-
} else if (type == PrimitiveType.LONG) {
125-
bigName = "Long";
126-
} else if (type == PrimitiveType.FLOAT) {
127-
bigName = "Float";
128-
} else if (type == PrimitiveType.DOUBLE) {
129-
bigName = "Double";
130-
} else if (type == PrimitiveType.BOOLEAN) {
131-
bigName = "Boolean";
132-
} else if (type == PrimitiveType.BYTE) {
133-
bigName = "Byte";
134-
} else if (type == PrimitiveType.SHORT) {
135-
bigName = "Short";
136-
} else if (type == PrimitiveType.CHAR) {
137-
bigName = "Character";
138-
}
139-
if (bigName != null) {
140-
buffer.append("new " + bigName + " (");
141-
element.accept(this);
142-
buffer.append(")");
143-
return ;
144-
}
145-
}
146-
} else if (exp.resolveUnboxing()) {
147-
ITypeBinding typeBinding = exp.resolveTypeBinding();
148-
if (!typeBinding.isPrimitive()) {
149-
String name = typeBinding.getQualifiedName();
150-
String bigName = null;
151-
if ("java.lang.Integer".equals(name)) {
152-
bigName = "int";
153-
} else if ("java.lang.Long".equals(name)) {
154-
bigName = "long";
155-
} else if ("java.lang.Float".equals(name)) {
156-
bigName = "float";
157-
} else if ("java.lang.Double".equals(name)) {
158-
bigName = "double";
159-
} else if ("java.lang.Boolean".equals(name)) {
160-
bigName = "boolean";
161-
} else if ("java.lang.Byte".equals(name)) {
162-
bigName = "byte";
163-
} else if ("java.lang.Short".equals(name)) {
164-
bigName = "short";
165-
} else if ("java.lang.Character".equals(name)) {
166-
bigName = "char";
167-
}
168-
169-
if (bigName != null) {
170-
buffer.append("(");
171-
element.accept(this);
172-
buffer.append(")." + bigName + "Value ()");
173-
return ;
174-
}
175-
}
176-
}
177-
}
178-
element.accept(this);
179-
}
180101
protected void visitList(List list, String seperator, int begin, int end) {
181102
for (int i = begin; i < end; i++) {
182103
ASTNode element = (ASTNode) list.get(i);
@@ -468,13 +389,13 @@ public void endVisit(Block node) {
468389
buffer.append("}");
469390
for (int i = finalVars.size() - 1; i >= 0; i--) {
470391
FinalVariable var = (FinalVariable) finalVars.get(i);
471-
if (var.getBlockLevel() >= blockLevel) {
392+
if (var.blockLevel >= blockLevel) {
472393
finalVars.remove(i);
473394
}
474395
}
475396
for (int i = normalVars.size() - 1; i >= 0; i--) {
476397
FinalVariable var = (FinalVariable) normalVars.get(i);
477-
if (var.getBlockLevel() >= blockLevel) {
398+
if (var.blockLevel >= blockLevel) {
478399
normalVars.remove(i);
479400
}
480401
}
@@ -1143,7 +1064,7 @@ public boolean visit(VariableDeclarationFragment node) {
11431064
String methodSig = (String) methodDeclareStack.peek();
11441065
f = new FinalVariable(blockLevel, identifier, methodSig);
11451066
}
1146-
f.setToVariableName(getIndexedVarName(identifier, normalVars.size()));
1067+
f.toVariableName = getIndexedVarName(identifier, normalVars.size());
11471068
normalVars.add(f);
11481069
if ((binding.getModifiers() & Modifier.FINAL) != 0) {
11491070
finalVars.add(f);

0 commit comments

Comments
 (0)