Пример #1
0
 /**
  * Register and compile a type in the evaluator object's context.
  *
  * @param type a type to be registered and compiled
  * @throws ASTException
  */
 public void registerClass(TypeDeclaration type) throws ASTException {
   Compiler compiler = Compiler.current();
   compiler.analyse(type);
   if (compiler.getDiagnostics().size() > 0) {
     throw new CompilationErrorsException(compiler.getDiagnostics());
   }
 }
Пример #2
0
 private static Value doEvaluate(Context context, Expression expr, TypeDeclaration[] types)
     throws ASTException, EvaluationException, TerminationException {
   Compiler compiler = Compiler.current();
   for (TypeDeclaration type : types) {
     compiler.analyse(type);
   }
   expr = (Expression) compiler.analyse(expr);
   List<Diagnostic> diags = compiler.getDiagnostics();
   if (diags.size() > 0) {
     throw new CompilationErrorsException(diags);
   }
   return expr.evaluate(context);
 }