Package org.codehaus.commons.compiler

Examples of org.codehaus.commons.compiler.Location


                    identifier           // fieldName
                );
            }
            if (this.peekKeyword("this")) {
                // '.' 'this'
                Location location = this.location();
                this.eatToken();
                return new Java.QualifiedThisReference(
                    location,                // location
                    atom.toTypeOrPE()        // qualification
                );
            }
            if (this.peekKeyword("super")) {
                Location location = this.location();
                this.eatToken();
                if (this.peekOperator("(")) {

                    // '.' 'super' Arguments
                    // Qualified superclass constructor invocation (JLS 8.8.5.1) (LHS is an Rvalue)
                    return new Java.SuperConstructorInvocation(
                        location,             // location
                        atom.toRvalueOrPE()// optionalQualification
                        this.parseArguments() // arguments
                    );
                }
                this.readOperator(".");
                String identifier = this.readIdentifier();

                if (this.peekOperator("(")) {

                    // '.' 'super' '.' Identifier Arguments
                    // Qualified superclass method invocation (JLS 15.12) (LHS is a ClassName)
                    // TODO: Qualified superclass method invocation
                    this.throwCompileException("Qualified superclass method invocation NYI");
                } else {

                    // '.' 'super' '.' Identifier
                    // Qualified superclass field access (JLS 15.11.2) (LHS is an Rvalue)
                    return new Java.SuperclassFieldAccessExpression(
                        location,          // location
                        atom.toTypeOrPE(), // optionalQualification
                        identifier         // fieldName
                    );
                }
            }
            if (this.peekKeyword("new")) {
                // '.' 'new' Identifier Arguments [ ClassBody ]
                Java.Rvalue lhs = atom.toRvalue();
                Location location = this.location();
                this.eatToken();
                String identifier = this.readIdentifier();
                Java.Type type = new Java.RvalueMemberType(
                    location,  // location
                    lhs,       // rValue
                    identifier // identifier
                );
                Java.Rvalue[] arguments = this.parseArguments();
                if (this.peekOperator("{")) {
                    // '.' 'new' Identifier Arguments ClassBody (LHS is an Rvalue)
                    final Java.AnonymousClassDeclaration anonymousClassDeclaration = new Java.AnonymousClassDeclaration(
                        this.location(), // location
                        type             // baseType
                    );
                    this.parseClassBody(anonymousClassDeclaration);
                    return new Java.NewAnonymousClassInstance(
                        location,                  // location
                        lhs,                       // optionalQualification
                        anonymousClassDeclaration, // anonymousClassDeclaration
                        arguments                  // arguments
                    );
                } else {
                    // '.' 'new' Identifier Arguments (LHS is an Rvalue)
                    return new Java.NewClassInstance(
                        location, // location
                        lhs,      // optionalQualification
                        type,     // referenceType
                        arguments // arguments
                    );
                }
            }
            if (this.peekKeyword("class")) {
                // '.' 'class'
                Location location = this.location();
                this.eatToken();
                return new Java.ClassLiteral(location, atom.toTypeOrPE());
            }
            this.throwCompileException("Unexpected selector \"" + this.scanner.peek() + "\" after \".\"");
        }
        if (this.peekOperator("[")) {
            // '[' Expression ']'
            Location location = this.location();
            this.eatToken();
            Java.Rvalue index = this.parseExpression().toRvalueOrPE();
            this.readOperator("]");
            return new Java.ArrayAccessExpression(
                location,        // location
View Full Code Here


    }

    private void generateEvaluatorClass() throws Exception {
        Scanner scanner = new Scanner(null, new StringReader(expression));
        Parser parser = new Parser(scanner);
        Location loc = parser.location();
        String className = "TupleExpression" + counter.incrementAndGet();
        setClassName(packageName + "." + className);
        Java.CompilationUnit cu = makeCompilationUnit(parser);
        cu.setPackageDeclaration(new Java.PackageDeclaration(loc, packageName));
        Java.PackageMemberClassDeclaration cd = new Java.PackageMemberClassDeclaration(loc,
View Full Code Here

                )
        );
    }

    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]));
View Full Code Here

    public TupleAllocatorGenerator(Class tupleClass) throws Exception {
        setParentClassLoader(tupleClass.getClassLoader());
        String className = tupleClass.getName() + "Allocator";
        setClassName(packageName + "." + className);
        Java.CompilationUnit cu = new Java.CompilationUnit(null);
        Location loc = new Location(null, (short)0, (short)0);
        cu.setPackageDeclaration(new Java.PackageDeclaration(loc, packageName));
        cu.addPackageMemberTypeDeclaration(makeClassDefinition(loc, tupleClass, className));
        allocatorClass = compileToClass(cu);
    }
View Full Code Here

    protected Class[] fieldTypes;
    protected Location loc;
    protected String className;

    public TupleCodeGenerator(Class iface, String[] fieldNames, Class[] fieldTypes) {
        this.loc = new Location("", (short)0, (short)0);
        this.iface = iface;
        this.fieldNames = fieldNames.clone();
        this.fieldTypes = fieldTypes.clone();
        this.className = "FastTuple" + counter.getAndIncrement();
        this.setClassName("com.boundary.tuple." + className);
View Full Code Here

        return compileToClass(makeCompilationUnit());
    }

    protected Java.CompilationUnit makeCompilationUnit() throws CompileException {
        Java.CompilationUnit cu = new Java.CompilationUnit(null);
        Location loc = new Location("", ((short) 0), ((short) 0));
        cu.setPackageDeclaration(new Java.PackageDeclaration(loc, "com.boundary.tuple"));
        cu.addImportDeclaration(new Java.CompilationUnit.SingleTypeImportDeclaration(loc, "com.boundary.tuple.unsafe.Coterie".split("\\.")));
        Class[] ifaces;
        if (iface != null) {
            ifaces = new Class[] {iface};
View Full Code Here

TOP

Related Classes of org.codehaus.commons.compiler.Location

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.