protected Node simpleAssignment ( Node left , Node right ) { int nodeType = left . getType ( ) ; switch ( nodeType ) { case Token . NAME : String name = ( ( Name ) left ) . getIdentifier ( ) ; if ( inUseStrictDirective && ( "eval" . equals ( name ) || "arguments" . equals ( name ) ) ) { reportError ( "msg.bad.id.strict" , name ) ; } left . setType ( Token . BINDNAME ) ; return new Node ( Token . SETNAME , left , right ) ; case Token . GETPROP : case Token . GETELEM : { Node obj , id ; // If it's a PropertyGet or ElementGet, we're in the parse pass. // We could alternately have PropertyGet and ElementGet // override getFirstChild/getLastChild and return the appropriate // field, but that seems just as ugly as this casting. if ( left instanceof PropertyGet ) { obj = ( ( PropertyGet ) left ) . getTarget ( ) ; id = ( ( PropertyGet ) left ) . getProperty ( ) ; } else if ( left instanceof ElementGet ) { obj = ( ( ElementGet ) left ) . getTarget ( ) ; id = ( ( ElementGet ) left ) . getElement ( ) ; } else { // This branch is called during IRFactory transform pass. obj = left . getFirstChild ( ) ; id = left . getLastChild ( ) ; } int type ; if ( nodeType == Token . GETPROP ) { type = Token . SETPROP ; // TODO(stevey) - see https://bugzilla.mozilla.org/show_bug.cgi?id=492036 // The new AST code generates NAME tokens for GETPROP ids where the old parser // generated STRING nodes. If we don't set the type to STRING below, this will // cause java.lang.VerifyError in codegen for code like // "var obj={p:3};[obj.p]=[9];" id . setType ( Token . STRING ) ; } else { type = Token . SETELEM ; } return new Node ( type , obj , id , right ) ; } case Token . GET_REF : { Node ref = left . getFirstChild ( ) ; checkMutableReference ( ref ) ; return new Node ( Token . SET_REF , ref , right ) ; } } throw codeBug ( ) ; }
side effects in the RHS .