Example #1
0
  /** Evaluates the body in a class or module definition statement. */
  public static IRubyObject evalClassDefinitionBody(
      Ruby runtime,
      ThreadContext context,
      StaticScope scope,
      Node bodyNode,
      RubyModule type,
      IRubyObject self,
      Block block) {
    context.preClassEval(scope, type);

    try {
      if (runtime.hasEventHooks()) {
        callTraceFunction(runtime, context, RubyEvent.CLASS);
      }

      if (bodyNode == null) return runtime.getNil();
      String name = type.getBaseName();
      if (name == null) {
        if (type.isSingleton()) {
          name = "__singleton__";
        } else if (type.isModule()) { // can these two happen?
          name = "<anonymous module>";
        } else {
          name = "<anonymous class>";
        }
      }
      return INTERPRET_CLASS(runtime, context, bodyNode, name, type, block);
    } finally {
      try {
        if (runtime.hasEventHooks()) {
          callTraceFunction(runtime, context, RubyEvent.END);
        }
      } finally {
        context.postClassEval();
      }
    }
  }
Example #2
0
 private static void methodPostTrace(
     Ruby runtime, ThreadContext context, String name, RubyModule implClass) {
   if (runtime.hasEventHooks()) context.trace(RubyEvent.RETURN, name, implClass);
 }
Example #3
0
 private static void blockPostTrace(
     Ruby runtime, ThreadContext context, String name, RubyModule implClass) {
   if (runtime.hasEventHooks() && runtime.is2_0())
     context.trace(RubyEvent.B_RETURN, name, implClass);
 }