private Java.MethodDeclarator generateBackendMethod(Parser parser) throws Exception { Location loc = parser.location(); List<Java.BlockStatement> statements = Lists.newArrayList(); Java.Rvalue[] exprs = parser.parseExpressionList(); for (int i=0; i<exprs.length; i++) { if (i == exprs.length - 1) { statements.add(maybeGenerateReturn(loc, exprs[i])); } else { statements.add(new Java.ExpressionStatement(exprs[i])); } } return new Java.MethodDeclarator(loc, null, new Java.Modifiers(Mod.PRIVATE), classToType(loc, returnType), "doEval", generateArgs(loc, schema.tupleClass()), new Java.Type[0], statements ); }
protected Java.MethodDeclarator generateGetter(String name, Class type, int index) throws CompileException { // unsafe().get* (long) Java.BlockStatement st = new Java.ReturnStatement(loc, generateGetInvocation(type, index)); return new Java.MethodDeclarator( loc, null, new Java.Modifiers(Mod.PUBLIC), classToType(loc, type), name, new Java.FunctionDeclarator.FormalParameters(loc, new Java.FunctionDeclarator.FormalParameter[] {}, false), new Java.Type[] {}, Lists.newArrayList(st) ); }
private Java.MethodDeclarator generateFrontendMethod(Location loc) throws Exception { return new Java.MethodDeclarator(loc, null, new Java.Modifiers(Mod.PUBLIC), classToType(loc, returnType), "evaluate", generateArgs(loc, FastTuple.class), new Java.Type[0], Lists.<Java.BlockStatement>newArrayList( maybeGenerateReturn(loc, new Java.MethodInvocation( loc, null, "doEval", new Java.Rvalue[] { new Java.Cast( loc, new Java.ReferenceType(loc, schema.tupleClass().getCanonicalName().split("\\."), null), new Java.AmbiguousName(loc, new String[] {"tuple"}) ) } ) ) ) ); }
cd.addDeclaredMethod(new Java.MethodDeclarator( loc, null,
protected Java.MethodDeclarator generateSetter(String name, Class type, int index) throws CompileException { Java.BlockStatement st = new Java.ExpressionStatement(generateSetInvocation(type, index, "value")); return new Java.MethodDeclarator( loc, null, new Java.Modifiers(Mod.PUBLIC), classToType(loc, Void.TYPE), name, new Java.FunctionDeclarator.FormalParameters(loc, new Java.FunctionDeclarator.FormalParameter[] { new Java.FunctionDeclarator.FormalParameter(loc, true, classToType(loc, type), "value") }, false), new Java.Type[] {}, Lists.newArrayList(st) ); }