ada.editor/src/org/netbeans/modules/ada/editor/ast/nodes/FormalParameter.java
author Andrea Lucarelli <raster@netbeans.org>
Sun, 22 Aug 2010 23:37:11 +0200
branchrelease68
changeset 16367 d2820c029d3a
parent 15779 367c7fdb5d23
permissions -rw-r--r--
Add JVM compiler support.
raster@14695
     1
/*
raster@14695
     2
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
raster@14695
     3
 * 
raster@14695
     4
 * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
raster@14695
     5
 * 
raster@14695
     6
 * The contents of this file are subject to the terms of either the GNU
raster@14695
     7
 * General Public License Version 2 only ("GPL") or the Common
raster@14695
     8
 * Development and Distribution License("CDDL") (collectively, the
raster@14695
     9
 * "License"). You may not use this file except in compliance with the
raster@14695
    10
 * License. You can obtain a copy of the License at
raster@14695
    11
 * http://www.netbeans.org/cddl-gplv2.html
raster@14695
    12
 * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
raster@14695
    13
 * specific language governing permissions and limitations under the
raster@14695
    14
 * License.  When distributing the software, include this License Header
raster@14695
    15
 * Notice in each file and include the License file at
raster@14695
    16
 * nbbuild/licenses/CDDL-GPL-2-CP.  Sun designates this
raster@14695
    17
 * particular file as subject to the "Classpath" exception as provided
raster@14695
    18
 * by Sun in the GPL Version 2 section of the License file that
raster@14695
    19
 * accompanied this code. If applicable, add the following below the
raster@14695
    20
 * License Header, with the fields enclosed by brackets [] replaced by
raster@14695
    21
 * your own identifying information:
raster@14695
    22
 * "Portions Copyrighted [year] [name of copyright owner]"
raster@14695
    23
 * 
raster@14695
    24
 * If you wish your version of this file to be governed by only the CDDL
raster@14695
    25
 * or only the GPL Version 2, indicate your decision by adding
raster@14695
    26
 * "[Contributor] elects to include this software in this distribution
raster@14695
    27
 * under the [CDDL or GPL Version 2] license." If you do not indicate a
raster@14695
    28
 * single choice of license, a recipient has the option to distribute
raster@14695
    29
 * your version of this file under either the CDDL, the GPL Version 2 or
raster@14695
    30
 * to extend the choice of license to its licensees as provided above.
raster@14695
    31
 * However, if you add GPL Version 2 code and therefore, elected the GPL
raster@14695
    32
 * Version 2 license, then the option applies only if the new code is
raster@14695
    33
 * made subject to such option by the copyright holder.
raster@14695
    34
 * 
raster@14695
    35
 * Contributor(s):
raster@14695
    36
 * 
raster@14695
    37
 * Portions Copyrighted 2008 Sun Microsystems, Inc.
raster@14695
    38
 */
raster@14695
    39
package org.netbeans.modules.ada.editor.ast.nodes;
raster@14695
    40
raster@14695
    41
import org.netbeans.modules.ada.editor.ast.ASTNode;
raster@14695
    42
import org.netbeans.modules.ada.editor.ast.nodes.visitors.Visitor;
raster@14695
    43
raster@14695
    44
/**
raster@14695
    45
 * Represents a function/procedure formal parameter
raster@15779
    46
 * <pre>e.g.<pre>
raster@14695
    47
 * procedure Foo (a : in bar; b : in out foo_bar; c : out boolean)
raster@14695
    48
 * function Foo (a : in bar; b : in foo_bar) return boolean
raster@14695
    49
 */
raster@14695
    50
public class FormalParameter extends ASTNode {
raster@14695
    51
raster@14695
    52
    public enum Mode {
raster@14695
    53
        IN, OUT, IN_OUT, ACCESS;
raster@14695
    54
    }
raster@14695
    55
    private Variable parameterName;
raster@14695
    56
    private Mode parameterMode;
raster@16367
    57
    private NameBase parameterType;
raster@14695
    58
    private Expression defaultValue;
raster@14695
    59
raster@16367
    60
    public FormalParameter(int start, int end, final Variable parameterName, Mode parameterMode, NameBase type, Expression defaultValue) {
raster@14695
    61
        super(start, end);
raster@14695
    62
raster@14695
    63
        this.parameterName = parameterName;
raster@14695
    64
        this.parameterMode = parameterMode;
raster@14695
    65
        this.parameterType = type;
raster@14695
    66
        this.defaultValue = defaultValue;
raster@14695
    67
    }
raster@14695
    68
raster@16367
    69
    public FormalParameter(int start, int end, final Variable parameterName, Mode parameterMode, NameBase type) {
raster@14695
    70
        this(start, end, parameterName, parameterMode, type, null);
raster@14695
    71
    }
raster@14695
    72
raster@14695
    73
    /**
raster@14695
    74
     * @return default value of this parameter
raster@14695
    75
     */
raster@14695
    76
    public Expression getDefaultValue() {
raster@14695
    77
        return defaultValue;
raster@14695
    78
    }
raster@14695
    79
raster@14695
    80
    /**
raster@14695
    81
     * @return the name of this parameter
raster@14695
    82
     */
raster@14695
    83
    public Variable getParameterName() {
raster@14695
    84
        return parameterName;
raster@14695
    85
    }
raster@14695
    86
raster@16367
    87
    /**
raster@14695
    88
     * @return the mode of this parameter
raster@14695
    89
     */
raster@14695
    90
    public Mode getParameterMode() {
raster@14695
    91
        return parameterMode;
raster@14695
    92
    }
raster@14695
    93
raster@14695
    94
    /**
raster@14695
    95
     * @return the type of this parameter
raster@14695
    96
     */
raster@16367
    97
    public NameBase getParameterType() {
raster@14695
    98
        return parameterType;
raster@14695
    99
    }
raster@16367
   100
raster@14695
   101
    @Override
raster@14695
   102
    public void accept(Visitor visitor) {
raster@14695
   103
        visitor.visit(this);
raster@14695
   104
    }
raster@14695
   105
}