001: /***** BEGIN LICENSE BLOCK *****
002: * Version: CPL 1.0/GPL 2.0/LGPL 2.1
003: *
004: * The contents of this file are subject to the Common Public
005: * License Version 1.0 (the "License"); you may not use this file
006: * except in compliance with the License. You may obtain a copy of
007: * the License at http://www.eclipse.org/legal/cpl-v10.html
008: *
009: * Software distributed under the License is distributed on an "AS
010: * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
011: * implied. See the License for the specific language governing
012: * rights and limitations under the License.
013: *
014: * Copyright (C) 2002 Jan Arne Petersen <jpetersen@uni-bonn.de>
015: * Copyright (C) 2002 Benoit Cerrina <b.cerrina@wanadoo.fr>
016: * Copyright (C) 2002-2004 Anders Bengtsson <ndrsbngtssn@yahoo.se>
017: * Copyright (C) 2004 Thomas E Enebo <enebo@acm.org>
018: *
019: * Alternatively, the contents of this file may be used under the terms of
020: * either of the GNU General Public License Version 2 or later (the "GPL"),
021: * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
022: * in which case the provisions of the GPL or the LGPL are applicable instead
023: * of those above. If you wish to allow use of your version of this file only
024: * under the terms of either the GPL or the LGPL, and not to allow others to
025: * use your version of this file under the terms of the CPL, indicate your
026: * decision by deleting the provisions above and replace them with the notice
027: * and other provisions required by the GPL or the LGPL. If you do not delete
028: * the provisions above, a recipient may use your version of this file under
029: * the terms of any one of the CPL, the GPL or the LGPL.
030: ***** END LICENSE BLOCK *****/package org.jruby.ast;
031:
032: import java.io.IOException;
033: import java.util.List;
034:
035: import org.jruby.ast.visitor.NodeVisitor;
036: import org.jruby.evaluator.Instruction;
037: import org.jruby.lexer.yacc.ISourcePosition;
038: import org.jruby.runtime.MethodIndex;
039:
040: /**
041: *
042: * @author jpetersen
043: */
044: public class OpAsgnNode extends Node {
045: static final long serialVersionUID = -1950295226516487753L;
046:
047: private final Node receiverNode;
048: private final Node valueNode;
049: private String variableName;
050: private String operatorName;
051: private String variableNameAsgn;
052: public final int index;
053:
054: public OpAsgnNode(ISourcePosition position, Node receiverNode,
055: Node valueNode, String variableName, String methodName) {
056: super (position, NodeTypes.OPASGNNODE);
057: this .receiverNode = receiverNode;
058: this .valueNode = valueNode;
059: this .variableName = variableName.intern();
060: this .operatorName = methodName.intern();
061: this .variableNameAsgn = (variableName + "=").intern();
062: this .index = MethodIndex.getIndex(this .operatorName);
063: }
064:
065: private void readObject(java.io.ObjectInputStream in)
066: throws IOException, ClassNotFoundException {
067: in.defaultReadObject();
068:
069: // deserialized strings are not interned; intern it now
070: variableName = variableName.intern();
071: operatorName = operatorName.intern();
072: variableNameAsgn = variableNameAsgn.intern();
073: }
074:
075: /**
076: * Accept for the visitor pattern.
077: * @param iVisitor the visitor
078: **/
079: public Instruction accept(NodeVisitor iVisitor) {
080: return iVisitor.visitOpAsgnNode(this );
081: }
082:
083: /**
084: * Gets the methodName.
085: * @return Returns a String
086: */
087: public String getOperatorName() {
088: return operatorName;
089: }
090:
091: /**
092: * Gets the receiverNode.
093: * @return Returns a Node
094: */
095: public Node getReceiverNode() {
096: return receiverNode;
097: }
098:
099: /**
100: * Gets the valueNode.
101: * @return Returns a Node
102: */
103: public Node getValueNode() {
104: return valueNode;
105: }
106:
107: /**
108: * Gets the varibaleName.
109: * @return Returns a String
110: */
111: public String getVariableName() {
112: return variableName;
113: }
114:
115: public String getVariableNameAsgn() {
116: return variableNameAsgn;
117: }
118:
119: public List childNodes() {
120: return Node.createList(receiverNode, valueNode);
121: }
122:
123: }
|