- New Statement, Problem Syntax des Klassennamens

This commit is contained in:
Enrico Schrödter 2016-03-30 10:09:17 +02:00
parent b4d7ab02eb
commit b51079280e
13 changed files with 63 additions and 15 deletions

View File

@ -993,7 +993,7 @@ public class Class extends GTVDeclarationContext implements AClassOrInterface, I
}
@Override
public String getDescription(){
public String getDescription(ClassGenerator cg, TypeinferenceResultSet rs){
return "class "+this.getName();
}
@Override

View File

@ -16,6 +16,7 @@ import de.dhbwstuttgart.typeinference.JavaCodeResult;
import de.dhbwstuttgart.typeinference.ResultSet;
import de.dhbwstuttgart.typeinference.TypeInsertable;
import de.dhbwstuttgart.typeinference.Typeable;
import de.dhbwstuttgart.typeinference.TypeinferenceResultSet;
import de.dhbwstuttgart.typeinference.assumptions.TypeAssumptions;
import de.dhbwstuttgart.typeinference.typedeployment.TypeInsertPoint;
@ -107,7 +108,7 @@ public abstract class Field extends GTVDeclarationContext implements TypeInserta
}
@Override
public String getDescription(){
public String getDescription(ClassGenerator cg, TypeinferenceResultSet rs){
return this.getIdentifier();
}

View File

@ -173,7 +173,7 @@ public class FieldDeclaration extends Field{
*/
public InstructionList genByteCode(ClassGenerator cg, TypeinferenceResultSet rs) {
//Das Feld an die Klasse anfügen:
FieldGen field = new FieldGen(0, this.getType().getBytecodeType(cg, rs), this.getDescription(), cg.getConstantPool());
FieldGen field = new FieldGen(0, this.getType().getBytecodeType(cg, rs), this.getDescription(cg, rs), cg.getConstantPool());
field.addAttribute(cg.getInstructionFactory().createSignatureAttribute(this.getType().getBytecodeSignature(cg, rs)));
cg.addField(field.getField());
@ -183,11 +183,11 @@ public class FieldDeclaration extends Field{
il.append(this.wert.genByteCode(cg, rs));
FieldInstruction putFieldInstruction =
cg.getInstructionFactory().createFieldAccess(this.getParentClass().getName().toString(),
this.getDescription(), this.getType().getBytecodeType(cg, rs), Constants.PUTFIELD);
this.getDescription(cg, rs), this.getType().getBytecodeType(cg, rs), Constants.PUTFIELD);
il.append(putFieldInstruction );
return il;
}
/*@Override
public void genByteCode(ClassGen cg) {
// TODO Auto-generated method stub

View File

@ -4,7 +4,7 @@ package de.dhbwstuttgart.syntaxtree;
// ino.module.FormalParameter.8561.import
import de.dhbwstuttgart.typeinference.Menge;
import de.dhbwstuttgart.bytecode.ClassGenerator;
import de.dhbwstuttgart.logger.Logger;
import de.dhbwstuttgart.syntaxtree.misc.DeclId;
@ -14,6 +14,7 @@ import de.dhbwstuttgart.typeinference.JavaCodeResult;
import de.dhbwstuttgart.typeinference.ResultSet;
import de.dhbwstuttgart.typeinference.TypeInsertable;
import de.dhbwstuttgart.typeinference.Typeable;
import de.dhbwstuttgart.typeinference.TypeinferenceResultSet;
import de.dhbwstuttgart.typeinference.exceptions.NotImplementedException;
import de.dhbwstuttgart.typeinference.exceptions.TypeinferenceException;
import de.dhbwstuttgart.typeinference.typedeployment.TypeInsertPoint;
@ -233,7 +234,7 @@ public class FormalParameter extends SyntaxTreeNode implements Typeable, TypeIns
}
@Override
public String getDescription() {
public String getDescription(ClassGenerator cg, TypeinferenceResultSet rs){
String ret = "";
if(this.getType() != null && !(this.getType() instanceof TypePlaceholder)){
ret += this.getType().getBytecodeSignature(null, null);

View File

@ -3,6 +3,7 @@ package de.dhbwstuttgart.syntaxtree;
import org.apache.commons.bcel6.generic.ClassGen;
import de.dhbwstuttgart.typeinference.Menge;
import de.dhbwstuttgart.bytecode.ClassGenerator;
import de.dhbwstuttgart.core.IItemWithOffset;
import de.dhbwstuttgart.syntaxtree.type.GenericTypeVar;
import de.dhbwstuttgart.syntaxtree.type.Type;
@ -10,6 +11,7 @@ import de.dhbwstuttgart.syntaxtree.type.TypePlaceholder;
import de.dhbwstuttgart.typeinference.Pair;
import de.dhbwstuttgart.typeinference.ResultSet;
import de.dhbwstuttgart.typeinference.TypeInsertable;
import de.dhbwstuttgart.typeinference.TypeinferenceResultSet;
import de.dhbwstuttgart.typeinference.exceptions.DebugException;
import de.dhbwstuttgart.typeinference.exceptions.TypeinferenceException;
import de.dhbwstuttgart.typeinference.typedeployment.GenericTypeInsertPoint;
@ -55,7 +57,7 @@ public abstract class SyntaxTreeNode implements IItemWithOffset{
* Eine Beschreibung/Name des SyntaxTree-Nodes
* @return
*/
public String getDescription(){
public String getDescription(ClassGenerator cg, TypeinferenceResultSet rs){
return this.toString();
}
@ -64,7 +66,7 @@ public abstract class SyntaxTreeNode implements IItemWithOffset{
public boolean equals(Object object){
if(!(object instanceof SyntaxTreeNode))return false;
SyntaxTreeNode equal = (SyntaxTreeNode)object;
if(!equal.getDescription().equals(this.getDescription()))return false;
if(!equal.getDescription(null, null).equals(this.getDescription(null, null)))return false;
if(this.getParent()!=null)
if(!this.getParent().equals(equal.getParent()))return false; //auch das Elternelement überprüfen.
return true;

View File

@ -252,7 +252,7 @@ public class Block extends Statement
}
@Override
public String getDescription(){
public String getDescription(ClassGenerator cg, TypeinferenceResultSet rs){
return "Block";
}

View File

@ -379,7 +379,7 @@ public class LocalVarDecl extends Statement implements TypeInsertable
}
@Override
public String getDescription() {
public String getDescription(ClassGenerator cg, TypeinferenceResultSet rs){
if(this.getType() == null)return "no type " + declid.toString();
if(this.getType() instanceof TypePlaceholder)return declid.toString();
return this.getType().toString() + " " + declid.toString();

View File

@ -202,11 +202,11 @@ public class NewClass extends Expr
if(arglist!=null){
il.append(arglist.generateBytecode(_cg, rs));
il.append(_cg.getInstructionFactory().createInvoke(this.getType().getDescription(), "<init>",
il.append(_cg.getInstructionFactory().createInvoke(this.getType().getDescription(_cg, rs), "<init>",
org.apache.commons.bcel6.generic.Type.VOID,
this.arglist.getBytecodeTypeList(_cg, rs), Constants.INVOKESPECIAL));
}else{
il.append(_cg.getInstructionFactory().createInvoke(this.getType().getDescription(), "<init>",
il.append(_cg.getInstructionFactory().createInvoke(this.getType().getDescription(_cg, rs), "<init>",
org.apache.commons.bcel6.generic.Type.VOID,
new org.apache.commons.bcel6.generic.Type[]{}, Constants.INVOKESPECIAL));
}

View File

@ -119,7 +119,7 @@ public abstract class Statement extends SyntaxTreeNode implements IItemWithOffse
public abstract JavaCodeResult printJavaCode(ResultSet resultSet);
@Override
public String getDescription(){
public String getDescription(ClassGenerator cg, TypeinferenceResultSet rs){
return this.printJavaCode(new ResultSet(new Menge<Pair>())).toString();
}

View File

@ -874,6 +874,13 @@ public class RefType extends ObjectType implements IMatchable
public GenericClassType getGenericClassType(){
return new GenericClassType(getName().toString(), getParaList(), parent, getOffset());
}
@Override
public String getDescription(ClassGenerator cg, TypeinferenceResultSet rs) {
return getBytecodeSignature(cg, rs);
}
}
// ino.end

View File

@ -0,0 +1,3 @@
class Parameter{
public String param;
}

View File

@ -0,0 +1,34 @@
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 ParameterTest {
public final static String rootDirectory = System.getProperty("user.dir")+"/test/bytecode/";
public final static String testFile = "Parameter.jav";
public final static String outputFile = "Parameter.class";
@Test
public void test() {
SingleClassTester.compileToBytecode(rootDirectory+testFile, rootDirectory+outputFile);
}
}

View File

@ -1,6 +1,6 @@
import java.util.Vector;
class AutoOverloadingVector{
class AutoOverloadingVector{
method2(p){
method(p);
}