@Override @AvailMethod void o_SetMethodName(final AvailObject object, final A_String methodName) { assert methodName.isString(); methodName.makeImmutable(); final A_Atom propertyAtom = object.mutableSlot(PROPERTY_ATOM); propertyAtom.setAtomProperty(methodNameKeyAtom(), methodName); // Now scan all sub-blocks. Some literals will be functions and some // will be compiled code objects. int counter = 1; for (int i = 1, limit = object.numLiterals(); i <= limit; i++) { final AvailObject literal = object.literalAt(i); final A_RawFunction subCode; if (literal.isFunction()) { subCode = literal.code(); } else if (literal.isInstanceOf(CompiledCodeTypeDescriptor.mostGeneralType())) { subCode = literal; } else { subCode = null; } if (subCode != null) { final String suffix = String.format("[%d]", counter); counter++; final A_Tuple newName = methodName.concatenateWith(StringDescriptor.from(suffix), true); subCode.setMethodName((A_String) newName); } } }
/** * {@inheritDoc} * * <p>Show the types of local variables and outer variables. */ @Override AvailObjectFieldHelper[] o_DescribeForDebugger(final AvailObject object) { final List<AvailObjectFieldHelper> fields = new ArrayList<>(); fields.addAll(Arrays.asList(super.o_DescribeForDebugger(object))); for (int i = 1, end = object.numOuters(); i <= end; i++) { fields.add( new AvailObjectFieldHelper(object, FakeSlots.OUTER_TYPE_, i, object.outerTypeAt(i))); } for (int i = 1, end = object.numLocals(); i <= end; i++) { fields.add( new AvailObjectFieldHelper(object, FakeSlots.LOCAL_TYPE_, i, object.localTypeAt(i))); } final StringBuilder disassembled = new StringBuilder(); object.printOnAvoidingIndent(disassembled, new IdentityHashMap<A_BasicObject, Void>(), 0); final String[] content = disassembled.toString().split("\n"); fields.add(new AvailObjectFieldHelper(object, FakeSlots.L1_DISASSEMBLY, -1, content)); final List<AvailObject> allLiterals = new ArrayList<>(); for (int i = 1; i <= object.numLiterals(); i++) { allLiterals.add(object.literalAt(i)); } fields.add( new AvailObjectFieldHelper( object, FakeSlots.ALL_LITERALS, -1, TupleDescriptor.fromList(allLiterals))); return fields.toArray(new AvailObjectFieldHelper[fields.size()]); }
@Override @AvailMethod A_Type o_OuterTypeAt(final AvailObject object, final int index) { assert 1 <= index && index <= object.numOuters(); return object.literalAt(object.numLiterals() - object.numLocals() - object.numOuters() + index); }