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) 2001-2002 Jan Arne Petersen <jpetersen@uni-bonn.de>
015: * Copyright (C) 2001-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.util.List;
033:
034: import org.jruby.ast.visitor.NodeVisitor;
035: import org.jruby.evaluator.Instruction;
036: import org.jruby.lexer.yacc.ISourcePosition;
037: import org.jruby.parser.StaticScope;
038:
039: /** Singleton class definition.
040: *
041: * <pre>
042: * class << anObject
043: *
044: * end
045: * </pre>
046: *
047: * @author jpetersen
048: */
049: public class SClassNode extends Node {
050: static final long serialVersionUID = -3706492163082062224L;
051:
052: private final Node receiverNode;
053: private final StaticScope scope;
054: private final Node bodyNode;
055:
056: public SClassNode(ISourcePosition position, Node recvNode,
057: StaticScope scope, Node bodyNode) {
058: super (position, NodeTypes.SCLASSNODE);
059: this .receiverNode = recvNode;
060: this .scope = scope;
061: this .bodyNode = bodyNode;
062: }
063:
064: /**
065: * Accept for the visitor pattern.
066: * @param iVisitor the visitor
067: **/
068: public Instruction accept(NodeVisitor iVisitor) {
069: return iVisitor.visitSClassNode(this );
070: }
071:
072: /**
073: * Gets the body of this class.
074: *
075: * @return the contents
076: */
077: public Node getBodyNode() {
078: return bodyNode;
079: }
080:
081: /**
082: * Gets the scope of this class
083: *
084: * @return the scope
085: */
086: public StaticScope getScope() {
087: return scope;
088: }
089:
090: /**
091: * Gets the receiverNode.
092: * @return Returns a Node
093: */
094: public Node getReceiverNode() {
095: return receiverNode;
096: }
097:
098: public List childNodes() {
099: return Node.createList(receiverNode, bodyNode);
100: }
101: }
|