public Expression transformExpression(ExpressionTransformer transformer) { PropertyExpression ret = new PropertyExpression(transformer.transform(objectExpression), transformer.transform(property), safe); ret.setSpreadSafe(spreadSafe); ret.setStatic(isStatic); ret.setImplicitThis(implicitThis); ret.setSourcePosition(this); ret.copyNodeMetaData(this); return ret; }
private static Expression tryTransformDelegateToProperty(VariableExpression expr) { // we need to transform variable expressions that go to a delegate // to a property expression, as ACG would loose the information // in processClassVariable before it reaches any makeCall, that could // handle it Object val = expr.getNodeMetaData(StaticTypesMarker.IMPLICIT_RECEIVER); if (val == null) return null; VariableExpression implicitThis = new VariableExpression("this"); PropertyExpression pexp = new PropertyExpression(implicitThis, expr.getName()); pexp.copyNodeMetaData(expr); pexp.setImplicitThis(true); pexp.getProperty().setSourcePosition(expr); ClassNode owner = expr.getNodeMetaData(StaticCompilationMetadataKeys.PROPERTY_OWNER); if (owner != null) { implicitThis.putNodeMetaData(StaticTypesMarker.INFERRED_TYPE, owner); implicitThis.putNodeMetaData(StaticTypesMarker.IMPLICIT_RECEIVER, val); } return pexp; }
pexp.setImplicitThis(true); for (int i=1; i<propertyPath.length;i++) { pexp.putNodeMetaData(StaticTypesMarker.INFERRED_TYPE, CLOSURE_TYPE); ); rewritten.setSpreadSafe(((PropertyExpression) origin).isSpreadSafe()); rewritten.setImplicitThis(false); rewritten.visit(controller.getAcg()); rewritten.putNodeMetaData(StaticTypesMarker.INFERRED_TYPE, origin.getNodeMetaData(StaticTypesMarker.INFERRED_TYPE));
private boolean tryVariableExpressionAsProperty(final VariableExpression vexp, final String dynName) { VariableExpression implicitThis = varX("this"); PropertyExpression pe = new PropertyExpression(implicitThis, dynName); pe.setImplicitThis(true); if (visitPropertyExpressionSilent(pe, vexp)) { ClassNode previousIt = vexp.getNodeMetaData(StaticTypesMarker.INFERRED_TYPE); vexp.copyNodeMetaData(implicitThis); vexp.putNodeMetaData(StaticTypesMarker.INFERRED_TYPE, previousIt); storeType(vexp, getType(pe)); Object val = pe.getNodeMetaData(StaticTypesMarker.READONLY_PROPERTY); if (val != null) vexp.putNodeMetaData(StaticTypesMarker.READONLY_PROPERTY, val); val = pe.getNodeMetaData(StaticTypesMarker.IMPLICIT_RECEIVER); if (val != null) vexp.putNodeMetaData(StaticTypesMarker.IMPLICIT_RECEIVER, val); return true; } return false; }
@Override public void visitPropertyExpression(PropertyExpression expr) { PropertyExpression conversion = new PropertyExpression( expr.isImplicitThis() ? expr.getObjectExpression() : convert(expr.getObjectExpression()), expr.getProperty(), expr.isSafe()); conversion.setSourcePosition(expr); conversion.setSpreadSafe(expr.isSpreadSafe()); conversion.setStatic(expr.isStatic()); conversion.setImplicitThis(expr.isImplicitThis()); result = record(conversion); }
@Override public void visitPropertyExpression(PropertyExpression expr) { PropertyExpression result = new PropertyExpression( replaceExpr(expr.getObjectExpression()), replaceExpr(expr.getProperty()), expr.isSafe() ); result.setSpreadSafe(expr.isSpreadSafe()); result.setStatic(expr.isStatic()); result.setImplicitThis(expr.isImplicitThis()); result.setType(expr.getType()); result.setSourcePosition(expr); replaceVisitedExpressionWith(result); }
private static Expression tryTransformPrivateFieldAccess(VariableExpression expr) { FieldNode field = expr.getNodeMetaData(StaticTypesMarker.PV_FIELDS_ACCESS); if (field == null) { field = expr.getNodeMetaData(StaticTypesMarker.PV_FIELDS_MUTATION); } if (field != null) { // access to a private field from a section of code that normally doesn't have access to it, like a // closure or an inner class VariableExpression receiver = new VariableExpression("this"); PropertyExpression pexp = new PropertyExpression( receiver, expr.getName() ); pexp.setImplicitThis(true); pexp.getProperty().setSourcePosition(expr); // put the receiver inferred type so that the class writer knows that it will have to call a bridge method receiver.putNodeMetaData(StaticTypesMarker.INFERRED_TYPE, field.getDeclaringClass()); // add inferred type information pexp.putNodeMetaData(StaticTypesMarker.INFERRED_TYPE, field.getOriginType()); return pexp; } return null; } }
private void processClassVariable(VariableExpression expression) { if (passingParams && controller.isInScriptBody()) { //TODO: check if this part is actually used MethodVisitor mv = controller.getMethodVisitor(); // let's create a ScriptReference to pass into the closure mv.visitTypeInsn(NEW, "org/codehaus/groovy/runtime/ScriptReference"); mv.visitInsn(DUP); loadThisOrOwner(); mv.visitLdcInsn(expression.getName()); mv.visitMethodInsn(INVOKESPECIAL, "org/codehaus/groovy/runtime/ScriptReference", "<init>", "(Lgroovy/lang/Script;Ljava/lang/String;)V", false); } else { PropertyExpression pexp = new PropertyExpression(new VariableExpression("this"), expression.getName()); pexp.getObjectExpression().setSourcePosition(expression); pexp.getProperty().setSourcePosition(expression); pexp.setImplicitThis(true); visitPropertyExpression(pexp); } }
"this" ); ((PropertyExpression)pexp).setImplicitThis(true);
new AttributeExpression(iteratorAsVar, spreadExpression.getProperty(), true): new PropertyExpression(iteratorAsVar, spreadExpression.getProperty(), true); pexp.setImplicitThis(spreadExpression.isImplicitThis()); pexp.setSourcePosition(spreadExpression); BinaryExpression assignment = new BinaryExpression(
"this" ); ((PropertyExpression)pexp).setImplicitThis(true);
protected void processClassVariable(String name) { if (passingClosureParams && isInScriptBody()) { // let's create a ScriptReference to pass into the closure mv.visitTypeInsn(NEW, "org/codehaus/groovy/runtime/ScriptReference"); mv.visitInsn(DUP); loadThisOrOwner(); mv.visitLdcInsn(name); mv.visitMethodInsn( INVOKESPECIAL, "org/codehaus/groovy/runtime/ScriptReference", "<init>", "(Lgroovy/lang/Script;Ljava/lang/String;)V"); } else { PropertyExpression pexp = new PropertyExpression(VariableExpression.THIS_EXPRESSION, name); pexp.setImplicitThis(true); visitPropertyExpression(pexp); } }
protected void processClassVariable(String name) { if (passingClosureParams && isInScriptBody()) { // let's create a ScriptReference to pass into the closure mv.visitTypeInsn(NEW, "org/codehaus/groovy/runtime/ScriptReference"); mv.visitInsn(DUP); loadThisOrOwner(); mv.visitLdcInsn(name); mv.visitMethodInsn( INVOKESPECIAL, "org/codehaus/groovy/runtime/ScriptReference", "<init>", "(Lgroovy/lang/Script;Ljava/lang/String;)V"); } else { PropertyExpression pexp = new PropertyExpression(VariableExpression.THIS_EXPRESSION, name); pexp.setImplicitThis(true); visitPropertyExpression(pexp); } }
public Expression transformExpression(ExpressionTransformer transformer) { PropertyExpression ret = new PropertyExpression(transformer.transform(objectExpression), transformer.transform(property), safe); ret.setSpreadSafe(spreadSafe); ret.setStatic(isStatic); ret.setImplicitThis(implicitThis); ret.setSourcePosition(this); return ret; }
public Expression transformExpression(ExpressionTransformer transformer) { PropertyExpression ret = new PropertyExpression(transformer.transform(objectExpression), transformer.transform(property), safe); ret.setSpreadSafe(spreadSafe); ret.setStatic(isStatic); ret.setImplicitThis(implicitThis); ret.setSourcePosition(this); return ret; }
protected void processClassVariable(String name) { if (passingClosureParams && isInScriptBody()) { // let's create a ScriptReference to pass into the closure mv.visitTypeInsn(NEW, "org/codehaus/groovy/runtime/ScriptReference"); mv.visitInsn(DUP); loadThisOrOwner(); mv.visitLdcInsn(name); mv.visitMethodInsn( INVOKESPECIAL, "org/codehaus/groovy/runtime/ScriptReference", "<init>", "(Lgroovy/lang/Script;Ljava/lang/String;)V"); } else { PropertyExpression pexp = new PropertyExpression(VariableExpression.THIS_EXPRESSION, name); pexp.setImplicitThis(true); visitPropertyExpression(pexp); } }
private void processClassVariable(String name) { if (passingParams && controller.isInScriptBody()) { //TODO: check if this part is actually used MethodVisitor mv = controller.getMethodVisitor(); // let's create a ScriptReference to pass into the closure mv.visitTypeInsn(NEW, "org/codehaus/groovy/runtime/ScriptReference"); mv.visitInsn(DUP); loadThisOrOwner(); mv.visitLdcInsn(name); mv.visitMethodInsn( INVOKESPECIAL, "org/codehaus/groovy/runtime/ScriptReference", "<init>", "(Lgroovy/lang/Script;Ljava/lang/String;)V"); } else { PropertyExpression pexp = new PropertyExpression(VariableExpression.THIS_EXPRESSION, name); pexp.setImplicitThis(true); visitPropertyExpression(pexp); } }
@Override public void visitPropertyExpression(PropertyExpression expr) { PropertyExpression result = new PropertyExpression( replaceExpr(expr.getObjectExpression()), replaceExpr(expr.getProperty()), expr.isSafe() ); result.setSpreadSafe(expr.isSpreadSafe()); result.setStatic(expr.isStatic()); result.setImplicitThis(expr.isImplicitThis()); result.setType(expr.getType()); result.setSourcePosition(expr); replaceVisitedExpressionWith(result); }
pexp.setImplicitThis(true); pexp.setSourcePosition(atom);
pexp.setImplicitThis(true); withLoc(exp,pexp); return transform(pexp); pexp.setImplicitThis(true); pexp.setSourcePosition(vexp);