4 // Author: Cesar Octavio Lopez Nataren
6 // (C) 2003, 2004, Cesar Octavio Lopez Nataren
10 // Permission is hereby granted, free of charge, to any person obtaining
11 // a copy of this software and associated documentation files (the
12 // "Software"), to deal in the Software without restriction, including
13 // without limitation the rights to use, copy, modify, merge, publish,
14 // distribute, sublicense, and/or sell copies of the Software, and to
15 // permit persons to whom the Software is furnished to do so, subject to
16 // the following conditions:
18 // The above copyright notice and this permission notice shall be
19 // included in all copies or substantial portions of the Software.
21 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
22 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
23 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
24 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
25 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
26 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
27 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
31 using Microsoft.JScript.Vsa;
32 using System.Reflection;
33 using System.Reflection.Emit;
34 using System.Collections;
36 namespace Microsoft.JScript {
38 public sealed class Try : AST {
40 internal FieldBuilder field_info;
41 internal LocalBuilder local_builder;
43 internal AST guarded_block;
44 internal ArrayList catch_blocks;
45 internal AST finally_block;
48 internal Try (AST guarded_block, ArrayList catch_block, AST finally_block, AST parent, int line_number)
51 this.guarded_block = guarded_block;
52 this.catch_blocks = catch_block;
53 this.finally_block = finally_block;
56 public static Object JScriptExceptionValue (object e, VsaEngine engine)
58 throw new NotImplementedException ();
61 public static void PushHandlerScope (VsaEngine engine, string id, int scopeId)
63 throw new NotImplementedException ();
66 internal override bool Resolve (IdentificationTable context)
69 if (guarded_block != null)
70 r &= guarded_block.Resolve (context);
72 if (catch_blocks != null && catch_blocks.Count > 0) {
73 foreach (Catch c in catch_blocks) {
75 context.Enter (c.id, c);
76 r &= c.Resolve (context);
77 context.CloseBlock ();
80 if (finally_block != null)
81 r &= finally_block.Resolve (context);
85 internal override void Emit (EmitContext ec)
87 ILGenerator ig = ec.ig;
89 ig.BeginExceptionBlock ();
91 if (guarded_block != null)
92 guarded_block.Emit (ec);
94 if (catch_blocks != null && catch_blocks.Count > 0) {
95 foreach (Catch c in catch_blocks)
98 if (finally_block != null) {
99 ig.BeginFinallyBlock ();
100 finally_block.Emit (ec);
102 ig.EndExceptionBlock ();