예제 #1
0
파일: Evaluator.java 프로젝트: crawley/pep
 /**
  * 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
파일: Evaluator.java 프로젝트: crawley/pep
 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);
 }