wasCSharpSQLite – Blame information for rev 3

Subversion Repositories:
Rev:
Rev Author Line No. Line
1 office 1 /*
2 * ReturnCmd.java --
3 *
4 * This file implements the Tcl "return" 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: ReturnCmd.java,v 1.1.1.1 1998/10/14 21:09:19 cvsadmin Exp $
16 *
17 */
18 using System;
19 namespace tcl.lang
20 {
21  
22 /*
23 * This class implements the built-in "return" command in Tcl.
24 */
25  
26 class ReturnCmd : Command
27 {
28  
29 public TCL.CompletionCode cmdProc( Interp interp, TclObject[] argv )
30 {
31 interp.errorCode = null;
32 interp.errorInfo = null;
33 TCL.CompletionCode returnCode;
34 int i;
35  
36 /*
37 * Note: returnCode is the value given by the -code option. Don't
38 * confuse this value with the compCode variable of the
39 * TclException thrown by this method, which is always TCL.CompletionCode.RETURN.
40 */
41  
42 returnCode = TCL.CompletionCode.OK;
43 for ( i = 1; i < argv.Length - 1; i += 2 )
44 {
45  
46 if ( argv[i].ToString().Equals( "-code" ) )
47 {
48  
49 if ( argv[i + 1].ToString().Equals( "ok" ) )
50 {
51 returnCode = TCL.CompletionCode.OK;
52 }
53 else
54 {
55  
56 if ( argv[i + 1].ToString().Equals( "error" ) )
57 {
58 returnCode = TCL.CompletionCode.ERROR;
59 }
60 else
61 {
62  
63 if ( argv[i + 1].ToString().Equals( "return" ) )
64 {
65 returnCode = TCL.CompletionCode.RETURN;
66 }
67 else
68 {
69  
70 if ( argv[i + 1].ToString().Equals( "break" ) )
71 {
72 returnCode = TCL.CompletionCode.BREAK;
73 }
74 else
75 {
76  
77 if ( argv[i + 1].ToString().Equals( "continue" ) )
78 {
79 returnCode = TCL.CompletionCode.CONTINUE;
80 }
81 else
82 {
83 try
84 {
85 returnCode = (TCL.CompletionCode)TclInteger.get( interp, argv[i + 1] );
86 }
87 catch ( TclException e )
88 {
89  
90 throw new TclException( interp, "bad completion code \"" + argv[i + 1] + "\": must be ok, error, return, break, " + "continue, or an integer" );
91 }
92 }
93 }
94 }
95 }
96 }
97 }
98 else
99 {
100  
101 if ( argv[i].ToString().Equals( "-errorcode" ) )
102 {
103  
104 interp.errorCode = argv[i + 1].ToString();
105 }
106 else
107 {
108  
109 if ( argv[i].ToString().Equals( "-errorinfo" ) )
110 {
111  
112 interp.errorInfo = argv[i + 1].ToString();
113 }
114 else
115 {
116  
117 throw new TclException( interp, "bad option \"" + argv[i] + "\": must be -code, -errorcode, or -errorinfo" );
118 }
119 }
120 }
121 }
122 if ( i != argv.Length )
123 {
124 interp.setResult( argv[argv.Length - 1] );
125 }
126  
127 interp.returnCode = returnCode;
128 throw new TclException( TCL.CompletionCode.RETURN );
129 }
130 } // end ReturnCmd
131 }