View Javadoc

1   package net.sf.tomp.xtcl.command;
2   
3   import net.sf.tomp.xtcl.Context;
4   
5   /***
6    * A Call to a Function. Passes parameters.
7    * 
8    * @author tomp
9    */
10  public class Call extends TryBlock {
11      /*** DOCUMENT ME! */
12      protected String name;
13  
14      /*** DOCUMENT ME! */
15      protected String[] passes;
16  
17      /***
18       * DOCUMENT ME!
19       * 
20       * @param p DOCUMENT ME!
21       */
22      public void setName(String p) {
23          name = p;
24      }
25  
26      /***
27       * DOCUMENT ME!
28       * 
29       * @param r DOCUMENT ME!
30       */
31      public void setPasses(String[] r) {
32          passes = r;
33      }
34  
35      /***
36       * DOCUMENT ME!
37       * 
38       * @param c DOCUMENT ME!
39       * @return DOCUMENT ME!
40       * @throws Exception DOCUMENT ME!
41       */
42      public int execute(Context c) throws Exception {
43          int retCode = 0;
44          Context prev = c.getPrevious();
45          Function function = (Function) c.get(name);
46  
47          for (int i = 0; i < passes.length; i++) {
48              Object v = prev.get(passes[i]);
49  
50              System.err.print("realparref=" + passes[i]);
51              System.err.print(", realparvalue=" + v);
52  
53              if (v == null) {
54                  if (c.isStrictPassing()) {
55                      retCode = 1;
56  
57                      break;
58                  }
59              } else {
60                  c.put(function.param(i), v);
61                  System.err.println(", assigned to formalpar="
62                          + function.param(i));
63              }
64          }
65  
66          if (retCode == 0) {
67              retCode = function.execute(c);
68          }
69  
70          return done(c, retCode);
71      }
72  
73      /***
74       * DOCUMENT ME!
75       * 
76       * @return DOCUMENT ME!
77       */
78      public String toString() {
79          return "CALL " + name + " (" + listArray(passes) + ")";
80      }
81  }
82  
83  /*
84   * The contents of this file are subject to the Mozilla Public License Version
85   * 1.1 (the "License"); you may not use this file except in compliance with the
86   * License. You may obtain a copy of the License at http://www.mozilla.org/MPL/
87   * Software distributed under the License is distributed on an "AS IS" basis,
88   * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
89   * the specific language governing rights and limitations under the License. The
90   * Original Code is: all this file. The Initial Developer of the Original Code
91   * is: Tomas Pitner, Masaryk University in Brno, Czech Republic. Contributor(s):
92   */