raster@15779
|
1 |
/*
|
raster@15779
|
2 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
|
raster@15779
|
3 |
*
|
raster@15779
|
4 |
* Copyright 2008 Sun Microsystems, Inc. All rights reserved.
|
raster@15779
|
5 |
*
|
raster@15779
|
6 |
* The contents of this file are subject to the terms of either the GNU
|
raster@15779
|
7 |
* General Public License Version 2 only ("GPL") or the Common
|
raster@15779
|
8 |
* Development and Distribution License("CDDL") (collectively, the
|
raster@15779
|
9 |
* "License"). You may not use this file except in compliance with the
|
raster@15779
|
10 |
* License. You can obtain a copy of the License at
|
raster@15779
|
11 |
* http://www.netbeans.org/cddl-gplv2.html
|
raster@15779
|
12 |
* or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
|
raster@15779
|
13 |
* specific language governing permissions and limitations under the
|
raster@15779
|
14 |
* License. When distributing the software, include this License Header
|
raster@15779
|
15 |
* Notice in each file and include the License file at
|
raster@15779
|
16 |
* nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
|
raster@15779
|
17 |
* particular file as subject to the "Classpath" exception as provided
|
raster@15779
|
18 |
* by Sun in the GPL Version 2 section of the License file that
|
raster@15779
|
19 |
* accompanied this code. If applicable, add the following below the
|
raster@15779
|
20 |
* License Header, with the fields enclosed by brackets [] replaced by
|
raster@15779
|
21 |
* your own identifying information:
|
raster@15779
|
22 |
* "Portions Copyrighted [year] [name of copyright owner]"
|
raster@15779
|
23 |
*
|
raster@15779
|
24 |
* If you wish your version of this file to be governed by only the CDDL
|
raster@15779
|
25 |
* or only the GPL Version 2, indicate your decision by adding
|
raster@15779
|
26 |
* "[Contributor] elects to include this software in this distribution
|
raster@15779
|
27 |
* under the [CDDL or GPL Version 2] license." If you do not indicate a
|
raster@15779
|
28 |
* single choice of license, a recipient has the option to distribute
|
raster@15779
|
29 |
* your version of this file under either the CDDL, the GPL Version 2 or
|
raster@15779
|
30 |
* to extend the choice of license to its licensees as provided above.
|
raster@15779
|
31 |
* However, if you add GPL Version 2 code and therefore, elected the GPL
|
raster@15779
|
32 |
* Version 2 license, then the option applies only if the new code is
|
raster@15779
|
33 |
* made subject to such option by the copyright holder.
|
raster@15779
|
34 |
*
|
raster@15779
|
35 |
* Contributor(s):
|
raster@15779
|
36 |
*
|
raster@15779
|
37 |
* Portions Copyrighted 2008 Sun Microsystems, Inc.
|
raster@15779
|
38 |
*/
|
raster@15779
|
39 |
package org.netbeans.modules.ada.editor.ast.nodes;
|
raster@15779
|
40 |
|
raster@15779
|
41 |
import java.util.ArrayList;
|
raster@15779
|
42 |
import java.util.List;
|
raster@15779
|
43 |
import org.netbeans.modules.ada.editor.ast.nodes.visitors.Visitor;
|
raster@15779
|
44 |
|
raster@15779
|
45 |
/**
|
raster@15779
|
46 |
* Represents a procedure/function body (ARM95 - 6.3 Subprogram Bodies)
|
raster@15779
|
47 |
*
|
raster@15779
|
48 |
* <pre>e.g.<pre>
|
raster@15779
|
49 |
* procedure Push(E : in Element_Type; S : in out Stack) is
|
raster@15779
|
50 |
* begin
|
raster@15779
|
51 |
* if S.Index = S.Size then
|
raster@15779
|
52 |
* raise Stack_Overflow;
|
raster@15779
|
53 |
* else
|
raster@15779
|
54 |
* S.Index := S.Index + 1;
|
raster@15779
|
55 |
* S.Space(S.Index) := E;
|
raster@15779
|
56 |
* end if;
|
raster@15779
|
57 |
* end Push;
|
raster@15779
|
58 |
* function Dot_Product(Left, Right : Vector) return Real is
|
raster@15779
|
59 |
* Sum : Real := 0.0;
|
raster@15779
|
60 |
* begin
|
raster@15779
|
61 |
* Check(Left'First = Right'First and Left'Last = Right'Last);
|
raster@15779
|
62 |
* for J in Left'Range loop
|
raster@15779
|
63 |
* Sum := Sum + Left(J)*Right(J);
|
raster@15779
|
64 |
* end loop;
|
raster@15779
|
65 |
* return Sum;
|
raster@15779
|
66 |
* end Dot_Product;
|
raster@15779
|
67 |
*/
|
raster@15779
|
68 |
public class SubprogramBody extends Statement {
|
raster@15779
|
69 |
|
raster@16367
|
70 |
private SubprogramSpecification subprogramSpecification;
|
raster@16367
|
71 |
private Identifier subprogramNameEnd;
|
raster@15779
|
72 |
private Block declarations;
|
raster@15779
|
73 |
private Block body;
|
raster@15779
|
74 |
|
raster@15779
|
75 |
public SubprogramBody(int start, int end, SubprogramSpecification subprogramSpecification, Block declarations, Block body, Identifier subprogramNameEnd) {
|
raster@15779
|
76 |
super(start, end);
|
raster@16367
|
77 |
this.subprogramSpecification = subprogramSpecification;
|
raster@15779
|
78 |
this.declarations = declarations;
|
raster@15779
|
79 |
this.body = body;
|
raster@15779
|
80 |
this.subprogramNameEnd = subprogramNameEnd;
|
raster@15779
|
81 |
}
|
raster@15779
|
82 |
|
raster@15779
|
83 |
/**
|
raster@15779
|
84 |
* Local declarations of this subprogram
|
raster@15779
|
85 |
*
|
raster@15779
|
86 |
* @return Body of this subprogram
|
raster@15779
|
87 |
*/
|
raster@15779
|
88 |
public Block getDeclarations() {
|
raster@15779
|
89 |
return declarations;
|
raster@15779
|
90 |
}
|
raster@15779
|
91 |
|
raster@15779
|
92 |
/**
|
raster@15779
|
93 |
* Body of this subprogram
|
raster@15779
|
94 |
*
|
raster@15779
|
95 |
* @return Body of this subprogram
|
raster@15779
|
96 |
*/
|
raster@15779
|
97 |
public Block getBody() {
|
raster@15779
|
98 |
return body;
|
raster@15779
|
99 |
}
|
raster@15779
|
100 |
|
raster@16367
|
101 |
public SubprogramSpecification getSubprogramSpecification() {
|
raster@16367
|
102 |
return subprogramSpecification;
|
raster@16367
|
103 |
}
|
raster@15779
|
104 |
|
raster@16367
|
105 |
public Identifier getSubprogramNameEnd() {
|
raster@15779
|
106 |
return subprogramNameEnd;
|
raster@15779
|
107 |
}
|
raster@15779
|
108 |
|
raster@15779
|
109 |
@Override
|
raster@15779
|
110 |
public void accept(Visitor visitor) {
|
raster@15779
|
111 |
visitor.visit(this);
|
raster@15779
|
112 |
}
|
raster@15779
|
113 |
}
|