import org.cojen.classfile.TypeDesc;
import org.objectweb.asm.Label;
+import org.simantics.scl.compiler.constants.componentaccess.ComponentAccess;
+import org.simantics.scl.compiler.constants.componentaccess.FieldComponentAccess;
import org.simantics.scl.compiler.internal.codegen.continuations.Cont;
import org.simantics.scl.compiler.internal.codegen.references.BoundVar;
import org.simantics.scl.compiler.internal.codegen.references.IVal;
public class SCLConstructor extends FunctionValue {
private static int MAX_FIELD_COUNT = Constants.MAX_TUPLE_LENGTH;
- public static String[][] DEFAULT_FIELD_NAMES = new String[MAX_FIELD_COUNT+1][];
+ public static ComponentAccess[][] DEFAULT_FIELD_NAMES = new ComponentAccess[MAX_FIELD_COUNT+1][];
static {
for(int i=0;i<=MAX_FIELD_COUNT;++i) {
- String[] fieldNames = new String[i];
+ ComponentAccess[] fieldNames = new ComponentAccess[i];
for(int j=0;j<i;++j)
- fieldNames[j] = "c" + j;
+ fieldNames[j] = new FieldComponentAccess("c" + j);
DEFAULT_FIELD_NAMES[i] = fieldNames;
}
}
- String name; // For debugging
- String className;
- String[] fieldNames;
+ private final String name; // For debugging
+ private final String className;
+ private final ComponentAccess[] componentAccesses;
boolean onlyConstructor;
- int constructorTag;
- public final String[] recordFieldNames;
+ private final int constructorTag;
public SCLConstructor(String name, String className, TVar[] typeParameters, int constructorTag,
- Type returnType, String[] fieldNames, String[] recordFieldNames, Type... parameterTypes) {
+ Type returnType, ComponentAccess[] componentAccesses, Type... parameterTypes) {
super(typeParameters, Types.NO_EFFECTS, returnType, parameterTypes);
ClassBuilder.checkClassName(className);
this.name = name;
this.className = className;
- this.fieldNames = fieldNames;
+ this.componentAccesses = componentAccesses;
this.constructorTag = constructorTag;
- this.recordFieldNames = recordFieldNames;
}
public SCLConstructor(String name, String className, TVar[] typeParameters, int constructorTag,
Type returnType,
Type ... parameterTypes) {
this(name, className, typeParameters, constructorTag, returnType,
- DEFAULT_FIELD_NAMES[parameterTypes.length], null, parameterTypes);
+ DEFAULT_FIELD_NAMES[parameterTypes.length], parameterTypes);
}
public void setOnlyConstructor(boolean onlyConstructor) {
if(!typeDesc.equals(TypeDesc.VOID)) {
mb.dup();
- mb.loadField(MethodBuilder.getClassName(constructorType), fieldNames[i], typeDesc);
+ componentAccesses[i].load(mb, MethodBuilder.getClassName(constructorType), typeDesc);
if(typeDesc == TypeDesc.OBJECT)
mb.unbox(contType);
}