JavaPatternMatching/src/mycompiler/mystatement/CharLiteral.java

193 lines
5.6 KiB
Java
Raw Normal View History

2013-10-18 11:33:46 +00:00
// ino.module.CharLiteral.8628.package
package mycompiler.mystatement;
// ino.end
// ino.module.CharLiteral.8628.import
import java.util.Hashtable;
import java.util.Vector;
2014-02-22 03:58:49 +00:00
import mycompiler.SyntaxTreeNode;
2013-10-18 11:33:46 +00:00
import mycompiler.mybytecode.ClassFile;
import mycompiler.mybytecode.CodeAttribute;
import mycompiler.mybytecode.JVMCode;
import mycompiler.myclass.Class;
import mycompiler.myexception.CTypeReconstructionException;
import mycompiler.myexception.JVMCodeException;
import mycompiler.mytype.CharacterType;
import mycompiler.mytype.GenericTypeVar;
import mycompiler.mytype.RefType;
import mycompiler.mytype.Type;
import mycompiler.mytypereconstruction.CSupportData;
import mycompiler.mytypereconstruction.CTriple;
import mycompiler.mytypereconstruction.set.CSubstitutionSet;
import mycompiler.mytypereconstruction.set.CTripleSet;
import mycompiler.mytypereconstruction.set.CTypeAssumptionSet;
import mycompiler.mytypereconstruction.typeassumption.CTypeAssumption;
import org.apache.log4j.Logger;
// ino.end
2014-02-22 03:58:49 +00:00
2013-10-18 11:33:46 +00:00
import typinferenz.ConstraintsSet;
import typinferenz.JavaCodeResult;
import typinferenz.ResultSet;
import typinferenz.assumptions.TypeAssumptions;
2013-10-18 11:33:46 +00:00
// ino.class.CharLiteral.25166.declaration
public class CharLiteral extends Literal
// ino.end
// ino.class.CharLiteral.25166.body
{
// ino.attribute.Char.25170.declaration
private char Char;
// ino.end
// ino.attribute.parserlog.25173.declaration
protected static Logger parserlog = Logger.getLogger("parser");
// ino.end
// ino.method.CharLiteral.25176.definition
public CharLiteral()
// ino.end
// ino.method.CharLiteral.25176.body
{
super(-1,-1);
// #JB# 20.04.2005
// ###########################################################
this.setType(new CharacterType());
//this.setType(new Type("char"));
// ###########################################################
}
// ino.end
// ino.method.sc_check.25179.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.25179.body
{
if(ext)
parserlog.debug(" ---CharLiteral---");
}
// ino.end
// ino.method.set_Char.25182.definition
public void set_Char( char c)
// ino.end
// ino.method.set_Char.25182.body
{
this.Char = c ;
}
// ino.end
// ino.method.get_Name.25185.definition
public String get_Name()
// ino.end
// ino.method.get_Name.25185.body
{
return null;
}
// ino.end
// ino.method.codegen.25188.definition
public void codegen(ClassFile classfile, CodeAttribute code, Vector paralist)
throws JVMCodeException
// ino.end
// ino.method.codegen.25188.body
{
// Wert des chars auf den Stack laden
code.add_code(JVMCode.bipush);
code.add_code_byte((byte)Char);
// Auto-Boxing des Typs in Character
code.add_code(JVMCode.invokestatic);
code.add_code_short(classfile.add_method_ref("java/lang/Character", "valueOf", "(C)Ljava/lang/Character;"));
}
// ino.end
// ino.method.ConstantCodegen.25191.definition
public short ConstantCodegen(ClassFile classfile)
throws JVMCodeException
// ino.end
// ino.method.ConstantCodegen.25191.body
{
return (short) classfile.add_CONSTANT_Integer_info(Char);
}
// ino.end
// ino.method.TRStatement.25194.definition
public CTripleSet TRStatement(CSubstitutionSet sigma, CTypeAssumptionSet V, CSupportData supportData)
// ino.end
// ino.method.TRStatement.25194.body
{
throw CTypeReconstructionException.createNotImplementedException();
}
// ino.end
// ino.method.TRExp.25197.defdescription type=javadoc
/**
* Workaround: <EFBFBD>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>CharacterType</code> zur<EFBFBD>ckzugeben, wird ein
* <code>RefType</code> zur<EFBFBD>ckgegeben.<br/>
* Diese Methode kann sp<EFBFBD>ter entfernt werden, sodass automatisch die Methode der
* Super-Klasse verwendet wird.
* <br>Author: J<EFBFBD>rg B<EFBFBD>uerle
* @param sigma
* @param V
* @param supportData
* @return
*/
// ino.end
// ino.method.TRExp.25197.definition
public CTripleSet TRExp(CSubstitutionSet sigma, CTypeAssumptionSet V, CSupportData supportData)
// ino.end
// ino.method.TRExp.25197.body
{
CTripleSet tripleSet = new CTripleSet();
tripleSet.addElement(new CTriple(sigma, new RefType("java.lang.Character",getOffset()),V));
return tripleSet;
}
// ino.end
// ino.method.wandleRefTypeAttributes2GenericAttributes.25200.definition
public void wandleRefTypeAttributes2GenericAttributes(Vector<Type> paralist, Vector<GenericTypeVar> genericMethodParameters)
// ino.end
// ino.method.wandleRefTypeAttributes2GenericAttributes.25200.body
{
}
// ino.end
@Override
public ConstraintsSet TYPEExpr(TypeAssumptions assumptions) {
// TODO Auto-generated method stub
return null;
}
@Override
public JavaCodeResult printJavaCode(ResultSet resultSet) {
return new JavaCodeResult("'"+String.valueOf(this.Char)+"'");
}
2014-02-22 03:58:49 +00:00
@Override
public Vector<SyntaxTreeNode> getChildren() {
Vector<SyntaxTreeNode> ret = new Vector<SyntaxTreeNode>();
return ret;
}
2013-10-18 11:33:46 +00:00
}
// ino.end