BoolLiteral implementiert

This commit is contained in:
Schubert, Julia (WWI2012D) 2015-06-23 00:23:14 +02:00
parent 93f4257cdc
commit acdc36d23f
2 changed files with 147 additions and 135 deletions

View File

@ -1,134 +1,146 @@
// ino.module.BoolLiteral.8626.package
package de.dhbwstuttgart.syntaxtree.statement;
// ino.end
// ino.module.BoolLiteral.8626.import
import java.util.Hashtable;
import org.apache.bcel.generic.ClassGen;
import de.dhbwstuttgart.typeinference.Menge;
import de.dhbwstuttgart.logger.Logger;
import de.dhbwstuttgart.myexception.CTypeReconstructionException;
import de.dhbwstuttgart.myexception.JVMCodeException;
import de.dhbwstuttgart.syntaxtree.Class;
import de.dhbwstuttgart.syntaxtree.SyntaxTreeNode;
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;
import de.dhbwstuttgart.typeinference.unify.CSubstitutionSet;
// ino.class.BoolLiteral.25089.declaration
public class BoolLiteral extends Literal
// ino.end
// ino.class.BoolLiteral.25089.body
{
@Override
public void genByteCode(ClassGen _cg) {
// TODO Auto-generated method stub
}
// 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 RefType("Boolean",this,this.getOffset()));
//this.setType(new Type("boolean"));
// ###########################################################
}
// ino.end
/*
// ino.method.sc_check.25102.definition
public void sc_check(Menge<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
@Override
public ConstraintsSet TYPEExpr(TypeAssumptions assumptions) {
this.type = assumptions.checkType(new RefType("java.lang.Boolean",this,-1), this);
return new ConstraintsSet();
}
@Override
public JavaCodeResult printJavaCode(ResultSet resultSet) {
if(Bool)return new JavaCodeResult("true");
return new JavaCodeResult("false");
}
@Override
public Menge<SyntaxTreeNode> getChildren() {
Menge<SyntaxTreeNode> ret = new Menge<SyntaxTreeNode>();
return ret;
}
@Override
public void wandleRefTypeAttributes2GenericAttributes(
Menge<Type> paralist,
Menge<GenericTypeVar> genericMethodParameters) {
// TODO Auto-generated method stub
}
}
// ino.end
// ino.module.BoolLiteral.8626.package
package de.dhbwstuttgart.syntaxtree.statement;
// ino.end
// ino.module.BoolLiteral.8626.import
import java.util.Hashtable;
import org.apache.bcel.generic.ClassGen;
import org.apache.bcel.generic.InstructionFactory;
import org.apache.bcel.generic.InstructionList;
import de.dhbwstuttgart.typeinference.Menge;
import de.dhbwstuttgart.logger.Logger;
import de.dhbwstuttgart.myexception.CTypeReconstructionException;
import de.dhbwstuttgart.myexception.JVMCodeException;
import de.dhbwstuttgart.syntaxtree.Class;
import de.dhbwstuttgart.syntaxtree.SyntaxTreeNode;
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;
import de.dhbwstuttgart.typeinference.unify.CSubstitutionSet;
// 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 RefType("Boolean",this,this.getOffset()));
//this.setType(new Type("boolean"));
// ###########################################################
}
// ino.end
/*
// ino.method.sc_check.25102.definition
public void sc_check(Menge<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
@Override
public ConstraintsSet TYPEExpr(TypeAssumptions assumptions) {
this.type = assumptions.checkType(new RefType("java.lang.Boolean",this,-1), this);
return new ConstraintsSet();
}
@Override
public JavaCodeResult printJavaCode(ResultSet resultSet) {
if(Bool)return new JavaCodeResult("true");
return new JavaCodeResult("false");
}
@Override
public Menge<SyntaxTreeNode> getChildren() {
Menge<SyntaxTreeNode> ret = new Menge<SyntaxTreeNode>();
return ret;
}
@Override
public void wandleRefTypeAttributes2GenericAttributes(
Menge<Type> paralist,
Menge<GenericTypeVar> genericMethodParameters) {
// TODO Auto-generated method stub
}
@Override
public InstructionList genByteCode(ClassGen cg) {
InstructionFactory _factory = new InstructionFactory(cg, cg.getConstantPool());
InstructionList il = new InstructionList();
if (Bool == true){
il.append(_factory.ICONST_1);
}else {
il.append(_factory.ICONST_0);
}
return il;
}
}
// ino.end

View File

@ -1,6 +1,6 @@
class BoolLit{
void method() { b = true; }
void method() { b; b = false; }