parserPostProcessing implementiert
This commit is contained in:
parent
8cbd22f562
commit
605c554ffb
@ -694,12 +694,12 @@ extendsinterfaces : EXTENDS interfacetype
|
|||||||
classbodydeclarations : classbodydeclaration
|
classbodydeclarations : classbodydeclaration
|
||||||
{
|
{
|
||||||
ClassBody CB = new ClassBody();
|
ClassBody CB = new ClassBody();
|
||||||
CB.set_FieldDecl( $1 );
|
CB.addField( $1 );
|
||||||
$$=CB;
|
$$=CB;
|
||||||
}
|
}
|
||||||
| classbodydeclarations classbodydeclaration
|
| classbodydeclarations classbodydeclaration
|
||||||
{
|
{
|
||||||
$1.set_FieldDecl($2);
|
$1.addField($2);
|
||||||
$$ = $1;
|
$$ = $1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
File diff suppressed because one or more lines are too long
@ -5,9 +5,11 @@ package mycompiler;
|
|||||||
|
|
||||||
// ino.module.AClassOrInterface.8526.import
|
// ino.module.AClassOrInterface.8526.import
|
||||||
import java.util.Vector;
|
import java.util.Vector;
|
||||||
|
|
||||||
import mycompiler.myclass.UsedId;
|
import mycompiler.myclass.UsedId;
|
||||||
import mycompiler.myexception.JVMCodeException;
|
import mycompiler.myexception.JVMCodeException;
|
||||||
import mycompiler.mymodifier.Modifiers;
|
import mycompiler.mymodifier.Modifiers;
|
||||||
|
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
// ino.end
|
// ino.end
|
||||||
|
|
||||||
@ -21,14 +23,17 @@ import org.apache.log4j.Logger;
|
|||||||
*/
|
*/
|
||||||
// ino.end
|
// ino.end
|
||||||
// ino.class.AClassOrInterface.21186.declaration
|
// ino.class.AClassOrInterface.21186.declaration
|
||||||
public abstract class AClassOrInterface
|
public interface AClassOrInterface
|
||||||
// ino.end
|
// ino.end
|
||||||
// ino.class.AClassOrInterface.21186.body
|
// ino.class.AClassOrInterface.21186.body
|
||||||
{
|
{
|
||||||
|
|
||||||
|
public String getName();
|
||||||
|
public Vector<UsedId> getSuperInterfaces();
|
||||||
|
public void setSuperInterfaces(Vector<UsedId> vector);
|
||||||
|
|
||||||
|
/*
|
||||||
// ino.attribute.inferencelog.21189.decldescription type=javadoc
|
// ino.attribute.inferencelog.21189.decldescription type=javadoc
|
||||||
/**
|
|
||||||
* Log4j - Loggerinstanzen
|
|
||||||
*/
|
|
||||||
// ino.end
|
// ino.end
|
||||||
// ino.attribute.inferencelog.21189.declaration
|
// ino.attribute.inferencelog.21189.declaration
|
||||||
protected static Logger inferencelog = Logger.getLogger("inference");
|
protected static Logger inferencelog = Logger.getLogger("inference");
|
||||||
@ -151,9 +156,6 @@ public abstract class AClassOrInterface
|
|||||||
// ino.end
|
// ino.end
|
||||||
|
|
||||||
// ino.method.getAccessFlags.21237.defdescription type=javadoc
|
// ino.method.getAccessFlags.21237.defdescription type=javadoc
|
||||||
/**
|
|
||||||
* Liefert die AccessFlags fuer den Bytecode zurueck.
|
|
||||||
*/
|
|
||||||
// ino.end
|
// ino.end
|
||||||
// ino.method.getAccessFlags.21237.definition
|
// ino.method.getAccessFlags.21237.definition
|
||||||
public short getAccessFlags()
|
public short getAccessFlags()
|
||||||
@ -197,5 +199,6 @@ public abstract class AClassOrInterface
|
|||||||
public abstract void codegen(SourceFile sf)
|
public abstract void codegen(SourceFile sf)
|
||||||
throws JVMCodeException;
|
throws JVMCodeException;
|
||||||
// ino.end
|
// ino.end
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
// ino.end
|
// ino.end
|
||||||
|
@ -479,7 +479,6 @@ public class MyCompiler implements MyCompilerAPI
|
|||||||
// ino.end
|
// ino.end
|
||||||
// ino.method.init.21295.body
|
// ino.method.init.21295.body
|
||||||
{
|
{
|
||||||
m_AbstractSyntaxTree = null;
|
|
||||||
TypePlaceholder.deleteRegistry();
|
TypePlaceholder.deleteRegistry();
|
||||||
|
|
||||||
// Log4J fuer die Ausgabe vorbereiten
|
// Log4J fuer die Ausgabe vorbereiten
|
||||||
|
@ -51,7 +51,7 @@ import typinferenz.assumptions.TypeAssumptions;
|
|||||||
|
|
||||||
// ino.class.SourceFile.21355.declaration
|
// ino.class.SourceFile.21355.declaration
|
||||||
public class SourceFile
|
public class SourceFile
|
||||||
implements SyntaxTreeNode
|
extends SyntaxTreeNode
|
||||||
// ino.end
|
// ino.end
|
||||||
// ino.class.SourceFile.21355.body
|
// ino.class.SourceFile.21355.body
|
||||||
{
|
{
|
||||||
@ -316,7 +316,6 @@ public class SourceFile
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} // Schleifenende durch Klassenvektor
|
} // Schleifenende durch Klassenvektor
|
||||||
|
|
||||||
for(int i=0; i<InterfaceVektor.size();i++){
|
for(int i=0; i<InterfaceVektor.size();i++){
|
||||||
Interface intf= InterfaceVektor.get(i);
|
Interface intf= InterfaceVektor.get(i);
|
||||||
if(intf.getSuperInterfaces()!=null){
|
if(intf.getSuperInterfaces()!=null){
|
||||||
@ -330,7 +329,6 @@ public class SourceFile
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Vector tto = (Vector)vFC.clone();
|
Vector tto = (Vector)vFC.clone();
|
||||||
|
|
||||||
Unify.printMenge( "FC", vFC, 6 );
|
Unify.printMenge( "FC", vFC, 6 );
|
||||||
@ -1505,6 +1503,7 @@ public class SourceFile
|
|||||||
@Override
|
@Override
|
||||||
public void parserPostProcessing(SyntaxTreeNode parent) {
|
public void parserPostProcessing(SyntaxTreeNode parent) {
|
||||||
if(parent!=null)throw new TypinferenzException("Eine SourceFile hat keine Elternelement im Syntaxbaum");
|
if(parent!=null)throw new TypinferenzException("Eine SourceFile hat keine Elternelement im Syntaxbaum");
|
||||||
|
for(SyntaxTreeNode node : this.getChildren())node.parserPostProcessing(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -1517,8 +1516,11 @@ public class SourceFile
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Vector<SyntaxTreeNode> getChildren() {
|
public Vector<SyntaxTreeNode> getChildren() {
|
||||||
// TODO Auto-generated method stub
|
Vector<SyntaxTreeNode> ret = super.getChildren();
|
||||||
return null;
|
for(Class cl : this.KlassenVektor){
|
||||||
|
ret.add(cl);
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -2,7 +2,9 @@ package mycompiler;
|
|||||||
|
|
||||||
import java.util.Vector;
|
import java.util.Vector;
|
||||||
|
|
||||||
public interface SyntaxTreeNode {
|
public abstract class SyntaxTreeNode {
|
||||||
|
|
||||||
|
private SyntaxTreeNode parent;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Wird nach dem Parsen aufgerufen.
|
* Wird nach dem Parsen aufgerufen.
|
||||||
@ -11,8 +13,16 @@ public interface SyntaxTreeNode {
|
|||||||
* 2. Verknüpft die Knoten des Syntaxbaums. (setzt Parent)
|
* 2. Verknüpft die Knoten des Syntaxbaums. (setzt Parent)
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public void parserPostProcessing(SyntaxTreeNode parent);
|
public void parserPostProcessing(SyntaxTreeNode parent) {
|
||||||
|
this.parent = parent;
|
||||||
public SyntaxTreeNode getParent();
|
for(SyntaxTreeNode node : this.getChildren())node.parserPostProcessing(this);
|
||||||
public Vector<SyntaxTreeNode> getChildren();
|
}
|
||||||
|
|
||||||
|
public SyntaxTreeNode getParent() {
|
||||||
|
return this.parent;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Vector<SyntaxTreeNode> getChildren(){
|
||||||
|
return new Vector<SyntaxTreeNode>();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -53,6 +53,7 @@ import org.apache.log4j.Logger;
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
import sun.reflect.generics.reflectiveObjects.NotImplementedException;
|
import sun.reflect.generics.reflectiveObjects.NotImplementedException;
|
||||||
import typinferenz.ConstraintsSet;
|
import typinferenz.ConstraintsSet;
|
||||||
import typinferenz.JavaCodeResult;
|
import typinferenz.JavaCodeResult;
|
||||||
@ -66,10 +67,66 @@ import typinferenz.assumptions.TypeAssumptions;
|
|||||||
|
|
||||||
|
|
||||||
// ino.class.Class.23010.declaration
|
// ino.class.Class.23010.declaration
|
||||||
public class Class extends AClassOrInterface implements SyntaxTreeNode
|
public class Class extends SyntaxTreeNode implements AClassOrInterface
|
||||||
// ino.end
|
// ino.end
|
||||||
// ino.class.Class.23010.body
|
// ino.class.Class.23010.body
|
||||||
{
|
{
|
||||||
|
/**
|
||||||
|
* Log4j - Loggerinstanzen
|
||||||
|
*/
|
||||||
|
protected static Logger inferencelog = Logger.getLogger("inference");
|
||||||
|
protected static Logger codegenlog = Logger.getLogger("codegen");
|
||||||
|
protected static Logger parserlog = Logger.getLogger("parser");
|
||||||
|
protected UsedId pkgName;
|
||||||
|
protected Modifiers modifiers;
|
||||||
|
protected String name;
|
||||||
|
|
||||||
|
private Vector<UsedId> superif = new Vector<UsedId>();
|
||||||
|
|
||||||
|
public UsedId getPackageName()
|
||||||
|
{
|
||||||
|
return pkgName;
|
||||||
|
}
|
||||||
|
public void setPackageName(UsedId pkgName)
|
||||||
|
{
|
||||||
|
this.pkgName = pkgName;
|
||||||
|
}
|
||||||
|
public String getName()
|
||||||
|
{
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
public void setName(String strName)
|
||||||
|
{
|
||||||
|
name = strName;
|
||||||
|
}
|
||||||
|
public void setModifiers(Modifiers mod)
|
||||||
|
{
|
||||||
|
this.modifiers = mod;
|
||||||
|
}
|
||||||
|
public Modifiers getModifiers()
|
||||||
|
{
|
||||||
|
return this.modifiers;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Liefert die AccessFlags fuer den Bytecode zurueck.
|
||||||
|
*/
|
||||||
|
public short getAccessFlags()
|
||||||
|
{
|
||||||
|
short ret = 0;
|
||||||
|
if (modifiers != null) {
|
||||||
|
ret = modifiers.calculate_access_flags();
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
public Vector<UsedId> getSuperInterfaces()
|
||||||
|
{
|
||||||
|
return superif;
|
||||||
|
}
|
||||||
|
public void setSuperInterfaces(Vector<UsedId> superif)
|
||||||
|
{
|
||||||
|
this.superif = superif;
|
||||||
|
}
|
||||||
|
|
||||||
// ino.attribute.superclassid.23014.decldescription type=line
|
// ino.attribute.superclassid.23014.decldescription type=line
|
||||||
// private Status status;
|
// private Status status;
|
||||||
// ino.end
|
// ino.end
|
||||||
@ -123,7 +180,7 @@ public class Class extends AClassOrInterface implements SyntaxTreeNode
|
|||||||
// ino.end
|
// ino.end
|
||||||
// ino.method.Class.23041.body
|
// ino.method.Class.23041.body
|
||||||
{
|
{
|
||||||
super(name);
|
this.name = name;
|
||||||
if(name.equals("java.lang.Object")){
|
if(name.equals("java.lang.Object")){
|
||||||
superclassid=null;
|
superclassid=null;
|
||||||
}
|
}
|
||||||
@ -135,7 +192,8 @@ public class Class extends AClassOrInterface implements SyntaxTreeNode
|
|||||||
// ino.end
|
// ino.end
|
||||||
// ino.method.Class.23044.body
|
// ino.method.Class.23044.body
|
||||||
{
|
{
|
||||||
super(name, mod);
|
this.name = name;
|
||||||
|
this.modifiers = mod;
|
||||||
if(name.equals("java.lang.Object")){
|
if(name.equals("java.lang.Object")){
|
||||||
superclassid=null;
|
superclassid=null;
|
||||||
}
|
}
|
||||||
@ -154,7 +212,8 @@ public class Class extends AClassOrInterface implements SyntaxTreeNode
|
|||||||
// ino.end
|
// ino.end
|
||||||
// ino.method.Class.23047.body
|
// ino.method.Class.23047.body
|
||||||
{
|
{
|
||||||
super(name, mod);
|
this.name = name;
|
||||||
|
this.modifiers = mod;
|
||||||
if (cb != null) set_ClassBody(cb);
|
if (cb != null) set_ClassBody(cb);
|
||||||
if (ct != null) setContainedTypes(ct);
|
if (ct != null) setContainedTypes(ct);
|
||||||
if (superclass != null) set_UsedId(superclass);
|
if (superclass != null) set_UsedId(superclass);
|
||||||
@ -522,7 +581,7 @@ public class Class extends AClassOrInterface implements SyntaxTreeNode
|
|||||||
|
|
||||||
//Generiere Liste mit Expressions, welche zur Initialisierung von Feldern verwendet werden.
|
//Generiere Liste mit Expressions, welche zur Initialisierung von Feldern verwendet werden.
|
||||||
Vector<Expr> fieldInitializers = new Vector<Expr>();
|
Vector<Expr> fieldInitializers = new Vector<Expr>();
|
||||||
for(FieldInitialization field : body.getFieldInitializations()){
|
for(FieldDeclaration field : body.getFieldInitializations()){
|
||||||
Assign fieldAssign = new Assign(0,0);
|
Assign fieldAssign = new Assign(0,0);
|
||||||
Expr expr1 = new LocalOrFieldVar(field.getName(), 0);
|
Expr expr1 = new LocalOrFieldVar(field.getName(), 0);
|
||||||
Expr expr2 = field.getWert();
|
Expr expr2 = field.getWert();
|
||||||
@ -1134,6 +1193,7 @@ public class Class extends AClassOrInterface implements SyntaxTreeNode
|
|||||||
@Override
|
@Override
|
||||||
public void parserPostProcessing(SyntaxTreeNode parent) {
|
public void parserPostProcessing(SyntaxTreeNode parent) {
|
||||||
this.parent = parent;
|
this.parent = parent;
|
||||||
|
for(SyntaxTreeNode node : this.getChildren())node.parserPostProcessing(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -1143,8 +1203,11 @@ public class Class extends AClassOrInterface implements SyntaxTreeNode
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Vector<SyntaxTreeNode> getChildren() {
|
public Vector<SyntaxTreeNode> getChildren() {
|
||||||
// TODO Auto-generated method stub
|
Vector<SyntaxTreeNode> ret = new Vector<SyntaxTreeNode>();
|
||||||
return null;
|
for(Field f : this.body.getFields()){
|
||||||
|
ret.add(f);
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -92,23 +92,20 @@ Paratyp gesetzt."); }
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
// ino.method.get_FieldDeclVector.23182.definition
|
|
||||||
public Vector<Field> getFields()
|
public Vector<Field> getFields()
|
||||||
// ino.end
|
|
||||||
// ino.method.get_FieldDeclVector.23182.body
|
|
||||||
{
|
{
|
||||||
return fielddecl;
|
return fielddecl;
|
||||||
}
|
}
|
||||||
// ino.end
|
|
||||||
|
|
||||||
// ino.method.set_FieldDecl.23185.definition
|
/**
|
||||||
public void set_FieldDecl(Field i)
|
* @author Andreas Stadelmeier, a10023
|
||||||
// ino.end
|
* Fügt der Klasse eine Feld hinzu.
|
||||||
// ino.method.set_FieldDecl.23185.body
|
* @param feld
|
||||||
|
*/
|
||||||
|
public void addField(Field i)
|
||||||
{
|
{
|
||||||
fielddecl.addElement(i);
|
fielddecl.addElement(i);
|
||||||
}
|
}
|
||||||
// ino.end
|
|
||||||
|
|
||||||
// ino.method.is_declared.23188.defdescription type=line
|
// ino.method.is_declared.23188.defdescription type=line
|
||||||
//
|
//
|
||||||
@ -364,19 +361,8 @@ public void istParameterOK( Vector Parameter, Vector<Class> KlassenVektor )
|
|||||||
|
|
||||||
private Vector<FieldInitialization> fieldInitialisations = new Vector<FieldInitialization>();
|
private Vector<FieldInitialization> fieldInitialisations = new Vector<FieldInitialization>();
|
||||||
|
|
||||||
/**
|
|
||||||
* @author Andreas Stadelmeier, a10023
|
|
||||||
* Fügt der Klasse eine Feldinitialisation hinzu.
|
|
||||||
* Eine Feldinitialisation steht für eine Felddeklaration mit gleichzeitiger Wertzuweisung
|
|
||||||
* Beispiel: 'public Feld FeldVar = FeldWert;'
|
|
||||||
* @param feld
|
|
||||||
*/
|
|
||||||
public void addFieldInitialization(FieldInitialization feld) {
|
|
||||||
this.fieldInitialisations.add(feld);
|
|
||||||
}
|
|
||||||
public Vector<FieldInitialization> getFieldInitializations(){
|
|
||||||
return this.fieldInitialisations;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public JavaCodeResult printJavaCode(ResultSet resultSet) {
|
public JavaCodeResult printJavaCode(ResultSet resultSet) {
|
||||||
@ -386,5 +372,16 @@ public void istParameterOK( Vector Parameter, Vector<Class> KlassenVektor )
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
|
public Vector<FieldDeclaration> getFieldInitializations() {
|
||||||
|
Vector<FieldDeclaration> ret = new Vector<FieldDeclaration>();
|
||||||
|
for(Field f:this.getFields()){
|
||||||
|
if(f instanceof FieldDeclaration)ret.add((FieldDeclaration)f);
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
// ino.end
|
// ino.end
|
||||||
|
@ -13,12 +13,14 @@ import typinferenz.Typeable;
|
|||||||
import typinferenz.TypeInsertable;
|
import typinferenz.TypeInsertable;
|
||||||
import typinferenz.assumptions.TypeAssumptions;
|
import typinferenz.assumptions.TypeAssumptions;
|
||||||
|
|
||||||
public abstract class Field implements TypeInsertable, Typeable, SyntaxTreeNode{
|
public abstract class Field extends SyntaxTreeNode implements TypeInsertable, Typeable{
|
||||||
// ino.attribute.declid.23370.declaration
|
|
||||||
protected Vector<DeclId> declid = new Vector<DeclId>(); // Vector, da 'int a, b, c, ...' auch eingeparst werden muss
|
protected Vector<DeclId> declid = new Vector<DeclId>(); // Vector, da 'int a, b, c, ...' auch eingeparst werden muss
|
||||||
|
|
||||||
private Type typ;
|
private Type typ;
|
||||||
|
|
||||||
|
private SyntaxTreeNode parent;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setType(Type typ) {
|
public void setType(Type typ) {
|
||||||
this.typ = typ;
|
this.typ = typ;
|
||||||
@ -28,52 +30,34 @@ public abstract class Field implements TypeInsertable, Typeable, SyntaxTreeNode{
|
|||||||
return typ;
|
return typ;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ino.method.codegen.23376.declaration
|
|
||||||
public abstract void codegen(ClassFile classfile, Vector paralist)
|
public abstract void codegen(ClassFile classfile, Vector paralist)
|
||||||
throws JVMCodeException;
|
throws JVMCodeException;
|
||||||
// ino.end
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// ino.method.set_DeclId.23379.definition
|
|
||||||
public void set_DeclId(DeclId did)
|
public void set_DeclId(DeclId did)
|
||||||
// ino.end
|
|
||||||
// ino.method.set_DeclId.23379.body
|
|
||||||
{
|
{
|
||||||
this.declid.addElement(did);
|
this.declid.addElement(did);
|
||||||
}
|
}
|
||||||
// ino.end
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// ino.method.get_Name.23382.definition
|
|
||||||
public Vector<DeclId> get_Name()
|
public Vector<DeclId> get_Name()
|
||||||
// ino.end
|
|
||||||
// ino.method.get_Name.23382.body
|
|
||||||
{
|
{
|
||||||
return declid;
|
return declid;
|
||||||
}
|
}
|
||||||
// ino.end
|
|
||||||
|
|
||||||
// ino.method.getDeclIdVector.23385.definition
|
|
||||||
public Vector<DeclId> getDeclIdVector()
|
public Vector<DeclId> getDeclIdVector()
|
||||||
// ino.end
|
|
||||||
// ino.method.getDeclIdVector.23385.body
|
|
||||||
{
|
{
|
||||||
// otth: ganzer Vektor zur<EFBFBD>ckgeben, um ihn zu kopieren (vgl. MyCompiler - Konstruktor in Methode umwandeln)
|
// otth: ganzer Vektor zur<EFBFBD>ckgeben, um ihn zu kopieren (vgl. MyCompiler - Konstruktor in Methode umwandeln)
|
||||||
return declid;
|
return declid;
|
||||||
}
|
}
|
||||||
// ino.end
|
|
||||||
|
|
||||||
// ino.method.setDeclIdVector.23388.definition
|
|
||||||
public void setDeclIdVector( Vector<DeclId> vDeclId )
|
public void setDeclIdVector( Vector<DeclId> vDeclId )
|
||||||
// ino.end
|
|
||||||
// ino.method.setDeclIdVector.23388.body
|
|
||||||
{
|
{
|
||||||
// otth: kompletter Vektor setzen, um ihn zu kopieren (vgl. MyCompiler - Konstruktor in Methode umwandeln)
|
// otth: kompletter Vektor setzen, um ihn zu kopieren (vgl. MyCompiler - Konstruktor in Methode umwandeln)
|
||||||
declid = vDeclId;
|
declid = vDeclId;
|
||||||
}
|
}
|
||||||
// ino.end
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -86,4 +70,6 @@ public abstract class Field implements TypeInsertable, Typeable, SyntaxTreeNode{
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public abstract TypeAssumptions createTypeAssumptions(Class classmember);
|
public abstract TypeAssumptions createTypeAssumptions(Class classmember);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -2,15 +2,24 @@ package mycompiler.myclass;
|
|||||||
|
|
||||||
import java.util.Vector;
|
import java.util.Vector;
|
||||||
|
|
||||||
|
|
||||||
import typinferenz.JavaCodeResult;
|
import typinferenz.JavaCodeResult;
|
||||||
import typinferenz.ResultSet;
|
import typinferenz.ResultSet;
|
||||||
import typinferenz.assumptions.TypeAssumptions;
|
import typinferenz.assumptions.TypeAssumptions;
|
||||||
|
import mycompiler.SyntaxTreeNode;
|
||||||
import mycompiler.mybytecode.ClassFile;
|
import mycompiler.mybytecode.ClassFile;
|
||||||
import mycompiler.myexception.JVMCodeException;
|
import mycompiler.myexception.JVMCodeException;
|
||||||
import mycompiler.mystatement.Expr;
|
import mycompiler.mystatement.Expr;
|
||||||
import mycompiler.mytype.Type;
|
import mycompiler.mytype.Type;
|
||||||
|
import mycompiler.mytype.TypePlaceholder;
|
||||||
import mycompiler.mytypereconstruction.replacementlistener.CReplaceTypeEvent;
|
import mycompiler.mytypereconstruction.replacementlistener.CReplaceTypeEvent;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Eine Feldinitialisation steht für eine Felddeklaration mit gleichzeitiger Wertzuweisung
|
||||||
|
* Beispiel: 'public Feld FeldVar = FeldWert;'
|
||||||
|
* @author janulrich
|
||||||
|
*
|
||||||
|
*/
|
||||||
public class FieldDeclaration extends Field{
|
public class FieldDeclaration extends Field{
|
||||||
|
|
||||||
private Expr wert;
|
private Expr wert;
|
||||||
@ -27,18 +36,6 @@ public class FieldDeclaration extends Field{
|
|||||||
return this.get_Name().elementAt(0).name;
|
return this.get_Name().elementAt(0).name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void replaceType(CReplaceTypeEvent e) {
|
|
||||||
// TODO Auto-generated method stub
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getTypeLineNumber() {
|
|
||||||
// TODO Auto-generated method stub
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void codegen(ClassFile classfile, Vector paralist)
|
public void codegen(ClassFile classfile, Vector paralist)
|
||||||
throws JVMCodeException {
|
throws JVMCodeException {
|
||||||
@ -47,15 +44,57 @@ public class FieldDeclaration extends Field{
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
public String toString()
|
||||||
|
{
|
||||||
|
return super.toString() + "=" + getWert().toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public JavaCodeResult printJavaCode(ResultSet resultSet) {
|
public JavaCodeResult printJavaCode(ResultSet resultSet) {
|
||||||
// TODO Auto-generated method stub
|
JavaCodeResult ret = new JavaCodeResult();
|
||||||
return null;
|
ret.attach(this.getType().printJavaCode(resultSet)).attach( " ").attach( this.getName()+" = ").attach(this.getWert().printJavaCode(resultSet) ).attach( ";");
|
||||||
|
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public TypeAssumptions createTypeAssumptions(Class classmember) {
|
public TypeAssumptions createTypeAssumptions(Class classmember) {
|
||||||
|
//////////////////////////////
|
||||||
|
//Felder:
|
||||||
|
//////////////////////////////
|
||||||
|
|
||||||
|
TypeAssumptions assumptions = new TypeAssumptions();
|
||||||
|
/*
|
||||||
|
* TODO: Der Feld-Assumption muss ein TPH als Typ hinzugefügt werden, falls er Typlos initialisiert wurde. Dies kann auch der Type-Algorithmus der Inst/FieldVar - Klasse machen.
|
||||||
|
* Wird das Feld mit einem Typ initialisiert so muss dieser auch in die Assumptions.
|
||||||
|
*/
|
||||||
|
if(this.getType() == null)this.setType(TypePlaceholder.fresh(this));
|
||||||
|
assumptions.add(TypeAssumptions.createFieldVarAssumption(classmember.getName(), this.getName(), this.getType()));
|
||||||
|
return assumptions;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void parserPostProcessing(SyntaxTreeNode parent){
|
||||||
|
super.parserPostProcessing(parent);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Vector<SyntaxTreeNode> getChildren() {
|
||||||
|
Vector<SyntaxTreeNode> ret = new Vector<SyntaxTreeNode>();
|
||||||
|
ret.add(this.wert);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void replaceType(CReplaceTypeEvent e) {
|
||||||
// TODO Auto-generated method stub
|
// TODO Auto-generated method stub
|
||||||
return null;
|
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
public int getTypeLineNumber() {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -80,7 +80,7 @@ public class FieldInitialization extends InstVarDecl {
|
|||||||
*/
|
*/
|
||||||
if(this.getType() == null)this.setType(TypePlaceholder.fresh(this));
|
if(this.getType() == null)this.setType(TypePlaceholder.fresh(this));
|
||||||
assumptions.add(TypeAssumptions.createFieldVarAssumption(classmember.getName(), this.getName(), this.getType()));
|
assumptions.add(TypeAssumptions.createFieldVarAssumption(classmember.getName(), this.getName(), this.getType()));
|
||||||
classmember.get_ClassBody().addFieldInitialization(this);
|
classmember.get_ClassBody().addField(this);
|
||||||
return assumptions;
|
return assumptions;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -8,6 +8,7 @@ import java.util.Iterator;
|
|||||||
import java.util.Vector;
|
import java.util.Vector;
|
||||||
|
|
||||||
import mycompiler.IItemWithOffset;
|
import mycompiler.IItemWithOffset;
|
||||||
|
import mycompiler.SyntaxTreeNode;
|
||||||
import mycompiler.mybytecode.ClassFile;
|
import mycompiler.mybytecode.ClassFile;
|
||||||
import mycompiler.MyCompiler;
|
import mycompiler.MyCompiler;
|
||||||
import mycompiler.myexception.JVMCodeException;
|
import mycompiler.myexception.JVMCodeException;
|
||||||
@ -650,5 +651,30 @@ public class Method extends Field implements ITypeReplacementListener, IItemWith
|
|||||||
return assumptions;
|
return assumptions;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void parserPostProcessing(SyntaxTreeNode parent){
|
||||||
|
super.parserPostProcessing(parent);
|
||||||
|
if(this.getType()==null)this.setType(TypePlaceholder.fresh(this));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Vector<SyntaxTreeNode> getChildren() {
|
||||||
|
Vector<SyntaxTreeNode> ret = super.getChildren();
|
||||||
|
ret.add(this.block);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setType(Type t){
|
||||||
|
// Methode und Block teilen sich einen ReturnType:
|
||||||
|
this.block.setType(t);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Type getType(){
|
||||||
|
//Methode und Block teilen sich einen ReturnType:
|
||||||
|
return this.block.getType();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
// ino.end
|
// ino.end
|
||||||
|
@ -4,6 +4,7 @@ package mycompiler.myinterface;
|
|||||||
|
|
||||||
// ino.module.Interface.8582.import
|
// ino.module.Interface.8582.import
|
||||||
import java.util.Vector;
|
import java.util.Vector;
|
||||||
|
|
||||||
import mycompiler.AClassOrInterface;
|
import mycompiler.AClassOrInterface;
|
||||||
import mycompiler.mybytecode.ClassFile;
|
import mycompiler.mybytecode.ClassFile;
|
||||||
import mycompiler.myclass.ClassHelper;
|
import mycompiler.myclass.ClassHelper;
|
||||||
@ -11,6 +12,7 @@ import mycompiler.myclass.Constant;
|
|||||||
import mycompiler.myclass.FormalParameter;
|
import mycompiler.myclass.FormalParameter;
|
||||||
import mycompiler.myclass.Method;
|
import mycompiler.myclass.Method;
|
||||||
import mycompiler.myclass.ParameterList;
|
import mycompiler.myclass.ParameterList;
|
||||||
|
import mycompiler.myclass.UsedId;
|
||||||
import mycompiler.myexception.JVMCodeException;
|
import mycompiler.myexception.JVMCodeException;
|
||||||
import mycompiler.mymodifier.Modifiers;
|
import mycompiler.mymodifier.Modifiers;
|
||||||
import mycompiler.mytype.GenericTypeVar;
|
import mycompiler.mytype.GenericTypeVar;
|
||||||
@ -33,7 +35,7 @@ import mycompiler.SourceFile;
|
|||||||
*/
|
*/
|
||||||
// ino.end
|
// ino.end
|
||||||
// ino.class.Interface.23932.declaration
|
// ino.class.Interface.23932.declaration
|
||||||
public class Interface extends AClassOrInterface
|
public class Interface implements AClassOrInterface
|
||||||
// ino.end
|
// ino.end
|
||||||
// ino.class.Interface.23932.body
|
// ino.class.Interface.23932.body
|
||||||
{
|
{
|
||||||
@ -247,5 +249,9 @@ public class Interface extends AClassOrInterface
|
|||||||
|
|
||||||
}
|
}
|
||||||
// ino.end
|
// ino.end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
// ino.end
|
// ino.end
|
||||||
|
@ -1163,14 +1163,14 @@ case 51:
|
|||||||
// line 695 "./../src/mycompiler/myparser/JavaParser.jay"
|
// line 695 "./../src/mycompiler/myparser/JavaParser.jay"
|
||||||
{
|
{
|
||||||
ClassBody CB = new ClassBody();
|
ClassBody CB = new ClassBody();
|
||||||
CB.set_FieldDecl( ((Field)yyVals[0+yyTop]) );
|
CB.addField( ((Field)yyVals[0+yyTop]) );
|
||||||
yyVal=CB;
|
yyVal=CB;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 52:
|
case 52:
|
||||||
// line 701 "./../src/mycompiler/myparser/JavaParser.jay"
|
// line 701 "./../src/mycompiler/myparser/JavaParser.jay"
|
||||||
{
|
{
|
||||||
((ClassBody)yyVals[-1+yyTop]).set_FieldDecl(((Field)yyVals[0+yyTop]));
|
((ClassBody)yyVals[-1+yyTop]).addField(((Field)yyVals[0+yyTop]));
|
||||||
yyVal = ((ClassBody)yyVals[-1+yyTop]);
|
yyVal = ((ClassBody)yyVals[-1+yyTop]);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -694,12 +694,12 @@ extendsinterfaces : EXTENDS interfacetype
|
|||||||
classbodydeclarations : classbodydeclaration
|
classbodydeclarations : classbodydeclaration
|
||||||
{
|
{
|
||||||
ClassBody CB = new ClassBody();
|
ClassBody CB = new ClassBody();
|
||||||
CB.set_FieldDecl( $1 );
|
CB.addField( $1 );
|
||||||
$$=CB;
|
$$=CB;
|
||||||
}
|
}
|
||||||
| classbodydeclarations classbodydeclaration
|
| classbodydeclarations classbodydeclaration
|
||||||
{
|
{
|
||||||
$1.set_FieldDecl($2);
|
$1.addField($2);
|
||||||
$$ = $1;
|
$$ = $1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -37,7 +37,7 @@ import mycompiler.mytypereconstruction.typeassumption.CTypeAssumption;
|
|||||||
|
|
||||||
|
|
||||||
// ino.class.Statement.26184.declaration
|
// ino.class.Statement.26184.declaration
|
||||||
public abstract class Statement implements IItemWithOffset, Typeable, ITypeReplacementListener, SyntaxTreeNode
|
public abstract class Statement extends SyntaxTreeNode implements IItemWithOffset, Typeable, ITypeReplacementListener
|
||||||
// ino.end
|
// ino.end
|
||||||
// ino.class.Statement.26184.body
|
// ino.class.Statement.26184.body
|
||||||
{
|
{
|
||||||
@ -50,6 +50,7 @@ public abstract class Statement implements IItemWithOffset, Typeable, ITypeRepla
|
|||||||
// ino.end
|
// ino.end
|
||||||
|
|
||||||
protected Type type;
|
protected Type type;
|
||||||
|
private SyntaxTreeNode parent;
|
||||||
|
|
||||||
// ino.method.Statement.26194.definition
|
// ino.method.Statement.26194.definition
|
||||||
public Statement(int offset, int variableLength)
|
public Statement(int offset, int variableLength)
|
||||||
@ -145,5 +146,6 @@ public abstract class Statement implements IItemWithOffset, Typeable, ITypeRepla
|
|||||||
public abstract JavaCodeResult printJavaCode(ResultSet resultSet);
|
public abstract JavaCodeResult printJavaCode(ResultSet resultSet);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
// ino.end
|
// ino.end
|
||||||
|
@ -6,6 +6,8 @@ package mycompiler.mytype;
|
|||||||
import java.util.Vector;
|
import java.util.Vector;
|
||||||
// ino.end
|
// ino.end
|
||||||
|
|
||||||
|
|
||||||
|
import mycompiler.mytypereconstruction.replacementlistener.ITypeReplacementListener;
|
||||||
import typinferenz.JavaCodeResult;
|
import typinferenz.JavaCodeResult;
|
||||||
import typinferenz.ResultSet;
|
import typinferenz.ResultSet;
|
||||||
|
|
||||||
@ -131,6 +133,7 @@ public class GenericTypeVar extends Type
|
|||||||
}
|
}
|
||||||
return new JavaCodeResult(this.name);
|
return new JavaCodeResult(this.name);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
// ino.end
|
// ino.end
|
||||||
|
|
||||||
|
@ -162,13 +162,17 @@ public class RefType extends Type implements IMatchable
|
|||||||
}
|
}
|
||||||
// ino.end
|
// ino.end
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Wandelt die Parameter des RefTypes in TPHs um, sofern es sich um Generische Variablen handelt.
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
// ino.method.GenericTypeVar2TypePlaceholder.26652.definition
|
// ino.method.GenericTypeVar2TypePlaceholder.26652.definition
|
||||||
public CSubstitutionSet GenericTypeVar2TypePlaceholder ()
|
public CSubstitutionSet GenericTypeVar2TypePlaceholder ()
|
||||||
// ino.end
|
// ino.end
|
||||||
// ino.method.GenericTypeVar2TypePlaceholder.26652.body
|
// ino.method.GenericTypeVar2TypePlaceholder.26652.body
|
||||||
{
|
{
|
||||||
throw new NotImplementedException();
|
//throw new NotImplementedException();
|
||||||
/*
|
///*
|
||||||
CSubstitutionSet sub = new CSubstitutionSet();
|
CSubstitutionSet sub = new CSubstitutionSet();
|
||||||
if(parameter != null)
|
if(parameter != null)
|
||||||
{
|
{
|
||||||
@ -176,7 +180,7 @@ public class RefType extends Type implements IMatchable
|
|||||||
{
|
{
|
||||||
if (parameter.elementAt(i) instanceof GenericTypeVar)
|
if (parameter.elementAt(i) instanceof GenericTypeVar)
|
||||||
{
|
{
|
||||||
TypePlaceholder tlv = TypePlaceholder.fresh();
|
TypePlaceholder tlv = TypePlaceholder.fresh(); //TODO: Hier wird ein TypePlaceholder ohne ITypeReplacementListener erstellt. Kann Probleme verursachen
|
||||||
sub.addElement(new CSubstitutionGenVar((GenericTypeVar)parameter.elementAt(i), tlv));
|
sub.addElement(new CSubstitutionGenVar((GenericTypeVar)parameter.elementAt(i), tlv));
|
||||||
parameter.set(i, tlv);
|
parameter.set(i, tlv);
|
||||||
}
|
}
|
||||||
@ -188,7 +192,7 @@ public class RefType extends Type implements IMatchable
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
return sub;
|
return sub;
|
||||||
*/
|
//*/
|
||||||
}
|
}
|
||||||
// ino.end
|
// ino.end
|
||||||
|
|
||||||
|
@ -87,7 +87,7 @@ public class TypePlaceholder extends Type implements IReplaceTypeEventProvider
|
|||||||
*/
|
*/
|
||||||
// ino.end
|
// ino.end
|
||||||
// ino.method.fresh.26800.definition
|
// ino.method.fresh.26800.definition
|
||||||
private static TypePlaceholder fresh()
|
public static TypePlaceholder fresh()
|
||||||
// ino.end
|
// ino.end
|
||||||
// ino.method.fresh.26800.body
|
// ino.method.fresh.26800.body
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user