wasCSharpSQLite – Blame information for rev 1

Subversion Repositories:
Rev:
Rev Author Line No. Line
1 office 1 /*
2 * GlobalCmd.java
3 *
4 * Copyright (c) 1997 Cornell University.
5 * Copyright (c) 1997 Sun Microsystems, Inc.
6 *
7 * See the file "license.terms" for information on usage and
8 * redistribution of this file, and for a DISCLAIMER OF ALL
9 * WARRANTIES.
10 *
11 * Included in SQLite3 port to C# for use in testharness only; 2008 Noah B Hart
12 *
13 * RCS @(#) $Id: GlobalCmd.java,v 1.2 1999/08/03 02:55:41 mo Exp $
14 *
15 */
16 using System;
17 namespace tcl.lang
18 {
19  
20 /// <summary> This class implements the built-in "global" command in Tcl.</summary>
21  
22 class GlobalCmd : Command
23 {
24 /// <summary> See Tcl user documentation for details.</summary>
25  
26 public TCL.CompletionCode cmdProc( Interp interp, TclObject[] objv )
27 {
28 if ( objv.Length < 2 )
29 {
30 throw new TclNumArgsException( interp, 1, objv, "varName ?varName ...?" );
31 }
32  
33 // If we are not executing inside a Tcl procedure, just return.
34  
35 if ( ( interp.varFrame == null ) || !interp.varFrame.isProcCallFrame )
36 {
37 return TCL.CompletionCode.RETURN;
38 }
39  
40 for ( int i = 1; i < objv.Length; i++ )
41 {
42  
43 // Make a local variable linked to its counterpart in the global ::
44 // namespace.
45  
46 TclObject obj = objv[i];
47  
48 string varName = obj.ToString();
49  
50 // The variable name might have a scope qualifier, but the name for
51 // the local "link" variable must be the simple name at the tail.
52  
53 int tail = varName.Length;
54  
55 tail -= 1; // tail should start on the last index of the string
56  
57 while ( ( tail > 0 ) && ( ( varName[tail] != ':' ) || ( varName[tail - 1] != ':' ) ) )
58 {
59 tail--;
60 }
61 if ( varName[tail] == ':' )
62 {
63 tail++;
64 }
65  
66 // Link to the variable "varName" in the global :: namespace.
67  
68 Var.makeUpvar( interp, null, varName, null, TCL.VarFlag.GLOBAL_ONLY, varName.Substring( tail ), 0 );
69 }
70 return TCL.CompletionCode.RETURN;
71 }
72 }
73 }