JavaPatternMatching/src/mycompiler/mystatement/StringLiteral.java
2014-03-17 17:55:55 +01:00

157 lines
4.5 KiB
Java
Executable File

// ino.module.StringLiteral.8653.package
package mycompiler.mystatement;
// ino.end
// ino.module.StringLiteral.8653.import
import java.util.Hashtable;
import java.util.Vector;
import mycompiler.SyntaxTreeNode;
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.set.CSubstitutionSet;
import mycompiler.mytypereconstruction.set.CTripleSet;
import mycompiler.mytypereconstruction.set.CTypeAssumptionSet;
import mycompiler.mytypereconstruction.typeassumption.CTypeAssumption;
import org.apache.log4j.Logger;
// ino.end
import typinferenz.ConstraintsSet;
import typinferenz.JavaCodeResult;
import typinferenz.ResultSet;
import typinferenz.assumptions.TypeAssumptions;
// ino.class.StringLiteral.26227.declaration
public class StringLiteral extends Literal
// ino.end
// ino.class.StringLiteral.26227.body
{
// ino.attribute.string.26231.declaration
private String string;
// ino.end
// ino.attribute.parserlog.26234.declaration
protected static Logger parserlog = Logger.getLogger("parser");
// ino.end
// ino.method.StringLiteral.26237.definition
public StringLiteral()
// ino.end
// ino.method.StringLiteral.26237.body
{
super(-1,-1);
// #JB# 20.04.2005
// ###########################################################
this.setType(new RefType("java.lang.String",getOffset()));
//this.setType(new Type("String"));
// ###########################################################
}
// ino.end
// ino.method.sc_check.26240.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.26240.body
{
if(ext)
parserlog.debug(" ---StringLiteral---");
}
// ino.end
// ino.method.set_String.26243.definition
public void set_String( String s)
// ino.end
// ino.method.set_String.26243.body
{
this.string = s;
}
// ino.end
// ino.method.get_Name.26246.definition
public String get_Name()
// ino.end
// ino.method.get_Name.26246.body
{
return null;
}
// ino.end
// ino.method.codegen.26249.definition
public void codegen(ClassFile classfile, CodeAttribute code, Vector paralist)
throws JVMCodeException
// ino.end
// ino.method.codegen.26249.body
{
int index = classfile.add_CONSTANT_String_info(string);
if(index < 256) {
code.add_code(JVMCode.ldc);
code.add_code_byte((byte)index);
}
else {
code.add_code(JVMCode.ldc_w);
code.add_code_short((short)index);
}
}
// ino.end
// ino.method.ConstantCodegen.26252.definition
public short ConstantCodegen(ClassFile classfile)
throws JVMCodeException
// ino.end
// ino.method.ConstantCodegen.26252.body
{
return (short) classfile.add_CONSTANT_String_info(string);
}
// ino.end
// ino.method.TRStatement.26255.definition
public CTripleSet TRStatement(CSubstitutionSet sigma, CTypeAssumptionSet V, CSupportData supportData)
// ino.end
// ino.method.TRStatement.26255.body
{
throw CTypeReconstructionException.createNotImplementedException();
}
// ino.end
// ino.method.wandleRefTypeAttributes2GenericAttributes.26258.definition
public void wandleRefTypeAttributes2GenericAttributes(Vector<Type> paralist, Vector<GenericTypeVar> genericMethodParameters)
// ino.end
// ino.method.wandleRefTypeAttributes2GenericAttributes.26258.body
{
}
// ino.end
@Override
public ConstraintsSet TYPEExpr(TypeAssumptions assumptions) {
this.set_Type(new RefType("String",0));
return new ConstraintsSet();
}
@Override
public JavaCodeResult printJavaCode(ResultSet resultSet) {
return new JavaCodeResult("\""+this.string+"\"");
}
@Override
public Vector<SyntaxTreeNode> getChildren() {
Vector<SyntaxTreeNode> ret = new Vector<SyntaxTreeNode>();
return ret;
}
}
// ino.end