private FieldHolder readField(DataInput input) throws IOException { FieldHolder field = new FieldHolder(symbolTable.at(input.readInt())); field.setType(ValueType.parse(symbolTable.at(input.readInt()))); field.setLevel(accessLevels[input.readByte()]); field.getModifiers().addAll(unpackModifiers(input.readInt())); field.setInitialValue(readFieldValue(input)); readAnnotations(input, field.getAnnotations()); return field; }
private void addFunctorField(ClassHolder cls, MethodReference method) { if (cls.getAnnotations().get(FunctorImpl.class.getName()) != null) { return; } FieldHolder field = new FieldHolder("$$jso_functor$$"); field.setLevel(AccessLevel.PUBLIC); field.setType(ValueType.parse(JSObject.class)); cls.addField(field); AnnotationHolder annot = new AnnotationHolder(FunctorImpl.class.getName()); annot.getValues().put("value", new AnnotationValue(method.getDescriptor().toString())); cls.getAnnotations().add(annot); }
public FieldHolder parseField(FieldNode node) { FieldHolder field = new FieldHolder(referenceCache.getCached(node.name)); field.setType(referenceCache.getCached(ValueType.parse(node.desc))); field.setInitialValue(node.value); parseModifiers(node.access, field, DECL_FIELD); parseAnnotations(field.getAnnotations(), node.visibleAnnotations, node.invisibleAnnotations); return field; }
public static FieldHolder copyField(FieldReader field) { FieldHolder copy = new FieldHolder(field.getName()); copy.setLevel(field.getLevel()); copy.getModifiers().addAll(field.readModifiers()); copy.setType(field.getType()); copy.setInitialValue(field.getInitialValue()); copyAnnotations(field.getAnnotations(), copy.getAnnotations()); return copy; }
public FieldHolder rename(FieldHolder field) { FieldHolder renamedField = new FieldHolder(field.getName()); renamedField.getModifiers().addAll(field.getModifiers()); renamedField.setLevel(field.getLevel()); renamedField.setType(rename(field.getType())); renamedField.setInitialValue(field.getInitialValue()); rename(field.getAnnotations(), renamedField.getAnnotations()); return renamedField; }
private Variable createVariable(ValueImpl<?> value, CallLocation location) { if (value.context == this) { return value.innerValue; } Variable outerVar = getParent().emitVariable(value, location); CapturedValue capturedValue = capturedValueMap.computeIfAbsent(outerVar, v -> { FieldHolder field = new FieldHolder("proxyCapture" + suffixGenerator++); field.setLevel(AccessLevel.PUBLIC); field.setType(value.type); proxyClass.addField(field); CapturedValue result = new CapturedValue(field, v); capturedValues.add(result); return result; }); Program program = startBlock.getProgram(); Variable var = program.createVariable(); GetFieldInstruction insn = new GetFieldInstruction(); insn.setInstance(program.variableAt(0)); insn.setField(capturedValue.field.getReference()); insn.setFieldType(capturedValue.field.getType()); insn.setReceiver(var); startBlock.add(insn); return var; }
private MethodHolder createConstructor(ClassHierarchy hierarchy, ClassHolder implementor, ValueType[] types, TextLocation location) { ValueType[] signature = Arrays.copyOf(types, types.length + 1); signature[types.length] = ValueType.VOID; MethodHolder ctor = new MethodHolder("<init>", signature); ctor.setLevel(AccessLevel.PUBLIC); ProgramEmitter pe = ProgramEmitter.create(ctor, hierarchy); pe.setCurrentLocation(location); ValueEmitter thisVar = pe.var(0, implementor); thisVar.invokeSpecial(implementor.getParent(), "<init>"); for (int i = 0; i < types.length; ++i) { FieldHolder field = new FieldHolder("_" + i); field.setLevel(AccessLevel.PRIVATE); field.setType(types[i]); implementor.addField(field); thisVar.setField(field.getName(), pe.var(i + 1, types[i])); } pe.exit(); implementor.addMethod(ctor); return ctor; }
field.setType(method.getResultType()); field.setLevel(AccessLevel.PRIVATE); field.getModifiers().add(ElementModifier.STATIC);
field.setType(methodDecl.getResultType()); field.setLevel(AccessLevel.PRIVATE); implementor.addField(field);
private FieldHolder readField(DataInput input) throws IOException { FieldHolder field = new FieldHolder(symbolTable.at(input.readInt())); field.setType(ValueType.parse(symbolTable.at(input.readInt()))); field.setLevel(accessLevels[input.readByte()]); field.getModifiers().addAll(unpackModifiers(input.readInt())); field.setInitialValue(readFieldValue(input)); readAnnotations(input, field.getAnnotations()); return field; }
private void addFunctorField(ClassHolder cls, MethodReference method) { if (cls.getAnnotations().get(FunctorImpl.class.getName()) != null) { return; } FieldHolder field = new FieldHolder("$$jso_functor$$"); field.setLevel(AccessLevel.PUBLIC); field.setType(ValueType.parse(JSObject.class)); cls.addField(field); AnnotationHolder annot = new AnnotationHolder(FunctorImpl.class.getName()); annot.getValues().put("value", new AnnotationValue(method.getDescriptor().toString())); cls.getAnnotations().add(annot); }
public FieldHolder parseField(FieldNode node) { FieldHolder field = new FieldHolder(node.name); field.setType(ValueType.parse(node.desc)); field.setInitialValue(node.value); parseModifiers(node.access, field); parseAnnotations(field.getAnnotations(), node.visibleAnnotations, node.invisibleAnnotations); return field; }
public static FieldHolder copyField(FieldReader field) { FieldHolder copy = new FieldHolder(field.getName()); copy.setLevel(field.getLevel()); copy.getModifiers().addAll(field.readModifiers()); copy.setType(field.getType()); copy.setInitialValue(field.getInitialValue()); copyAnnotations(field.getAnnotations(), copy.getAnnotations()); return copy; }
private Variable createVariable(ValueImpl<?> value, CallLocation location) { if (value.context == this) { return value.innerValue; } Variable outerVar = getParent().emitVariable(value, location); CapturedValue capturedValue = capturedValueMap.computeIfAbsent(outerVar, v -> { FieldHolder field = new FieldHolder("proxyCapture" + suffixGenerator++); field.setLevel(AccessLevel.PUBLIC); field.setType(value.type); proxyClass.addField(field); CapturedValue result = new CapturedValue(field, v); capturedValues.add(result); return result; }); Program program = startBlock.getProgram(); Variable var = program.createVariable(); GetFieldInstruction insn = new GetFieldInstruction(); insn.setInstance(program.variableAt(0)); insn.setField(capturedValue.field.getReference()); insn.setFieldType(capturedValue.field.getType()); insn.setReceiver(var); startBlock.add(insn); return var; }
field.setType(method.getResultType()); field.setLevel(AccessLevel.PRIVATE); field.getModifiers().add(ElementModifier.STATIC);