forked from JavaTX/JavaCompilerCore
while Statement implemented
This commit is contained in:
parent
0cf8f82283
commit
856f9b059d
22
.idea/libraries/lib.xml
generated
Normal file
22
.idea/libraries/lib.xml
generated
Normal file
@ -0,0 +1,22 @@
|
||||
<component name="libraryTable">
|
||||
<library name="lib">
|
||||
<CLASSES>
|
||||
<root url="jar://$PROJECT_DIR$/lib/log4j-1.2.12.jar!/" />
|
||||
<root url="jar://$PROJECT_DIR$/lib/guava-10.0.1.jar!/" />
|
||||
<root url="jar://$PROJECT_DIR$/lib/bcel-6.1-SNAPSHOT.jar!/" />
|
||||
<root url="jar://$PROJECT_DIR$/lib/bcel-6.1-SNAPSHOT-sources.jar!/" />
|
||||
<root url="jar://$PROJECT_DIR$/lib/annotations-2.0.1.jar!/" />
|
||||
<root url="jar://$PROJECT_DIR$/lib/guava-15.0.jar!/" />
|
||||
<root url="jar://$PROJECT_DIR$/lib/junit-4.0.jar!/" />
|
||||
<root url="jar://$PROJECT_DIR$/lib/commons-bcel6-6.0-SNAPSHOT.jar!/" />
|
||||
<root url="jar://$PROJECT_DIR$/lib/reflections-0.9.10-javadoc.jar!/" />
|
||||
<root url="jar://$PROJECT_DIR$/lib/reflections-0.9.10.jar!/" />
|
||||
<root url="jar://$PROJECT_DIR$/lib/cloning.jar!/" />
|
||||
<root url="jar://$PROJECT_DIR$/lib/javassist-3.19.0-GA.jar!/" />
|
||||
<root url="jar://$PROJECT_DIR$/lib/reflections-0.9.10-sources.jar!/" />
|
||||
<root url="jar://$PROJECT_DIR$/lib/antlr-complete.jar!/" />
|
||||
</CLASSES>
|
||||
<JAVADOC />
|
||||
<SOURCES />
|
||||
</library>
|
||||
</component>
|
9
classes/classes.iml
Normal file
9
classes/classes.iml
Normal file
@ -0,0 +1,9 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module type="WEB_MODULE" version="4">
|
||||
<component name="NewModuleRootManager" inherit-compiler-output="true">
|
||||
<exclude-output />
|
||||
<content url="file://$MODULE_DIR$" />
|
||||
<orderEntry type="inheritedJdk" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
</component>
|
||||
</module>
|
9
doc/doc.iml
Normal file
9
doc/doc.iml
Normal file
@ -0,0 +1,9 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module type="WEB_MODULE" version="4">
|
||||
<component name="NewModuleRootManager" inherit-compiler-output="true">
|
||||
<exclude-output />
|
||||
<content url="file://$MODULE_DIR$" />
|
||||
<orderEntry type="inheritedJdk" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
</component>
|
||||
</module>
|
11
src/JavaCompilerCore1.iml
Normal file
11
src/JavaCompilerCore1.iml
Normal file
@ -0,0 +1,11 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module type="JAVA_MODULE" version="4">
|
||||
<component name="NewModuleRootManager" inherit-compiler-output="true">
|
||||
<exclude-output />
|
||||
<content url="file://$MODULE_DIR$">
|
||||
<sourceFolder url="file://$MODULE_DIR$" isTestSource="false" />
|
||||
</content>
|
||||
<orderEntry type="inheritedJdk" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
</component>
|
||||
</module>
|
@ -333,8 +333,9 @@ public class StatementGenerator {
|
||||
}
|
||||
|
||||
private Statement convert(Java8Parser.WhileStatementContext stmt){
|
||||
//TODO
|
||||
throw new NotImplementedException();
|
||||
Expression expr = convert(stmt.expression());
|
||||
Statement block = convert(stmt.statement());
|
||||
return new WhileStmt(expr, block,stmt.getStart());
|
||||
}
|
||||
|
||||
private Statement convert(Java8Parser.WhileStatementNoShortIfContext stmt){
|
||||
@ -441,8 +442,11 @@ public class StatementGenerator {
|
||||
}
|
||||
|
||||
private Statement convert(Java8Parser.ReturnStatementContext stmt){
|
||||
return new Return(convert(stmt.expression()),stmt.getStart());
|
||||
//throw new NotImplementedException();
|
||||
if(stmt.expression() != null){
|
||||
return new Return( convert(stmt.expression()),stmt.getStart());
|
||||
}else{
|
||||
return new ReturnVoid(stmt.getStart());
|
||||
}
|
||||
}
|
||||
|
||||
private Statement convert(Java8Parser.ThrowStatementContext stmt){
|
||||
|
@ -12,7 +12,8 @@ public class SyntacticSugar {
|
||||
Statement lastStmt = statements.get(statements.size() - 1);
|
||||
if (lastStmt instanceof Return) return statements;
|
||||
if (lastStmt instanceof WhileStmt) {
|
||||
if (hasReturn(((WhileStmt) lastStmt).loop_block)) return statements;
|
||||
//TODO
|
||||
//if (hasReturn(((WhileStmt) lastStmt).loopBlock)) return statements;
|
||||
} else if (lastStmt instanceof IfStmt) {
|
||||
if (hasReturn(((IfStmt) lastStmt).then_block)
|
||||
&& hasReturn(((IfStmt) lastStmt).else_block)) return statements;
|
||||
|
@ -2,20 +2,24 @@ package de.dhbwstuttgart.syntaxtree.statement;
|
||||
|
||||
|
||||
import de.dhbwstuttgart.syntaxtree.StatementVisitor;
|
||||
import de.dhbwstuttgart.syntaxtree.type.TypePlaceholder;
|
||||
import de.dhbwstuttgart.typeinference.assumptions.TypeInferenceBlockInformation;
|
||||
import de.dhbwstuttgart.typeinference.constraints.ConstraintSet;
|
||||
import de.dhbwstuttgart.typeinference.assumptions.TypeInferenceInformation;
|
||||
import de.dhbwstuttgart.exceptions.NotImplementedException;
|
||||
import org.antlr.v4.runtime.Token;
|
||||
|
||||
public class WhileStmt extends Statement
|
||||
{
|
||||
public WhileStmt(int offset, int variableLength)
|
||||
{
|
||||
super(null,null);
|
||||
}
|
||||
public final Expression expr;
|
||||
public final Statement loopBlock;
|
||||
|
||||
public Expression expr;
|
||||
public Block loop_block;
|
||||
public WhileStmt(Expression expr, Statement loopBlock, Token offset)
|
||||
{
|
||||
super(TypePlaceholder.fresh(offset), offset);
|
||||
this.expr = expr;
|
||||
this.loopBlock = loopBlock;
|
||||
}
|
||||
|
||||
/**
|
||||
* <br/>Author: Martin Pl�micke
|
||||
@ -23,7 +27,7 @@ public class WhileStmt extends Statement
|
||||
*/
|
||||
public String toString()
|
||||
{
|
||||
return "WHILE " + loop_block.toString();
|
||||
return "WHILE " + loopBlock.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -1,7 +1,6 @@
|
||||
package de.dhbwstuttgart.typecheck;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* Speichert die Klassen im aktuellen Projektscope
|
||||
@ -17,7 +16,7 @@ public class JavaClassRegistry {
|
||||
}
|
||||
|
||||
/**
|
||||
* Fügt ein gesamtes Package der ClassRegistry hinzu.
|
||||
* F<EFBFBD>gt ein gesamtes Package der ClassRegistry hinzu.
|
||||
* Dies geschieht beispielsweise, wenn der Benutzer ein "import package.*;" statement verwendet
|
||||
* @param packageName
|
||||
*/
|
||||
@ -55,6 +54,8 @@ public class JavaClassRegistry {
|
||||
}
|
||||
|
||||
public boolean contains(String whole) {
|
||||
return existingClasses.contains(new JavaClassName(whole));
|
||||
boolean ret = existingClasses.contains(new JavaClassName(whole));
|
||||
if(ret == false)existingClasses.add(getName(whole));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -14,7 +14,7 @@ public class RunParserTest {
|
||||
@Test
|
||||
public void testMain() throws Exception {
|
||||
String[] args = new String[1];
|
||||
args[0] = rootDirectory+"ImportTest2.jav";
|
||||
args[0] = rootDirectory+"WhileTest.jav";
|
||||
new JavaTXParser().parse(new File(args[0]));
|
||||
}
|
||||
}
|
9
test/parser/WhileTest.jav
Normal file
9
test/parser/WhileTest.jav
Normal file
@ -0,0 +1,9 @@
|
||||
class WhileTest{
|
||||
void methode(){
|
||||
Boolean test;
|
||||
while(test){
|
||||
test = test;
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
11
test/test.iml
Normal file
11
test/test.iml
Normal file
@ -0,0 +1,11 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module type="JAVA_MODULE" version="4">
|
||||
<component name="NewModuleRootManager" inherit-compiler-output="true">
|
||||
<exclude-output />
|
||||
<content url="file://$MODULE_DIR$">
|
||||
<sourceFolder url="file://$MODULE_DIR$" isTestSource="true" />
|
||||
</content>
|
||||
<orderEntry type="inheritedJdk" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
</component>
|
||||
</module>
|
9
tools/tools.iml
Normal file
9
tools/tools.iml
Normal file
@ -0,0 +1,9 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module type="WEB_MODULE" version="4">
|
||||
<component name="NewModuleRootManager" inherit-compiler-output="true">
|
||||
<exclude-output />
|
||||
<content url="file://$MODULE_DIR$" />
|
||||
<orderEntry type="inheritedJdk" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
</component>
|
||||
</module>
|
Loading…
Reference in New Issue
Block a user