forked from JavaTX/JavaCompilerCore
213 lines
5.9 KiB
Java
Executable File
213 lines
5.9 KiB
Java
Executable File
// ino.module.BoolLiteral.8626.package
|
||
package de.dhbwstuttgart.syntaxtree.statement;
|
||
// ino.end
|
||
// ino.module.BoolLiteral.8626.import
|
||
import java.util.Hashtable;
|
||
import java.util.Vector;
|
||
|
||
import mycompiler.mybytecode.ClassFile;
|
||
import mycompiler.mybytecode.CodeAttribute;
|
||
import mycompiler.mybytecode.JVMCode;
|
||
import mycompiler.myexception.CTypeReconstructionException;
|
||
import mycompiler.myexception.JVMCodeException;
|
||
import mycompiler.mytypereconstruction.CSupportData;
|
||
import mycompiler.mytypereconstruction.CTriple;
|
||
import mycompiler.mytypereconstruction.set.CSubstitutionSet;
|
||
import mycompiler.mytypereconstruction.set.CTripleSet;
|
||
import mycompiler.mytypereconstruction.set.CTypeAssumptionSet;
|
||
|
||
import org.apache.log4j.Logger;
|
||
// ino.end
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
import de.dhbwstuttgart.core.SyntaxTreeNode;
|
||
import de.dhbwstuttgart.syntaxtree.Class;
|
||
import de.dhbwstuttgart.syntaxtree.type.BooleanType;
|
||
import de.dhbwstuttgart.syntaxtree.type.GenericTypeVar;
|
||
import de.dhbwstuttgart.syntaxtree.type.RefType;
|
||
import de.dhbwstuttgart.syntaxtree.type.Type;
|
||
import de.dhbwstuttgart.typeinference.ConstraintsSet;
|
||
import de.dhbwstuttgart.typeinference.JavaCodeResult;
|
||
import de.dhbwstuttgart.typeinference.ResultSet;
|
||
import de.dhbwstuttgart.typeinference.assumptions.TypeAssumptions;
|
||
|
||
|
||
|
||
|
||
// ino.class.BoolLiteral.25089.declaration
|
||
public class BoolLiteral extends Literal
|
||
// ino.end
|
||
// ino.class.BoolLiteral.25089.body
|
||
{
|
||
// ino.attribute.Bool.25093.declaration
|
||
private boolean Bool;
|
||
// ino.end
|
||
// ino.attribute.parserlog.25096.declaration
|
||
protected static Logger parserlog = Logger.getLogger("parser");
|
||
// ino.end
|
||
|
||
|
||
// ino.method.BoolLiteral.25099.definition
|
||
public BoolLiteral()
|
||
// ino.end
|
||
// ino.method.BoolLiteral.25099.body
|
||
{
|
||
super(-1,-1);
|
||
// #JB# 20.04.2005
|
||
// ###########################################################
|
||
this.setType(new BooleanType());
|
||
//this.setType(new Type("boolean"));
|
||
// ###########################################################
|
||
}
|
||
// ino.end
|
||
|
||
|
||
|
||
// ino.method.sc_check.25102.definition
|
||
public void sc_check(Vector<Class> classname, Hashtable ch, Hashtable<String, String> bh, boolean ext, Hashtable parach,Hashtable<String, Hashtable> parabh)
|
||
// ino.end
|
||
// ino.method.sc_check.25102.body
|
||
{
|
||
if(ext)
|
||
{
|
||
parserlog.debug(" ---BoolLiteral---");
|
||
}
|
||
}
|
||
// ino.end
|
||
|
||
|
||
|
||
// ino.method.set_Bool.25105.definition
|
||
public void set_Bool(boolean b)
|
||
// ino.end
|
||
// ino.method.set_Bool.25105.body
|
||
{
|
||
this.Bool = b;
|
||
}
|
||
// ino.end
|
||
|
||
|
||
|
||
// ino.method.get_Name.25108.definition
|
||
public String get_Name()
|
||
// ino.end
|
||
// ino.method.get_Name.25108.body
|
||
{
|
||
return null;
|
||
}
|
||
// ino.end
|
||
|
||
|
||
|
||
// ino.method.codegen.25111.definition
|
||
public void codegen(ClassFile classfile, CodeAttribute code, Vector paralist)
|
||
throws JVMCodeException
|
||
// ino.end
|
||
// ino.method.codegen.25111.body
|
||
{
|
||
if(Bool)
|
||
code.add_code(JVMCode.iconst_1);
|
||
else
|
||
code.add_code(JVMCode.iconst_0);
|
||
|
||
// Auto-Boxing des Typs in Boolean
|
||
code.add_code(JVMCode.invokestatic);
|
||
code.add_code_short(classfile.add_method_ref("java/lang/Boolean", "valueOf", "(Z)Ljava/lang/Boolean;"));
|
||
}
|
||
// ino.end
|
||
|
||
// ino.method.ConstantCodegen.25114.definition
|
||
public short ConstantCodegen(ClassFile classfile)
|
||
throws JVMCodeException
|
||
// ino.end
|
||
// ino.method.ConstantCodegen.25114.body
|
||
{
|
||
if (Bool)
|
||
return (short) classfile.add_CONSTANT_Integer_info(1);
|
||
else
|
||
return (short) classfile.add_CONSTANT_Integer_info(0);
|
||
}
|
||
// ino.end
|
||
|
||
|
||
// ino.method.TRStatement.25117.definition
|
||
public CTripleSet TRStatement(CSubstitutionSet sigma, CTypeAssumptionSet V, CSupportData supportData)
|
||
// ino.end
|
||
// ino.method.TRStatement.25117.body
|
||
{
|
||
throw CTypeReconstructionException.createNotImplementedException();
|
||
}
|
||
// ino.end
|
||
|
||
|
||
// ino.method.TRExp.25120.defdescription type=javadoc
|
||
/**
|
||
* Workaround: <20>berschreibt Methode TRExp aus der Super-Klasse
|
||
* <code>Literal</code>, weil die Implementierung von Unify (noch) nicht mit
|
||
* Basetypes umgehen kann.<br/>
|
||
* Anstatt den Basetype <code>BooleanType</code> zur<75>ckzugeben, wird ein
|
||
* <code>RefType</code> zur<75>ckgegeben.<br/>
|
||
* Diese Methode kann sp<73>ter entfernt werden, sodass automatisch die Methode der
|
||
* Super-Klasse verwendet wird.
|
||
* <br>Author: J<>rg B<>uerle
|
||
* @param sigma
|
||
* @param V
|
||
* @param supportData
|
||
* @return
|
||
*/
|
||
// ino.end
|
||
// ino.method.TRExp.25120.definition
|
||
public CTripleSet TRExp(CSubstitutionSet sigma, CTypeAssumptionSet V, CSupportData supportData)
|
||
// ino.end
|
||
// ino.method.TRExp.25120.body
|
||
{
|
||
CTripleSet tripleSet = new CTripleSet();
|
||
tripleSet.addElement(new CTriple(sigma, new RefType("java.lang.Boolean",getOffset()),V));
|
||
return tripleSet;
|
||
}
|
||
// ino.end
|
||
|
||
// ino.method.wandleRefTypeAttributes2GenericAttributes.25123.definition
|
||
public void wandleRefTypeAttributes2GenericAttributes(Vector<Type> paralist, Vector<GenericTypeVar> genericMethodParameters)
|
||
// ino.end
|
||
// ino.method.wandleRefTypeAttributes2GenericAttributes.25123.body
|
||
{
|
||
}
|
||
// ino.end
|
||
|
||
|
||
|
||
@Override
|
||
public ConstraintsSet TYPEExpr(TypeAssumptions assumptions) {
|
||
this.type = assumptions.getTypeFor(new RefType("java.lang.Boolean",-1), this);
|
||
return new ConstraintsSet();
|
||
}
|
||
|
||
|
||
|
||
@Override
|
||
public JavaCodeResult printJavaCode(ResultSet resultSet) {
|
||
if(Bool)return new JavaCodeResult("true");
|
||
return new JavaCodeResult("false");
|
||
}
|
||
|
||
|
||
|
||
@Override
|
||
public Vector<SyntaxTreeNode> getChildren() {
|
||
Vector<SyntaxTreeNode> ret = new Vector<SyntaxTreeNode>();
|
||
return ret;
|
||
}
|
||
|
||
|
||
}
|
||
// ino.end
|