コード例 #1
0
 private static RubyValue eval(String evalText) {
   RubyCompiler compiler = new RubyCompiler();
   try {
     CompilationResults codes = compiler.compileString(evalText);
     RubyProgram p = codes.getRubyProgram();
     return p.invoke();
   } catch (RecognitionException e) {
     throw new RubyException(RubyRuntime.SyntaxErrorClass, e.toString());
   } catch (TokenStreamException e) {
     throw new RubyException(RubyRuntime.SyntaxErrorClass, e.toString());
   } catch (InstantiationException e) {
     throw new RubyException(e.toString());
   } catch (IllegalAccessException e) {
     throw new RubyException(e.toString());
   }
 }
コード例 #2
0
 public static RubyValue eval(String evalText, RubyBinding binding) {
   RubyCompiler compiler = new RubyCompiler();
   try {
     CompilationResults codes = compiler.compileString(evalText);
     RubyProgram p = codes.getRubyProgram();
     return p.invoke(
         binding.getSelf(), binding.getVariables(), binding.getBlock(), binding.getScope());
   } catch (RecognitionException e) {
     throw new RubyException(RubyRuntime.SyntaxErrorClass, e.toString());
   } catch (TokenStreamException e) {
     throw new RubyException(RubyRuntime.SyntaxErrorClass, e.toString());
   } catch (InstantiationException e) {
     throw new RubyException(e.toString());
   } catch (IllegalAccessException e) {
     throw new RubyException(e.toString());
   }
 }
コード例 #3
0
 private static RubyValue eval(String evalText, RubyBinding binding, String file_name) {
   RubyCompiler compiler = new RubyCompiler(binding, false);
   try {
     CompilationResults codes = compiler.compileString(file_name, evalText);
     RubyProgram p = codes.getRubyProgram();
     if (null != binding) {
       return p.invoke(
           binding.getSelf(), binding.getVariables(), binding.getBlock(), binding.getScope());
     } else {
       return p.invoke();
     }
   } catch (RecognitionException e) {
     throw new RubyException(RubyRuntime.SyntaxErrorClass, file_name + " " + e.toString());
   } catch (TokenStreamException e) {
     throw new RubyException(RubyRuntime.SyntaxErrorClass, file_name + " " + e.toString());
   } catch (InstantiationException e) {
     throw new RubyException(e.toString());
   } catch (IllegalAccessException e) {
     throw new RubyException(e.toString());
   }
 }