forked from JavaTX/JavaCompilerCore
GenCode: LongLit implementiert, aufgrund von Typinferenz-Problemen nicht
testbar
This commit is contained in:
parent
5f6525db19
commit
03b0544131
@ -13,6 +13,7 @@ import org.apache.bcel.generic.FSTORE;
|
|||||||
import org.apache.bcel.generic.ISTORE;
|
import org.apache.bcel.generic.ISTORE;
|
||||||
import org.apache.bcel.generic.InstructionFactory;
|
import org.apache.bcel.generic.InstructionFactory;
|
||||||
import org.apache.bcel.generic.InstructionList;
|
import org.apache.bcel.generic.InstructionList;
|
||||||
|
import org.apache.bcel.generic.LSTORE;
|
||||||
|
|
||||||
import de.dhbwstuttgart.typeinference.Menge;
|
import de.dhbwstuttgart.typeinference.Menge;
|
||||||
import de.dhbwstuttgart.logger.Logger;
|
import de.dhbwstuttgart.logger.Logger;
|
||||||
@ -201,6 +202,10 @@ public class Assign extends Expr
|
|||||||
case "java.lang.Float":
|
case "java.lang.Float":
|
||||||
il.append(new FSTORE(counterAssign));
|
il.append(new FSTORE(counterAssign));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case "java.lang.Long":
|
||||||
|
il.append(new LSTORE(counterAssign));
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
return il;
|
return il;
|
||||||
|
@ -5,6 +5,9 @@ package de.dhbwstuttgart.syntaxtree.statement;
|
|||||||
import java.util.Hashtable;
|
import java.util.Hashtable;
|
||||||
|
|
||||||
import org.apache.bcel.generic.ClassGen;
|
import org.apache.bcel.generic.ClassGen;
|
||||||
|
import org.apache.bcel.generic.ConstantPoolGen;
|
||||||
|
import org.apache.bcel.generic.InstructionList;
|
||||||
|
import org.apache.bcel.generic.LDC2_W;
|
||||||
|
|
||||||
import de.dhbwstuttgart.typeinference.Menge;
|
import de.dhbwstuttgart.typeinference.Menge;
|
||||||
import de.dhbwstuttgart.logger.Logger;
|
import de.dhbwstuttgart.logger.Logger;
|
||||||
@ -125,9 +128,15 @@ public JavaCodeResult printJavaCode(ResultSet resultSet) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void genByteCode(ClassGen _cg) {
|
public InstructionList genByteCode(ClassGen cg) {
|
||||||
// TODO Auto-generated method stub
|
ConstantPoolGen cp = cg.getConstantPool();
|
||||||
|
//InstructionFactory _factory = new InstructionFactory(cg, cp);
|
||||||
|
InstructionList il = new InstructionList();
|
||||||
|
|
||||||
|
cp.addLong(get_Long());
|
||||||
|
il.append(new LDC2_W(cp.getSize()-1));
|
||||||
|
return il;
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// ino.end
|
// ino.end
|
||||||
|
6
test/bytecode/LongLiteral.jav
Normal file
6
test/bytecode/LongLiteral.jav
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
class LongLiteral{
|
||||||
|
|
||||||
|
void method() {l; l = 20L;}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
45
test/bytecode/LongLiteral.java
Normal file
45
test/bytecode/LongLiteral.java
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
package bytecode;
|
||||||
|
|
||||||
|
import static org.junit.Assert.*;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
|
import junit.framework.TestCase;
|
||||||
|
|
||||||
|
import org.junit.Test;
|
||||||
|
|
||||||
|
import plugindevelopment.TypeInsertTester;
|
||||||
|
import de.dhbwstuttgart.core.MyCompiler;
|
||||||
|
import de.dhbwstuttgart.core.MyCompilerAPI;
|
||||||
|
import de.dhbwstuttgart.logger.LoggerConfiguration;
|
||||||
|
import de.dhbwstuttgart.logger.Section;
|
||||||
|
import de.dhbwstuttgart.parser.JavaParser.yyException;
|
||||||
|
import de.dhbwstuttgart.typeinference.ByteCodeResult;
|
||||||
|
import de.dhbwstuttgart.typeinference.Menge;
|
||||||
|
import de.dhbwstuttgart.typeinference.TypeinferenceResultSet;
|
||||||
|
import de.dhbwstuttgart.typeinference.typedeployment.TypeInsertSet;
|
||||||
|
|
||||||
|
public class LongLiteral {
|
||||||
|
|
||||||
|
public final static String rootDirectory = System.getProperty("user.dir")+"/test/bytecode/";
|
||||||
|
public final static String testFile = "LongLiteral.jav";
|
||||||
|
public final static String outputFile = "LongLiteral.class";
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void test() {
|
||||||
|
LoggerConfiguration logConfig = new LoggerConfiguration().setOutput(Section.PARSER, System.out);
|
||||||
|
MyCompilerAPI compiler = MyCompiler.getAPI(logConfig);
|
||||||
|
try {
|
||||||
|
compiler.parse(new File(rootDirectory + testFile));
|
||||||
|
compiler.typeReconstruction();
|
||||||
|
ByteCodeResult bytecode = compiler.generateBytecode();
|
||||||
|
System.out.println(bytecode);
|
||||||
|
bytecode.getByteCode().getJavaClass().dump(new File(rootDirectory + outputFile));
|
||||||
|
} catch (IOException | yyException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
TestCase.fail();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user