01: /*
02: * EvalCmd.java
03: *
04: * Copyright (c) 1997 Cornell University.
05: * Copyright (c) 1997 Sun Microsystems, Inc.
06: *
07: * See the file "license.terms" for information on usage and
08: * redistribution of this file, and for a DISCLAIMER OF ALL
09: * WARRANTIES.
10: *
11: * RCS: @(#) $Id: EvalCmd.java,v 1.3 2005/11/16 21:08:11 mdejong Exp $
12: *
13: */
14:
15: package tcl.lang;
16:
17: /**
18: * This class implements the built-in "eval" command in Tcl.
19: */
20:
21: class EvalCmd implements Command {
22: /**
23: * This procedure is invoked to process the "eval" Tcl command.
24: * See the user documentation for details on what it does.
25: *
26: * @param interp the current interpreter.
27: * @param argv command arguments.
28: * @exception TclException if script causes error.
29: */
30:
31: public void cmdProc(Interp interp, TclObject[] objv)
32: throws TclException {
33: if (objv.length < 2) {
34: throw new TclNumArgsException(interp, 1, objv,
35: "arg ?arg ...?");
36: }
37:
38: try {
39: if (objv.length == 2) {
40: interp.eval(objv[1], 0);
41: } else {
42: TclObject obj = Util.concat(1, objv.length - 1, objv);
43: interp.eval(obj, 0);
44: }
45: } catch (TclException e) {
46: if (e.getCompletionCode() == TCL.ERROR) {
47: interp.addErrorInfo("\n (\"eval\" body line "
48: + interp.errorLine + ")");
49: }
50: throw e;
51: }
52: }
53: }
|