Skip to content

Instantly share code, notes, and snippets.

@kg
Created May 5, 2011 01:19
Show Gist options
  • Save kg/956348 to your computer and use it in GitHub Desktop.
Save kg/956348 to your computer and use it in GitHub Desktop.
public void VisitNode (JSBinaryOperatorExpression boe) {
if (boe.Operator != JSOperator.Assignment) {
base.VisitNode(boe);
return;
}
if (IsStruct(boe.Left.GetExpectedType(TypeSystem)) || IsStruct(boe.Right.GetExpectedType(TypeSystem))) {
Debug.WriteLine(String.Format("struct assignment {0} = {1}", boe.Left, boe.Right));
if (boe.Right is JSLiteral) {
Debug.WriteLine(" copy not needed, literal");
} else if (boe.Right is JSInvocationExpression) {
Debug.WriteLine(" copy not needed, invocation result");
} else {
Debug.WriteLine(" copy introduced");
boe.Right = new JSInvocationExpression(new JSDotExpression(boe.Right, CLR.MemberwiseClone));
}
}
VisitChildren(boe);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment