wasCSharpSQLite – Blame information for rev 4

Subversion Repositories:
Rev:
Rev Author Line No. Line
1 office 1 /*
2 * WhileCmd.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: WhileCmd.java,v 1.1.1.1 1998/10/14 21:09:20 cvsadmin Exp $
14 *
15 */
16 using System;
17 namespace tcl.lang
18 {
19  
20 /// <summary> This class implements the built-in "while" command in Tcl.</summary>
21  
22 class WhileCmd : Command
23 {
24 /// <summary> This procedure is invoked to process the "while" Tcl command.
25 /// See the user documentation for details on what it does.
26 ///
27 /// </summary>
28 /// <param name="interp">the current interpreter.
29 /// </param>
30 /// <param name="argv">command arguments.
31 /// </param>
32 /// <exception cref=""> TclException if script causes error.
33 /// </exception>
34  
35 public TCL.CompletionCode cmdProc( Interp interp, TclObject[] argv )
36 {
37 if ( argv.Length != 3 )
38 {
39 throw new TclNumArgsException( interp, 1, argv, "test command" );
40 }
41  
42 string test = argv[1].ToString();
43 TclObject command = argv[2];
44  
45 {
46 while ( interp.expr.evalBoolean( interp, test ) )
47 {
48 try
49 {
50 interp.eval( command, 0 );
51 }
52 catch ( TclException e )
53 {
54 switch ( e.getCompletionCode() )
55 {
56  
57 case TCL.CompletionCode.BREAK:
58 goto loop_brk;
59  
60  
61 case TCL.CompletionCode.CONTINUE:
62 continue;
63  
64  
65 case TCL.CompletionCode.ERROR:
66 interp.addErrorInfo( "\n (\"while\" body line " + interp.errorLine + ")" );
67 throw;
68  
69  
70 default:
71 throw;
72  
73 }
74 }
75 }
76 }
77  
78 loop_brk:
79 ;
80  
81  
82 interp.resetResult();
83 return TCL.CompletionCode.RETURN;
84 }
85 }
86 }