Пример #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
 /** Answer the starting line number for this block of code. */
 @Override
 @AvailMethod
 int o_StartingLineNumber(final AvailObject object) {
   final A_Atom properties = object.mutableSlot(PROPERTY_ATOM);
   final A_Number lineInteger = properties.getAtomProperty(lineNumberKeyAtom());
   return lineInteger.equalsNil() ? 0 : lineInteger.extractInt();
 }
Пример #3
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;
 }
Пример #4
0
 /** Answer the module in which this code occurs. */
 @Override
 @AvailMethod
 A_Module o_Module(final AvailObject object) {
   final A_Atom properties = object.mutableSlot(PROPERTY_ATOM);
   return properties.issuingModule();
 }
Пример #5
0
 @Override
 @AvailMethod
 L2Chunk o_StartingChunk(final AvailObject object) {
   final AvailObject pojo = object.mutableSlot(STARTING_CHUNK);
   return (L2Chunk) pojo.javaObject();
 }