Logo Search packages:      
Sourcecode: janino version File versions  Download package

void org::codehaus::janino::UnitCompiler::assignSyntheticParametersToSyntheticFields ( Java.ConstructorDeclarator  cd  )  throws CompileException [inline, package]

Copies the values of the synthetic parameters of this constructor ("this$..." and "val$...") to the synthetic fields of the object ("this$..." and "val$...").

Definition at line 4392 of file UnitCompiler.java.

                                                                                                           {
        for (Iterator it = cd.getDeclaringClass().syntheticFields.values().iterator(); it.hasNext();) {
            IClass.IField sf = (IClass.IField) it.next();
            Java.LocalVariable syntheticParameter = (Java.LocalVariable) cd.syntheticParameters.get(sf.getName());
            if (syntheticParameter == null) throw new RuntimeException("SNO: Synthetic parameter for synthetic field \"" + sf.getName() + "\" not found");
            try {
                Java.ExpressionStatement es = new Java.ExpressionStatement(new Java.Assignment(
                    cd.getLocation(),             // location
                    new Java.FieldAccess(         // lhs
                        cd.getLocation(),                         // location
                        new Java.ThisReference(cd.getLocation()), // lhs
                        sf                                        // field
                    ),
                    "=",                          // operator
                    new Java.LocalVariableAccess( // rhs
                        cd.getLocation(),  // location
                        syntheticParameter // localVariable
                    )
                ));
                es.setEnclosingScope(cd);
                this.compile(es);
            } catch (Parser.ParseException e) {
                throw new RuntimeException("S.N.O.");
            }
        }
    }


Generated by  Doxygen 1.6.0   Back to index