protected List<Java.MethodDeclarator> generateIndexedTypedGetters() throws CompileException { List<Java.MethodDeclarator> methods = Lists.newArrayList(); for (int i=0; i<types.length; i++) { methods.add(new Java.MethodDeclarator( loc, null, new Java.Modifiers(Mod.PUBLIC), new Java.BasicType(loc, primIndex(types[i])), "get" + capitalize(types[i].getName()), new Java.FunctionDeclarator.FormalParameters(loc, new Java.FunctionDeclarator.FormalParameter[] { new Java.FunctionDeclarator.FormalParameter(loc, true, new Java.BasicType(loc, Java.BasicType.INT), "index")}, false), new Java.Type[] {}, Lists.<Java.BlockStatement>newArrayList( new Java.SwitchStatement(loc, new Java.AmbiguousName(loc, new String[] {"index"}), generateIndexedGetterImpl(types[i])) ) )); } return methods; }
protected List<Java.MethodDeclarator> generateIndexedTypedSetters() throws CompileException { List<Java.MethodDeclarator> methods = Lists.newArrayList(); for (int i=0; i<types.length; i++) { methods.add(new Java.MethodDeclarator( loc, null, new Java.Modifiers(Mod.PUBLIC), new Java.BasicType(loc, Java.BasicType.VOID), "set" + capitalize(types[i].getName()), new Java.FunctionDeclarator.FormalParameters(loc, new Java.FunctionDeclarator.FormalParameter[] { new Java.FunctionDeclarator.FormalParameter(loc, true, new Java.BasicType(loc, Java.BasicType.INT), "index"), new Java.FunctionDeclarator.FormalParameter(loc, true, new Java.BasicType(loc, primIndex(types[i])), "value") }, false), new Java.Type[] {}, Lists.<Java.BlockStatement>newArrayList( new Java.SwitchStatement(loc, new Java.AmbiguousName(loc, new String[] {"index"}), generateIndexedSetterImpl("value", types[i])) ) )); } return methods; }
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"}) ) } ) ) ) ); }
protected Java.FieldDeclaration[] generateFields() { return new Java.FieldDeclaration[] { new Java.FieldDeclaration( loc, null, new Java.Modifiers(Mod.PUBLIC), new Java.BasicType(loc, Java.BasicType.LONG), new Java.VariableDeclarator[] {new Java.VariableDeclarator(loc, "address", 0, null)}), new Java.FieldDeclaration(loc, null, new Java.Modifiers((short)(Mod.STATIC + Mod.PRIVATE)), classToType(loc, Unsafe.class), new Java.VariableDeclarator[] { new Java.VariableDeclarator(loc, "unsafe", 0, new Java.MethodInvocation(loc, new Java.AmbiguousName(loc, new String[] {"Coterie"}), "unsafe", new Java.Rvalue[0])) }) }; }
protected Java.MethodDeclarator generateIndexedGetter() throws CompileException { return new Java.MethodDeclarator( loc, null, new Java.Modifiers(Mod.PUBLIC), classToType(loc, Object.class), "get", new Java.FunctionDeclarator.FormalParameters(loc, new Java.FunctionDeclarator.FormalParameter[] { new Java.FunctionDeclarator.FormalParameter(loc,true, classToType(loc, Integer.TYPE), "index")}, false), new Java.Type[] {}, Lists.<Java.BlockStatement>newArrayList( new Java.SwitchStatement(loc, new Java.AmbiguousName(loc, new String[] {"index"}), generateIndexedGetterImpl()) ) ); }
protected Java.MethodDeclarator generateIndexedSetter() throws CompileException { return new Java.MethodDeclarator( loc, null, new Java.Modifiers(Mod.PUBLIC), classToType(loc, Void.TYPE), "set", new Java.FunctionDeclarator.FormalParameters(loc, new Java.FunctionDeclarator.FormalParameter[] { new Java.FunctionDeclarator.FormalParameter(loc, true, classToType(loc, Integer.TYPE), "index"), new Java.FunctionDeclarator.FormalParameter(loc, true, classToType(loc, Object.class), "value") },false), new Java.Type[] {}, Lists.<Java.BlockStatement>newArrayList( new Java.SwitchStatement(loc, new Java.AmbiguousName(loc, new String[] {"index"}), generateIndexedSetterImpl("value")) ) ); }
protected Java.Rvalue generateSetInvocation(Class type, int index, String value) throws CompileException { return new Java.MethodInvocation(loc, new Java.AmbiguousName(loc, new String[] {"unsafe"}), "put" + accessorForType(type), new Java.Rvalue[]{ new Java.BinaryOperation(loc, new Java.AmbiguousName(loc, new String[]{"address"}), "+", new Java.IntegerLiteral(loc, Integer.toString(layout[index]))), new Java.Cast(loc, classToRefType(type), new Java.AmbiguousName(loc, new String[] {value})) } ); }
@Override protected Java.Rvalue generateSetInvocation(Class type, int index, String value) throws CompileException { return new Java.Assignment(loc, new Java.FieldAccessExpression(loc, new Java.ThisReference(loc), fieldNames[index]), "=", new Java.Cast(loc, classToRefType(fieldTypes[index]), new Java.AmbiguousName(loc, new String[] {value}))); } }
protected Java.Rvalue generateGetInvocation(Class type, int index) throws CompileException { return new Java.MethodInvocation(loc, new Java.AmbiguousName(loc, new String[] {"unsafe"}), "get" + accessorForType(type), new Java.Rvalue[] { new Java.BinaryOperation(loc, new Java.AmbiguousName(loc, new String[] {"address"}), "+", new Java.IntegerLiteral(loc, Integer.toString(layout[index]))) } ); }