private JSStatement FoldInvocation(JSInvocationExpression invocation, InitializationInfo ii) { var arguments = invocation.Arguments.ToArray(); var newExpression = new JSNewExpression( ii.Type, invocation.JSMethod.Reference, invocation.JSMethod.Method, arguments ); // Constructor call contains a reference to the struct being initialized. // For some reason the C# compiler lets you do this even though it would be undefined // if not for a nuance in how struct locals work in MSIL. if (newExpression.SelfAndChildrenRecursive.Any((n) => n.Equals(invocation.ThisReference))) { return(null); } ii.Folded = true; ii.BinaryExpressionParent.ReplaceChild(ii.ParentBinaryExpression, new JSNullExpression()); var newBoe = new JSBinaryOperatorExpression( JSOperator.Assignment, ii.ParentBinaryExpression.Left, newExpression, ii.ParentBinaryExpression.ActualType ); return(new JSVariableDeclarationStatement(newBoe)); }
private JSStatement FoldInvocation (JSInvocationExpression invocation, InitializationInfo ii) { var arguments = invocation.Arguments.ToArray(); var newExpression = new JSNewExpression( ii.Type, invocation.JSMethod.Reference, invocation.JSMethod.Method, arguments ); // Constructor call contains a reference to the struct being initialized. // For some reason the C# compiler lets you do this even though it would be undefined // if not for a nuance in how struct locals work in MSIL. if (newExpression.SelfAndChildrenRecursive.Any((n) => n.Equals(invocation.ThisReference))) return null; ii.Folded = true; ii.BinaryExpressionParent.ReplaceChild(ii.ParentBinaryExpression, new JSNullExpression()); var newBoe = new JSBinaryOperatorExpression( JSOperator.Assignment, ii.ParentBinaryExpression.Left, newExpression, ii.ParentBinaryExpression.ActualType ); return new JSVariableDeclarationStatement(newBoe); }
private JSStatement ConvertInvocationIntoReassignment (JSInvocationExpression invocation, InitializationInfo ii) { var arguments = invocation.Arguments.ToArray(); var newExpression = new JSNewExpression( ii.Type, invocation.JSMethod.Reference, invocation.JSMethod.Method, arguments ); var newBoe = new JSBinaryOperatorExpression( JSOperator.Assignment, ii.ParentBinaryExpression.Left, newExpression, ii.ParentBinaryExpression.ActualType ); return new JSExpressionStatement(newBoe); }
private JSStatement ConvertInvocationIntoReassignment(JSInvocationExpression invocation, InitializationInfo ii) { var arguments = invocation.Arguments.ToArray(); var newExpression = new JSNewExpression( ii.Type, invocation.JSMethod.Reference, invocation.JSMethod.Method, arguments ); var newBoe = new JSBinaryOperatorExpression( JSOperator.Assignment, ii.ParentBinaryExpression.Left, newExpression, ii.ParentBinaryExpression.ActualType ); return(new JSExpressionStatement(newBoe)); }
private JSStatement FoldInvocation(JSInvocationExpression invocation, InitializationInfo ii) { var arguments = invocation.Arguments.ToArray(); var newExpression = new JSNewExpression( ii.Type, invocation.JSMethod.Reference, invocation.JSMethod.Method, arguments ); ii.BinaryExpressionParent.ReplaceChild(ii.ParentBinaryExpression, new JSNullExpression()); Initializations.Remove(ii); var newBoe = new JSBinaryOperatorExpression( JSOperator.Assignment, ii.ParentBinaryExpression.Left, newExpression, ii.ParentBinaryExpression.ActualType ); return new JSVariableDeclarationStatement(newBoe); }