예제 #1
0
 @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);
     }
   }
 }
예제 #2
0
 @Override
 @AvailMethod
 A_String o_MethodName(final AvailObject object) {
   final A_Atom propertyAtom = object.mutableSlot(PROPERTY_ATOM);
   final A_String methodName = propertyAtom.getAtomProperty(methodNameKeyAtom());
   if (methodName.equalsNil()) {
     return StringDescriptor.from("Unknown function");
   }
   return methodName;
 }