forked from JavaTX/JavaCompilerCore
311 lines
8.4 KiB
Java
Executable File
311 lines
8.4 KiB
Java
Executable File
// ino.module.DeclId.8558.package
|
||
package mycompiler.myclass;
|
||
// ino.end
|
||
// ino.module.DeclId.8558.import
|
||
import java.util.Vector;
|
||
import mycompiler.mybytecode.Attribute;
|
||
import mycompiler.mybytecode.ClassFile;
|
||
import mycompiler.mybytecode.CodeAttribute;
|
||
import mycompiler.mybytecode.JVMCode;
|
||
import mycompiler.mybytecode.SignatureInfo;
|
||
import mycompiler.MyCompiler;
|
||
import mycompiler.myexception.JVMCodeException;
|
||
import mycompiler.mymodifier.Final;
|
||
import mycompiler.mymodifier.Modifiers;
|
||
import mycompiler.mystatement.Assign;
|
||
import mycompiler.mystatement.Expr;
|
||
import mycompiler.mystatement.ExprStmt;
|
||
import mycompiler.mystatement.InstVar;
|
||
import mycompiler.mystatement.LocalOrFieldVar;
|
||
import mycompiler.mytype.RefType;
|
||
import mycompiler.mytype.Type;
|
||
import org.apache.log4j.Logger;
|
||
// ino.end
|
||
|
||
|
||
|
||
|
||
// ino.class.DeclId.23280.declaration
|
||
public class DeclId
|
||
// ino.end
|
||
// ino.class.DeclId.23280.body
|
||
{
|
||
// ino.attribute.modifiers.23283.declaration
|
||
public Modifiers modifiers;
|
||
// ino.end
|
||
// ino.attribute.name.23286.declaration
|
||
public String name;
|
||
// ino.end
|
||
// ino.attribute.wert.23289.declaration
|
||
private ExprStmt wert;
|
||
// ino.end
|
||
// ino.attribute.paratyp.23292.declaration
|
||
public Vector paratyp = null; // hier wird die Parameterzuordnung gespeichert ... 'test t <int, double> = new test();'
|
||
// ino.end
|
||
// ino.attribute.m_LineNumber.23295.declaration
|
||
private int m_LineNumber = MyCompiler.NO_LINENUMBER;
|
||
// ino.end
|
||
private int m_Offset = -1; //hinzugef<65>gt hoth: 07.04.2006
|
||
// ino.attribute.codegenlog.23298.decldescription type=line
|
||
// Logger fuer Code-Gen
|
||
// ino.end
|
||
// ino.attribute.codegenlog.23298.declaration
|
||
protected static Logger codegenlog = Logger.getLogger("codegen");
|
||
// ino.end
|
||
|
||
// ino.method.DeclId.23301.definition
|
||
public DeclId()
|
||
// ino.end
|
||
// ino.method.DeclId.23301.body
|
||
{
|
||
|
||
}
|
||
// ino.end
|
||
|
||
|
||
|
||
// ino.method.DeclId.23304.definition
|
||
public DeclId(String name)
|
||
// ino.end
|
||
// ino.method.DeclId.23304.body
|
||
{
|
||
this.name = name;
|
||
}
|
||
// ino.end
|
||
|
||
// ino.method.set_Paratyp.23307.definition
|
||
public void set_Paratyp(Vector p)
|
||
// ino.end
|
||
// ino.method.set_Paratyp.23307.body
|
||
{
|
||
this.paratyp = p;
|
||
}
|
||
// ino.end
|
||
|
||
// ino.method.get_Paratyp.23310.definition
|
||
public Vector get_Paratyp()
|
||
// ino.end
|
||
// ino.method.get_Paratyp.23310.body
|
||
{
|
||
return this.paratyp;
|
||
}
|
||
// ino.end
|
||
|
||
// ino.method.set_Name.23313.definition
|
||
public void set_Name(String name)
|
||
// ino.end
|
||
// ino.method.set_Name.23313.body
|
||
{
|
||
this.name = name;
|
||
}
|
||
// ino.end
|
||
|
||
// ino.method.set_Wert.23316.definition
|
||
public void set_Wert(ExprStmt w)
|
||
// ino.end
|
||
// ino.method.set_Wert.23316.body
|
||
{
|
||
this.wert = w;
|
||
}
|
||
// ino.end
|
||
|
||
// ino.method.get_Name.23319.definition
|
||
public String get_Name()
|
||
// ino.end
|
||
// ino.method.get_Name.23319.body
|
||
{
|
||
return name;
|
||
}
|
||
// ino.end
|
||
|
||
// ino.method.get_Wert.23322.definition
|
||
public ExprStmt get_Wert()
|
||
// ino.end
|
||
// ino.method.get_Wert.23322.body
|
||
{
|
||
return wert;
|
||
}
|
||
// ino.end
|
||
|
||
// ino.method.set_Modifiers.23325.definition
|
||
public void set_Modifiers(Modifiers mod)
|
||
// ino.end
|
||
// ino.method.set_Modifiers.23325.body
|
||
{
|
||
this.modifiers = mod;
|
||
}
|
||
// ino.end
|
||
|
||
// ino.method.get_Modifiers.23328.definition
|
||
public Modifiers get_Modifiers()
|
||
// ino.end
|
||
// ino.method.get_Modifiers.23328.body
|
||
{
|
||
return this.modifiers;
|
||
}
|
||
// ino.end
|
||
|
||
// ino.method.get_access_flags.23331.definition
|
||
public short get_access_flags()
|
||
// ino.end
|
||
// ino.method.get_access_flags.23331.body
|
||
{
|
||
if(modifiers != null) return modifiers.calculate_access_flags();
|
||
else return (short)0;
|
||
}
|
||
// ino.end
|
||
|
||
|
||
|
||
// ino.method.set_ListType.23334.definition
|
||
public void set_ListType(Type t)
|
||
// ino.end
|
||
// ino.method.set_ListType.23334.body
|
||
{
|
||
//System.out.println("In Klasse DeclID, Methode set_ListType passiert nix!");
|
||
}
|
||
// ino.end
|
||
|
||
|
||
|
||
// ino.method.codegen_InstVarDecl.23337.defdescription type=javadoc
|
||
/**
|
||
* Generieren einer Instanzvariable im Bytecode.
|
||
* Fuegt ggf. eine Signatur hinzu (Generics).
|
||
*/
|
||
// ino.end
|
||
// ino.method.codegen_InstVarDecl.23337.definition
|
||
public void codegen_InstVarDecl(ClassFile classfile, Type type, Vector paralist)
|
||
throws JVMCodeException
|
||
// ino.end
|
||
// ino.method.codegen_InstVarDecl.23337.body
|
||
{
|
||
String codegen_type;
|
||
Attribute attr = null;
|
||
|
||
// Spezialbehandlung fuer Konstanten ....
|
||
// Eine Unterscheidung im Parser wuerde Konflikte erzeugen
|
||
// da die Definition von Fields und Konstanten sehr aehnlich ist.
|
||
if (modifiers != null && modifiers.includesModifier(new Final())) {
|
||
Constant ct = new Constant(name, modifiers);
|
||
ct.setType(type);
|
||
if (!(wert instanceof Expr))
|
||
throw new JVMCodeException("Das Generieren einer Konstante dieses Typs wird nicht unterst<73>tzt!");
|
||
ct.setValue((Expr) wert);
|
||
|
||
ct.codegen( classfile, paralist);
|
||
|
||
return;
|
||
}
|
||
|
||
|
||
// Ueberpruefung auf Generics (Signaturen!)
|
||
if (SignatureInfo.needsSignature(type)) attr = new SignatureInfo(type, classfile);
|
||
|
||
if (type instanceof RefType)
|
||
codegen_type = ((RefType)type).get_codegen_Type(null);
|
||
else
|
||
codegen_type = JVMCode.get_codegen_Type(type.getName(), paralist);
|
||
|
||
|
||
// Instanzvariable genenerieren
|
||
classfile.add_field(name, codegen_type, get_access_flags(), attr);
|
||
|
||
// Wertzuweisung ggf. hinzufuegen
|
||
if(wert != null) {
|
||
if(wert instanceof Expr) {
|
||
classfile.add_field_ref(name, null, codegen_type);
|
||
Assign assign = new Assign(getOffset(),name.length());
|
||
assign.set_Expr(new InstVar(name, type.getName(),getOffset()), (Expr)wert);
|
||
classfile.add_classblock_Element(assign);
|
||
}
|
||
else throw new JVMCodeException("Wertzuweisung der Instanzvariable kann nicht uebersetzt werden!");
|
||
}
|
||
}
|
||
// ino.end
|
||
|
||
|
||
|
||
// ino.method.codegen_LocalVarDecl.23340.definition
|
||
public void codegen_LocalVarDecl(ClassFile classfile, CodeAttribute code, Type type, Vector paralist)
|
||
throws JVMCodeException
|
||
// ino.end
|
||
// ino.method.codegen_LocalVarDecl.23340.body
|
||
{
|
||
code.add_local(name, type);
|
||
if(wert != null)
|
||
{
|
||
if(wert instanceof Expr)
|
||
{
|
||
Assign assign = new Assign(getOffset(),name.length());
|
||
assign.set_Expr(new LocalOrFieldVar(name,getOffset()), (Expr)wert);
|
||
assign.codegen(classfile, code, paralist);
|
||
}
|
||
else
|
||
{
|
||
throw new JVMCodeException("JVMCodeException: DeclId: void codegen(ClassFile classfile, Type type)");
|
||
}
|
||
}
|
||
}
|
||
// ino.end
|
||
|
||
// ino.method.getLineNumber.23343.definition
|
||
public int getLineNumber()
|
||
// ino.end
|
||
// ino.method.getLineNumber.23343.body
|
||
{
|
||
return m_LineNumber;
|
||
}
|
||
// ino.end
|
||
|
||
// ino.method.setLineNumber.23346.definition
|
||
public void setLineNumber(int lineNumber)
|
||
// ino.end
|
||
// ino.method.setLineNumber.23346.body
|
||
{
|
||
m_LineNumber = lineNumber;
|
||
}
|
||
// ino.end
|
||
|
||
// ino.method.getOffset.23349.defdescription type=line
|
||
// hinzugef<65>gt hoth: 07.04.2006
|
||
// ino.end
|
||
// ino.method.getOffset.23349.definition
|
||
public int getOffset()
|
||
// ino.end
|
||
// ino.method.getOffset.23349.body
|
||
{
|
||
return m_Offset;
|
||
}
|
||
// ino.end
|
||
|
||
// ino.method.setOffset.23352.defdescription type=line
|
||
// hinzugef<65>gt hoth: 07.04.2006
|
||
// ino.end
|
||
// ino.method.setOffset.23352.definition
|
||
public void setOffset(int Offset)
|
||
// ino.end
|
||
// ino.method.setOffset.23352.body
|
||
{
|
||
m_Offset = Offset;
|
||
}
|
||
// ino.end
|
||
|
||
// ino.method.toString.23355.defdescription type=javadoc
|
||
/**
|
||
* <br/>Author: Martin Pl<50>micke
|
||
* @return
|
||
*/
|
||
// ino.end
|
||
// ino.method.toString.23355.definition
|
||
public String toString()
|
||
// ino.end
|
||
// ino.method.toString.23355.body
|
||
{
|
||
return name.toString();
|
||
}
|
||
// ino.end
|
||
|
||
}
|
||
// ino.end
|