From: Miguel de Icaza Date: Tue, 6 Mar 2007 05:03:47 +0000 (-0000) Subject: 2007-03-01 Peter Dettman X-Git-Url: http://wien.tomnetworks.com/gitweb/?a=commitdiff_plain;h=01fd2cd291716ce66f59f0e353afded18033cfe4;p=mono.git 2007-03-01 Peter Dettman * mjs-most.tests: Enable ecma/Boolean/15.6.3.1-3.js. * mjs-most.fail: Delete ecma/String/15.5.5.1.js, ecma/FunctionObjects/15.3.3.1-3.js, ecma/Number/15.7.3.3-2.js, and ecma/Number/15.7.3.5-2.js, as they no longer fail. 2007-03-01 Peter Dettman * expression.cs: Expression.Emit changed to correctly leave a value on the stack or not according to the 'no_effect' field, including the case where the final AST in the list is an Assign. Fixed a reentrancy bug in Args.Emit. * Block.cs, ForIn.cs, Statement.cs: Correctly resolve child expressions with "no effect" where they should behave as statements. svn path=/trunk/mcs/; revision=73783 --- diff --git a/mcs/class/Microsoft.JScript/Microsoft.JScript/Block.cs b/mcs/class/Microsoft.JScript/Microsoft.JScript/Block.cs index 5d3d443b0e2..0355e53879c 100644 --- a/mcs/class/Microsoft.JScript/Microsoft.JScript/Block.cs +++ b/mcs/class/Microsoft.JScript/Microsoft.JScript/Block.cs @@ -108,21 +108,13 @@ namespace Microsoft.JScript { internal override bool Resolve (Environment env) { AST e; - bool no_effect; bool r = true; int i, n = elems.Count; - if (parent == null || parent is FunctionDeclaration) - no_effect = true; - else - no_effect = false; - - n = elems.Count; - for (i = 0; i < n; i++) { e = (AST) elems [i]; if (e is Exp) - r &= ((Exp) e).Resolve (env, no_effect); + r &= ((Exp) e).Resolve (env, true); else r &= e.Resolve (env); } diff --git a/mcs/class/Microsoft.JScript/Microsoft.JScript/ChangeLog b/mcs/class/Microsoft.JScript/Microsoft.JScript/ChangeLog index ef872555a06..c8f45f8bb6d 100644 --- a/mcs/class/Microsoft.JScript/Microsoft.JScript/ChangeLog +++ b/mcs/class/Microsoft.JScript/Microsoft.JScript/ChangeLog @@ -1,3 +1,12 @@ +2007-03-01 Peter Dettman + + * expression.cs: Expression.Emit changed to correctly leave a value on the + stack or not according to the 'no_effect' field, including the case where + the final AST in the list is an Assign. Fixed a reentrancy bug in Args.Emit. + + * Block.cs, ForIn.cs, Statement.cs: Correctly resolve child expressions with + "no effect" where they should behave as statements. + 2006-10-21 Miguel de Icaza * JScriptCodeCompiler.cs: Ifdefed out unused code. diff --git a/mcs/class/Microsoft.JScript/Microsoft.JScript/ForIn.cs b/mcs/class/Microsoft.JScript/Microsoft.JScript/ForIn.cs index 4c765872234..c21ec4049fa 100644 --- a/mcs/class/Microsoft.JScript/Microsoft.JScript/ForIn.cs +++ b/mcs/class/Microsoft.JScript/Microsoft.JScript/ForIn.cs @@ -84,8 +84,12 @@ namespace Microsoft.JScript { if (obj != null) r &= obj.Resolve (env); - if (body != null) - r &= body.Resolve (env); + if (body != null) { + if (body is Exp) + r &= ((Exp) body).Resolve (env, true); + else + r &= body.Resolve (env); + } return r; } diff --git a/mcs/class/Microsoft.JScript/Microsoft.JScript/Statement.cs b/mcs/class/Microsoft.JScript/Microsoft.JScript/Statement.cs index f04e9b64b76..2300d015169 100644 --- a/mcs/class/Microsoft.JScript/Microsoft.JScript/Statement.cs +++ b/mcs/class/Microsoft.JScript/Microsoft.JScript/Statement.cs @@ -350,7 +350,10 @@ namespace Microsoft.JScript { bool r = true; if (stm != null) - r &= stm.Resolve (env); + if (stm is Exp) + r &= ((Exp) stm).Resolve (env, true); + else + r &= stm.Resolve (env); if (exp != null) r &= exp.Resolve (env); return r; @@ -421,7 +424,10 @@ namespace Microsoft.JScript { else r &= exp.Resolve (env); if (stm != null) - r &= stm.Resolve (env); + if (stm is Exp) + r &= ((Exp) stm).Resolve (env, true); + else + r &= stm.Resolve (env); return r; } @@ -498,8 +504,14 @@ namespace Microsoft.JScript { { bool r = true; - foreach (AST ast in exprs) - r &= ast.Resolve (env); + for (int i = 0; i < 3; ++i) { + AST e = exprs[i]; + if (e is Exp) + r &= ((Exp) e).Resolve (env, i != 1); + else + r &= e.Resolve (env); + } + if (stms != null) r &= stms.Resolve (env); return true; @@ -630,8 +642,12 @@ namespace Microsoft.JScript { foreach (Clause c in case_clauses) r &= c.Resolve (env); if (default_clauses != null) - foreach (AST dc in default_clauses) - r &= dc.Resolve (env); + foreach (AST dc in default_clauses) { + if (dc is Exp) + r &= ((Exp) dc).Resolve (env, true); + else + r &= dc.Resolve (env); + } if (sec_case_clauses != null) foreach (Clause sc in sec_case_clauses) r &= sc.Resolve (env); @@ -724,8 +740,12 @@ namespace Microsoft.JScript { bool r = true; if (exp != null) r &= exp.Resolve (env); - foreach (AST ast in stm_list) - r &= ast.Resolve (env); + foreach (AST ast in stm_list) { + if (ast is Exp) + r &= ((Exp) ast).Resolve (env, true); + else + r &= ast.Resolve (env); + } return r; } diff --git a/mcs/class/Microsoft.JScript/Microsoft.JScript/expression.cs b/mcs/class/Microsoft.JScript/Microsoft.JScript/expression.cs index eee9f29f92c..369eddb144f 100644 --- a/mcs/class/Microsoft.JScript/Microsoft.JScript/expression.cs +++ b/mcs/class/Microsoft.JScript/Microsoft.JScript/expression.cs @@ -1759,6 +1759,9 @@ namespace Microsoft.JScript { bool strong_type = BoundToMethod is MethodInfo; ParameterInfo [] parameters = null; + // We may be called more than once, so avoid modifying fields + int expected_args = this.expected_args; + if (!BoundToDeclaredFunction) { if (has_this) expected_args--; @@ -1964,28 +1967,17 @@ namespace Microsoft.JScript { internal override bool Resolve (Environment env) { - int i, n; - object e; + int n = exprs.Count - 1; bool r = true; - - n = exprs.Count - 1; + object e; - for (i = 0; i < n; i++) { + for (int i = 0; i <= n; i++) { e = exprs [i]; if (e is Exp) - if (e is Assign) - r &= ((Assign) e).Resolve (env); - else - r &= ((Exp) e).Resolve (env, true); - } - e = exprs [n]; - if (e is Exp) - if (e is Assign) - r &= ((Assign) e).Resolve (env); + r &= ((Exp) e).Resolve (env, i < n || no_effect); else - r &= ((Exp) e).Resolve (env, no_effect); - else - ((AST) e).Resolve (env); + r &= ((AST) e).Resolve (env); + } return r; } @@ -1998,13 +1990,27 @@ namespace Microsoft.JScript { internal override void Emit (EmitContext ec) { - int i, n = exprs.Count; + int i, n = exprs.Count - 1; AST exp; for (i = 0; i < n; i++) { exp = (AST) exprs [i]; exp.Emit (ec); - CodeGenerator.EmitBox (ec.ig, exp); + } + if (n >= 0) + { + exp = (AST) exprs [n]; + if (exp is Assign) { + if (no_effect) + exp.Emit (ec); + else + CodeGenerator.EmitAssignAsExp (ec, exp); + } + else { + exp.Emit (ec); + if (!no_effect) + CodeGenerator.EmitBox (ec.ig, exp); + } } } } diff --git a/mcs/class/Microsoft.JScript/Test/Mozilla/ChangeLog b/mcs/class/Microsoft.JScript/Test/Mozilla/ChangeLog index 13c5d363b81..4114ba048fe 100644 --- a/mcs/class/Microsoft.JScript/Test/Mozilla/ChangeLog +++ b/mcs/class/Microsoft.JScript/Test/Mozilla/ChangeLog @@ -1,3 +1,11 @@ +2007-03-01 Peter Dettman + + * mjs-most.tests: Enable ecma/Boolean/15.6.3.1-3.js. + + * mjs-most.fail: Delete ecma/String/15.5.5.1.js, + ecma/FunctionObjects/15.3.3.1-3.js, ecma/Number/15.7.3.3-2.js, + and ecma/Number/15.7.3.5-2.js, as they no longer fail. + 2006-01-13 Cesar Lopez Nataren * mjs-most.tests: Enable ecma/FunctionObjects/15.3.3.1-2.js, diff --git a/mcs/class/Microsoft.JScript/Test/Mozilla/mjs-most.fail b/mcs/class/Microsoft.JScript/Test/Mozilla/mjs-most.fail index 7f6e310f8c4..8b7330c3da8 100644 --- a/mcs/class/Microsoft.JScript/Test/Mozilla/mjs-most.fail +++ b/mcs/class/Microsoft.JScript/Test/Mozilla/mjs-most.fail @@ -48,9 +48,6 @@ js1_2/function/definition-1.js js1_3/Script/script-001.js js1_4/Functions/function-001.js -# System.NotImplementedException: The requested feature is not implemented. (Convert:ToForInObject) -ecma/String/15.5.5.1.js - # System.Exception: error JS5002 A: function expected. ecma_2/Exceptions/exception-001.js @@ -76,9 +73,3 @@ js1_2/regexp/special_characters.js # Throw NotImplementedException when invoking Convert:ToForInObject ecma/Array/15.4.3.1-2.js - -# Throw NotImplementedException when invoking LateBinding::Delete -ecma/FunctionObjects/15.3.3.1-3.js -ecma/Number/15.7.3.3-2.js -ecma/Number/15.7.3.5-2.jsc -ecma/Number/15.7.3.5-2.js diff --git a/mcs/class/Microsoft.JScript/Test/Mozilla/mjs-most.tests b/mcs/class/Microsoft.JScript/Test/Mozilla/mjs-most.tests index 633c2f5f902..09927b1d375 100644 --- a/mcs/class/Microsoft.JScript/Test/Mozilla/mjs-most.tests +++ b/mcs/class/Microsoft.JScript/Test/Mozilla/mjs-most.tests @@ -65,8 +65,7 @@ ecma/Boolean/15.6.1.js ecma/Boolean/15.6.2.js ecma/Boolean/15.6.3.1-1.js ecma/Boolean/15.6.3.1-2.js -# invalid IL -#ecma/Boolean/15.6.3.1-3.js +ecma/Boolean/15.6.3.1-3.js # Invalid IL #ecma/Boolean/15.6.3.1-4.js ecma/Boolean/15.6.3.1-5.js