Source code: com/tripi/asp/DefineIdentNode.java
1 /**
2 * ArrowHead ASP Server
3 * This is a source file for the ArrowHead ASP Server - an 100% Java
4 * VBScript interpreter and ASP server.
5 *
6 * For more information, see http://www.tripi.com/arrowhead
7 *
8 * Copyright (C) 2002 Terence Haddock
9 *
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
14 *
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
19 *
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
23 *
24 */
25 package com.tripi.asp;
26
27 /**
28 * Implements the definition of an ident.
29 *
30 * @author Terence Haddock
31 * @version 0.9
32 */
33 public class DefineIdentNode extends DefaultNode
34 {
35 /** Name of ident to define */
36 IdentNode ident;
37
38 /**
39 * Constructor.
40 *
41 * @param ident Name of the identifier to define
42 */
43 public DefineIdentNode(IdentNode ident)
44 {
45 this.ident = ident;
46 }
47
48 /**
49 * Get the ident this node is defining.
50 * @param ident ident this node is defining
51 */
52 public IdentNode getIdent()
53 {
54 return ident;
55 }
56
57 /**
58 * Dumps this expression.
59 *
60 * @see Node#dump()
61 * @throws AspException if an error occurs.
62 */
63 public void dump() throws AspException
64 {
65 System.out.print("DIM ");
66 ident.dump();
67 System.out.println();
68 }
69
70 /**
71 * Prepares this expression, this involves setting the scope of
72 * the dimension statement.
73 *
74 * @param scope AspContext under which to prepare this expression.
75 * @see Node#prepare(AspContext)
76 * @throws AspException if an error occurs
77 */
78 public void prepare(AspContext scope) throws AspException
79 {
80 /* Check if this variable is already in scope */
81 if (scope.inDirectScope(ident)) {
82 throw new AspRedefineIdentException(ident.toString());
83 }
84 scope.forceScope(ident);
85 }
86
87
88 /**
89 * Executes this expression.
90 *
91 * @param scope AspContext under which to evaluate this expression.
92 * @return always null
93 * @see Node#execute(AspContext)
94 * @throws AspException if an error occurs.
95 */
96 public Object execute(AspContext scope) throws AspException
97 {
98 return null;
99 }
100 };
101