wasCSharpSQLite – Blame information for rev 4

Subversion Repositories:
Rev:
Rev Author Line No. Line
1 office 1 /*
2 * ForCmd.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: ForCmd.java,v 1.1.1.1 1998/10/14 21:09:19 cvsadmin Exp $
14 *
15 */
16 using System;
17 namespace tcl.lang
18 {
19  
20 /// <summary> This class implements the built-in "for" command in Tcl.</summary>
21  
22 class ForCmd : Command
23 {
24 /*
25 * This procedure is invoked to process the "for" Tcl command.
26 * See the user documentation for details on what it does.
27 *
28 * @param interp the current interpreter.
29 * @param argv command arguments.
30 * @exception TclException if script causes error.
31 */
32  
33 public TCL.CompletionCode cmdProc( Interp interp, TclObject[] argv )
34 {
35 if ( argv.Length != 5 )
36 {
37 throw new TclNumArgsException( interp, 1, argv, "start test next command" );
38 }
39  
40 TclObject start = argv[1];
41  
42 string test = argv[2].ToString();
43 TclObject next = argv[3];
44 TclObject command = argv[4];
45  
46 bool done = false;
47 try
48 {
49 interp.eval( start, 0 );
50 }
51 catch ( TclException e )
52 {
53 interp.addErrorInfo( "\n (\"for\" initial command)" );
54 throw;
55 }
56  
57 while ( !done )
58 {
59 if ( !interp.expr.evalBoolean( interp, test ) )
60 {
61 break;
62 }
63  
64 try
65 {
66 interp.eval( command, 0 );
67 }
68 catch ( TclException e )
69 {
70 switch ( e.getCompletionCode() )
71 {
72  
73 case TCL.CompletionCode.BREAK:
74 done = true;
75 break;
76  
77  
78 case TCL.CompletionCode.CONTINUE:
79 break;
80  
81  
82 case TCL.CompletionCode.ERROR:
83 interp.addErrorInfo( "\n (\"for\" body line " + interp.errorLine + ")" );
84 throw;
85  
86  
87 default:
88 throw;
89  
90 }
91 }
92  
93 if ( !done )
94 {
95 try
96 {
97 interp.eval( next, 0 );
98 }
99 catch ( TclException e )
100 {
101 switch ( e.getCompletionCode() )
102 {
103  
104 case TCL.CompletionCode.BREAK:
105 done = true;
106 break;
107  
108  
109 case TCL.CompletionCode.CONTINUE:
110 break;
111  
112  
113 default:
114 interp.addErrorInfo( "\n (\"for\" loop-end command)" );
115 throw;
116  
117 }
118 }
119 }
120 }
121  
122 interp.resetResult();
123 return TCL.CompletionCode.RETURN;
124 }
125 }
126 }