2013-10-18 11:33:46 +00:00
|
|
|
|
// ino.module.NewArray.8641.package
|
2014-09-02 08:33:54 +00:00
|
|
|
|
package de.dhbwstuttgart.syntaxtree.statement;
|
2013-10-18 11:33:46 +00:00
|
|
|
|
// ino.end
|
|
|
|
|
// ino.module.NewArray.8641.import
|
|
|
|
|
import java.util.Hashtable;
|
2015-04-22 19:40:22 +00:00
|
|
|
|
import de.dhbwstuttgart.typeinference.Menge;
|
2014-02-09 15:07:31 +00:00
|
|
|
|
|
2013-10-18 11:33:46 +00:00
|
|
|
|
|
2014-10-09 10:01:16 +00:00
|
|
|
|
import de.dhbwstuttgart.logger.Logger;
|
2014-09-04 14:35:44 +00:00
|
|
|
|
import de.dhbwstuttgart.bytecode.ClassFile;
|
|
|
|
|
import de.dhbwstuttgart.bytecode.CodeAttribute;
|
|
|
|
|
import de.dhbwstuttgart.bytecode.JVMCode;
|
|
|
|
|
import de.dhbwstuttgart.myexception.CTypeReconstructionException;
|
|
|
|
|
import de.dhbwstuttgart.myexception.JVMCodeException;
|
2014-09-02 08:33:54 +00:00
|
|
|
|
import de.dhbwstuttgart.syntaxtree.Class;
|
2014-09-04 14:35:44 +00:00
|
|
|
|
import de.dhbwstuttgart.syntaxtree.SyntaxTreeNode;
|
2014-09-02 08:33:54 +00:00
|
|
|
|
import de.dhbwstuttgart.syntaxtree.type.GenericTypeVar;
|
|
|
|
|
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;
|
2014-09-05 09:49:31 +00:00
|
|
|
|
import de.dhbwstuttgart.typeinference.unify.CSubstitutionSet;
|
2013-10-18 11:33:46 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// ino.class.NewArray.25787.declaration
|
|
|
|
|
public class NewArray extends Expr
|
|
|
|
|
// ino.end
|
|
|
|
|
// ino.class.NewArray.25787.body
|
|
|
|
|
{
|
|
|
|
|
// ino.method.NewArray.25791.definition
|
|
|
|
|
public NewArray(int offset,int variableLength)
|
|
|
|
|
// ino.end
|
|
|
|
|
// ino.method.NewArray.25791.body
|
|
|
|
|
{
|
|
|
|
|
super(offset,variableLength);
|
|
|
|
|
}
|
|
|
|
|
// ino.end
|
|
|
|
|
// ino.attribute.type.25794.declaration
|
|
|
|
|
private Type type;
|
|
|
|
|
// ino.end
|
|
|
|
|
// ino.attribute.expr.25797.declaration
|
2015-04-22 19:40:22 +00:00
|
|
|
|
public Menge<Expr> expr = new Menge<Expr>();
|
2013-10-18 11:33:46 +00:00
|
|
|
|
// ino.end
|
|
|
|
|
// ino.attribute.parserlog.25800.declaration
|
|
|
|
|
protected static Logger parserlog = Logger.getLogger("parser");
|
|
|
|
|
// ino.end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// ino.method.getType.25803.defdescription type=javadoc
|
|
|
|
|
/**
|
|
|
|
|
* Author: J<EFBFBD>rg B<EFBFBD>uerle<br/>
|
|
|
|
|
* @return Returns the type.
|
|
|
|
|
*/
|
|
|
|
|
// ino.end
|
|
|
|
|
// ino.method.getType.25803.definition
|
|
|
|
|
public Type getType()
|
|
|
|
|
// ino.end
|
|
|
|
|
// ino.method.getType.25803.body
|
|
|
|
|
{
|
|
|
|
|
return type;
|
|
|
|
|
}
|
|
|
|
|
// ino.end
|
|
|
|
|
|
|
|
|
|
// ino.method.setType.25806.defdescription type=javadoc
|
|
|
|
|
/**
|
|
|
|
|
* Author: J<EFBFBD>rg B<EFBFBD>uerle<br/>
|
|
|
|
|
* @param type The type to set.
|
|
|
|
|
*/
|
|
|
|
|
// ino.end
|
|
|
|
|
// ino.method.setType.25806.definition
|
|
|
|
|
public void setType(Type type)
|
|
|
|
|
// ino.end
|
|
|
|
|
// ino.method.setType.25806.body
|
|
|
|
|
{
|
|
|
|
|
this.type = type;
|
|
|
|
|
}
|
|
|
|
|
// ino.end
|
|
|
|
|
|
|
|
|
|
// ino.method.get_Name.25809.definition
|
|
|
|
|
public String get_Name()
|
|
|
|
|
// ino.end
|
|
|
|
|
// ino.method.get_Name.25809.body
|
|
|
|
|
{
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
// ino.end
|
|
|
|
|
|
2014-11-04 12:47:05 +00:00
|
|
|
|
/*
|
2013-10-18 11:33:46 +00:00
|
|
|
|
// ino.method.sc_check.25812.definition
|
2015-04-22 19:40:22 +00:00
|
|
|
|
public void sc_check(Menge<Class> classname, Hashtable bh, Hashtable<String, String> ch,boolean ext, Hashtable parach, Hashtable<String, Hashtable> parabh)
|
2013-10-18 11:33:46 +00:00
|
|
|
|
// ino.end
|
|
|
|
|
// ino.method.sc_check.25812.body
|
|
|
|
|
{
|
|
|
|
|
if(ext)
|
|
|
|
|
parserlog.debug(" ---NewArray---");
|
|
|
|
|
}
|
|
|
|
|
// ino.end
|
2014-11-04 12:47:05 +00:00
|
|
|
|
*/
|
2013-10-18 11:33:46 +00:00
|
|
|
|
|
|
|
|
|
// ino.method.get_codegen_Array_Type.25815.definition
|
|
|
|
|
public int get_codegen_Array_Type()
|
|
|
|
|
throws JVMCodeException
|
|
|
|
|
// ino.end
|
|
|
|
|
// ino.method.get_codegen_Array_Type.25815.body
|
|
|
|
|
{
|
|
|
|
|
if(this.getType().equals("boolean")) return 4;
|
|
|
|
|
else if(this.getType().equals("char")) return 5;
|
|
|
|
|
else if(this.getType().equals("float")) return 6;
|
|
|
|
|
else if(this.getType().equals("double")) return 7;
|
|
|
|
|
else if(this.getType().equals("byte")) return 8;
|
|
|
|
|
else if(this.getType().equals("short")) return 9;
|
|
|
|
|
else if(this.getType().equals("int")) return 10;
|
|
|
|
|
else if(this.getType().equals("long")) return 11;
|
|
|
|
|
else throw new JVMCodeException("JVMCodeException: NewArray: int get_codegen_Array_Type()");
|
|
|
|
|
}
|
|
|
|
|
// ino.end
|
|
|
|
|
|
|
|
|
|
// ino.method.codegen.25818.definition
|
2015-04-22 19:40:22 +00:00
|
|
|
|
public void codegen(ClassFile classfile, CodeAttribute code, Menge paralist)
|
2013-10-18 11:33:46 +00:00
|
|
|
|
throws JVMCodeException
|
|
|
|
|
// ino.end
|
|
|
|
|
// ino.method.codegen.25818.body
|
|
|
|
|
{
|
2014-09-02 16:49:19 +00:00
|
|
|
|
if(JVMCode.get_nType(this.getType().getName().toString()) == 4) {
|
2013-10-18 11:33:46 +00:00
|
|
|
|
for(int i = 0; i < expr.size(); i++) ((Expr)expr.elementAt(i)).codegen(classfile, code, paralist);
|
|
|
|
|
code.add_code(JVMCode.anewarray);
|
2014-09-02 16:49:19 +00:00
|
|
|
|
code.add_code_short(classfile.add_CONSTANT_Class_info(this.getType().getName().toString()));
|
2013-10-18 11:33:46 +00:00
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
for(int i = 0; i < expr.size(); i++) ((Expr)expr.elementAt(i)).codegen(classfile, code, paralist);
|
|
|
|
|
code.add_code(JVMCode.newarray);
|
|
|
|
|
code.add_code_byte(this.get_codegen_Array_Type());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
// ino.end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// ino.method.wandleRefTypeAttributes2GenericAttributes.25827.definition
|
2015-04-22 19:40:22 +00:00
|
|
|
|
public void wandleRefTypeAttributes2GenericAttributes(Menge<Type> paralist, Menge<GenericTypeVar> genericMethodParameters)
|
2013-10-18 11:33:46 +00:00
|
|
|
|
// ino.end
|
|
|
|
|
// ino.method.wandleRefTypeAttributes2GenericAttributes.25827.body
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
// ino.end
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public ConstraintsSet TYPEExpr(TypeAssumptions assumptions) {
|
|
|
|
|
// TODO Auto-generated method stub
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public JavaCodeResult printJavaCode(ResultSet resultSet) {
|
|
|
|
|
// TODO Auto-generated method stub
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
2014-03-27 15:43:07 +00:00
|
|
|
|
@Override
|
2015-04-22 19:40:22 +00:00
|
|
|
|
public Menge<SyntaxTreeNode> getChildren() {
|
|
|
|
|
Menge<SyntaxTreeNode> ret = new Menge<SyntaxTreeNode>();
|
2014-03-27 15:43:07 +00:00
|
|
|
|
ret.addAll(this.expr);
|
|
|
|
|
return ret;
|
|
|
|
|
}
|
|
|
|
|
|
2013-10-18 11:33:46 +00:00
|
|
|
|
}
|
|
|
|
|
// ino.end
|