private boolean setField ( PropertyExpression expression , Expression objectExpression , ClassNode rType , String name ) { if ( expression . isSafe ( ) ) return false ; FieldNode fn = AsmClassGenerator . getDeclaredFieldOfCurrentClassOrAccessibleFieldOfSuper ( controller . getClassNode ( ) , rType , name , false ) ; if ( fn == null ) return false ; OperandStack stack = controller . getOperandStack ( ) ; stack . doGroovyCast ( fn . getType ( ) ) ; MethodVisitor mv = controller . getMethodVisitor ( ) ; String ownerName = BytecodeHelper . getClassInternalName ( fn . getOwner ( ) ) ; if ( ! fn . isStatic ( ) ) { controller . getCompileStack ( ) . pushLHS ( false ) ; objectExpression . visit ( controller . getAcg ( ) ) ; controller . getCompileStack ( ) . popLHS ( ) ; if ( ! rType . equals ( stack . getTopOperand ( ) ) ) { BytecodeHelper . doCast ( mv , rType ) ; stack . replace ( rType ) ; } stack . swap ( ) ; mv . visitFieldInsn ( PUTFIELD , ownerName , name , BytecodeHelper . getTypeDescription ( fn . getType ( ) ) ) ; stack . remove ( 1 ) ; } else { mv . visitFieldInsn ( PUTSTATIC , ownerName , name , BytecodeHelper . getTypeDescription ( fn . getType ( ) ) ) ; } //mv.visitInsn(ACONST_NULL); //stack.replace(OBJECT_TYPE); return true ; }
this is just a simple set field handling static and non - static but not Closure and inner classes