internal override AST PartiallyEvaluate() { if (this.operand == null) { BlockScope bscope = null; for (ScriptObject scope = this.Engine.ScriptObjectStackTop(); scope != null; scope = scope.GetParent()) { if (scope is WithObject) { continue; } bscope = scope as BlockScope; if (bscope == null) { break; } if (bscope.catchHanderScope) { break; } } if (bscope == null) { this.context.HandleError(JSError.BadThrow); this.operand = new ConstantWrapper(null, this.context); } } else { this.operand = this.operand.PartiallyEvaluate(); } return(this); }
internal Try(Context context, AST body, AST identifier, TypeExpression type, AST handler, AST finally_block, bool finallyHasControlFlowOutOfIt, Context tryEndContext) : base(context) { this.body = body; this.type = type; this.handler = handler; this.finally_block = finally_block; ScriptObject current_scope = (ScriptObject)Globals.ScopeStack.Peek(); while (current_scope is WithObject) //Can only happen at run time and only if there is an eval current_scope = current_scope.GetParent(); this.handler_scope = null; this.field = null; if (identifier != null){ this.fieldName = identifier.ToString(); this.field = current_scope.GetField(this.fieldName, BindingFlags.Public|BindingFlags.Instance|BindingFlags.Static); if (this.field != null){ if (type == null && (field is JSVariableField && field.IsStatic && ((JSVariableField)field).type == null) && !field.IsLiteral && !field.IsInitOnly) return; //preserve legacy semantics by using the existing variable if (((IActivationObject)current_scope).GetLocalField(this.fieldName) != null) identifier.context.HandleError(JSError.DuplicateName, false); } this.handler_scope = new BlockScope(current_scope); this.handler_scope.catchHanderScope = true; JSVariableField f = this.handler_scope.AddNewField(identifier.ToString(), Missing.Value, FieldAttributes.Public); // must be a local this.field = f; f.originalContext = identifier.context; if (identifier.context.document.debugOn && this.field is JSLocalField){ this.handler_scope.AddFieldForLocalScopeDebugInfo((JSLocalField)this.field); } } this.finallyHasControlFlowOutOfIt = finallyHasControlFlowOutOfIt; this.tryEndContext = tryEndContext; }
internal override AST PartiallyEvaluate() { if (this.operand != null) { this.operand = this.operand.PartiallyEvaluate(); } else { BlockScope scope = null; for (ScriptObject obj2 = base.Engine.ScriptObjectStackTop(); obj2 != null; obj2 = obj2.GetParent()) { if (!(obj2 is WithObject)) { scope = obj2 as BlockScope; if ((scope == null) || scope.catchHanderScope) { break; } } } if (scope == null) { base.context.HandleError(JSError.BadThrow); this.operand = new ConstantWrapper(null, base.context); } } return(this); }
internal override Object Evaluate() { if (this.operand == null) { ScriptObject scope = this.Engine.ScriptObjectStackTop(); while (scope != null) { BlockScope bscope = scope as BlockScope; if (bscope != null && bscope.catchHanderScope) { throw (Exception)(bscope.GetFields(BindingFlags.Public | BindingFlags.Static)[0].GetValue(null)); } } } throw JScriptThrow(this.operand.Evaluate()); }
internal override object Evaluate() { if (this.operand == null) { ScriptObject obj2 = base.Engine.ScriptObjectStackTop(); while (obj2 != null) { BlockScope scope = obj2 as BlockScope; if ((scope != null) && scope.catchHanderScope) { throw ((Exception)scope.GetFields(BindingFlags.Public | BindingFlags.Static)[0].GetValue(null)); } } } throw JScriptThrow(this.operand.Evaluate()); }
internal Try(Context context, AST body, AST identifier, TypeExpression type, AST handler, AST finally_block, bool finallyHasControlFlowOutOfIt, Context tryEndContext) : base(context) { this.body = body; this.type = type; this.handler = handler; this.finally_block = finally_block; ScriptObject parent = base.Globals.ScopeStack.Peek(); while (parent is WithObject) { parent = parent.GetParent(); } this.handler_scope = null; this.field = null; if (identifier != null) { this.fieldName = identifier.ToString(); this.field = parent.GetField(this.fieldName, BindingFlags.Public | BindingFlags.Static | BindingFlags.Instance); if (this.field != null) { if ((((type == null) && (this.field is JSVariableField)) && (this.field.IsStatic && (((JSVariableField)this.field).type == null))) && (!this.field.IsLiteral && !this.field.IsInitOnly)) { return; } if (((IActivationObject)parent).GetLocalField(this.fieldName) != null) { identifier.context.HandleError(JSError.DuplicateName, false); } } this.handler_scope = new BlockScope(parent); this.handler_scope.catchHanderScope = true; JSVariableField field = this.handler_scope.AddNewField(identifier.ToString(), Microsoft.JScript.Missing.Value, FieldAttributes.Public); this.field = field; field.originalContext = identifier.context; if (identifier.context.document.debugOn && (this.field is JSLocalField)) { this.handler_scope.AddFieldForLocalScopeDebugInfo((JSLocalField)this.field); } } this.finallyHasControlFlowOutOfIt = finallyHasControlFlowOutOfIt; this.tryEndContext = tryEndContext; }
internal Try(Context context, AST body, AST identifier, TypeExpression type, AST handler, AST finally_block, bool finallyHasControlFlowOutOfIt, Context tryEndContext) : base(context) { this.body = body; this.type = type; this.handler = handler; this.finally_block = finally_block; ScriptObject current_scope = (ScriptObject)Globals.ScopeStack.Peek(); while (current_scope is WithObject) //Can only happen at run time and only if there is an eval { current_scope = current_scope.GetParent(); } this.handler_scope = null; this.field = null; if (identifier != null) { this.fieldName = identifier.ToString(); this.field = current_scope.GetField(this.fieldName, BindingFlags.Public | BindingFlags.Instance | BindingFlags.Static); if (this.field != null) { if (type == null && (field is JSVariableField && field.IsStatic && ((JSVariableField)field).type == null) && !field.IsLiteral && !field.IsInitOnly) { return; //preserve legacy semantics by using the existing variable } if (((IActivationObject)current_scope).GetLocalField(this.fieldName) != null) { identifier.context.HandleError(JSError.DuplicateName, false); } } this.handler_scope = new BlockScope(current_scope); this.handler_scope.catchHanderScope = true; JSVariableField f = this.handler_scope.AddNewField(identifier.ToString(), Missing.Value, FieldAttributes.Public); // must be a local this.field = f; f.originalContext = identifier.context; if (identifier.context.document.debugOn && this.field is JSLocalField) { this.handler_scope.AddFieldForLocalScopeDebugInfo((JSLocalField)this.field); } } this.finallyHasControlFlowOutOfIt = finallyHasControlFlowOutOfIt; this.tryEndContext = tryEndContext; }