wasCSharpSQLite – Blame information for rev 4

Subversion Repositories:
Rev:
Rev Author Line No. Line
1 office 1 /*
2 * UplevelCmd.java --
3 *
4 * Implements the "uplevel" command.
5 *
6 * Copyright (c) 1997 Cornell University.
7 * Copyright (c) 1997 Sun Microsystems, Inc.
8 *
9 * See the file "license.terms" for information on usage and
10 * redistribution of this file, and for a DISCLAIMER OF ALL
11 * WARRANTIES.
12 *
13 * Included in SQLite3 port to C# for use in testharness only; 2008 Noah B Hart
14 *
15 * RCS @(#) $Id: UplevelCmd.java,v 1.3 1999/07/12 02:38:53 mo Exp $
16 *
17 */
18 using System;
19 namespace tcl.lang
20 {
21  
22 /*
23 * This class implements the built-in "uplevel" command in Tcl.
24 */
25  
26 class UplevelCmd : Command
27 {
28  
29 public TCL.CompletionCode cmdProc( Interp interp, TclObject[] objv )
30 {
31 string optLevel;
32 int result;
33 CallFrame savedVarFrame, frame;
34 int objc = objv.Length;
35 int objv_index;
36 TclObject cmd;
37  
38 if ( objv.Length < 2 )
39 {
40 throw new TclNumArgsException( interp, 1, objv, "?level? command ?arg ...?" );
41 }
42  
43 // Find the level to use for executing the command.
44  
45  
46 optLevel = objv[1].ToString();
47 // Java does not support passing a reference by refernece so use an array
48 CallFrame[] frameArr = new CallFrame[1];
49 result = CallFrame.getFrame( interp, optLevel, frameArr );
50 frame = frameArr[0];
51  
52 objc -= ( result + 1 );
53 if ( objc == 0 )
54 {
55 throw new TclNumArgsException( interp, 1, objv, "?level? command ?arg ...?" );
56 }
57 objv_index = ( result + 1 );
58  
59 // Modify the interpreter state to execute in the given frame.
60  
61 savedVarFrame = interp.varFrame;
62 interp.varFrame = frame;
63  
64 // Execute the residual arguments as a command.
65  
66 if ( objc == 1 )
67 {
68 cmd = objv[objv_index];
69 }
70 else
71 {
72 cmd = TclString.newInstance( Util.concat( objv_index, objv.Length - 1, objv ) );
73 }
74 cmd.preserve();
75  
76 try
77 {
78 interp.eval( cmd, 0 );
79 }
80 catch ( TclException e )
81 {
82 if ( e.getCompletionCode() == TCL.CompletionCode.ERROR )
83 {
84 interp.addErrorInfo( "\n (\"uplevel\" body line " + interp.errorLine + ")" );
85 }
86 throw;
87 }
88 finally
89 {
90 interp.varFrame = savedVarFrame;
91 cmd.release();
92 }
93 return TCL.CompletionCode.RETURN;
94 }
95 } // end UplevelCmd
96 }