@Override @AvailMethod int o_PrimitiveNumber(final AvailObject object) { // Answer the primitive number I should try before falling back on // the Avail code. Zero indicates not-a-primitive. return object.slot(PRIMITIVE); }
@Override void o_WriteSummaryTo(final AvailObject object, final JSONWriter writer) { writer.startObject(); writer.write("kind"); writer.write("function implementation"); writer.write("outers"); writer.write(object.slot(NUM_OUTERS)); writer.write("arguments"); writer.write(object.slot(NUM_ARGS)); writer.write("locals"); writer.write(object.slot(NUM_LOCALS)); writer.write("maximum stack depth"); writer.write(object.slot(FRAME_SLOTS)); writer.write("nybbles"); object.slot(NYBBLES).writeTo(writer); writer.write("function type"); object.slot(FUNCTION_TYPE).writeSummaryTo(writer); writer.write("method"); object.methodName().writeTo(writer); writer.write("module"); object.module().moduleName().writeTo(writer); writer.write("starting line number"); writer.write(object.startingLineNumber()); writer.write("literals"); writer.startArray(); for (int i = 1, limit = object.variableObjectSlotsCount(); i <= limit; i++) { A_BasicObject literal = object.slot(LITERAL_AT_, i); if (literal.equalsNil()) { literal = IntegerDescriptor.zero(); } literal.writeSummaryTo(writer); } writer.endArray(); writer.endObject(); }
@Override @AvailMethod @Nullable Primitive o_Primitive(final AvailObject object) { return Primitive.byNumber(object.slot(PRIMITIVE)); }
@Override @AvailMethod int o_NumLocals(final AvailObject object) { return object.slot(NUM_LOCALS); }
@Override @AvailMethod int o_NumOuters(final AvailObject object) { return object.slot(NUM_OUTERS); }
@Override @AvailMethod int o_NumArgs(final AvailObject object) { return object.slot(NUM_ARGS); }
/** * {@inheritDoc} * * <p>Answer the number of arguments + locals + stack slots to reserve in my continuations. */ @Override @AvailMethod int o_NumArgsAndLocalsAndStack(final AvailObject object) { return object.slot(FRAME_SLOTS); }
@Override @AvailMethod A_Tuple o_Nybbles(final AvailObject object) { return object.slot(NYBBLES); }
@Override @AvailMethod int o_Hash(final AvailObject object) { return object.slot(HASH); }
@Override @AvailMethod A_Type o_FunctionType(final AvailObject object) { return object.slot(FUNCTION_TYPE); }
@Override @AvailMethod AvailObject o_LiteralAt(final AvailObject object, final int subscript) { return object.slot(LITERAL_AT_, subscript); }
/** * Answer the {@link InvocationStatistic} associated with the specified {@link * CompiledCodeDescriptor raw function}. * * @param object The {@link A_RawFunction} from which to extract the invocation statistics helper. * @return The code's invocation statistics. */ static InvocationStatistic getInvocationStatistic(final AvailObject object) { final AvailObject pojo = object.slot(INVOCATION_STATISTIC); return (InvocationStatistic) pojo.javaObject(); }