public override bool Equals(object obj) { ObjectLiteralKey other = obj as ObjectLiteralKey; if (other != null) { if (other.PropertyNames.Length != PropertyNames.Length) { return(false); } for (int i = 0; i < PropertyNames.Length; i++) { if (PropertyNames[i] != other.PropertyNames[i]) { return(false); } } return(true); } return(false); }
public override bool Walk(ObjectLiteral node) { // If a single file has a bunch of duplicate ObjectLiteral values with the same // property names we will merge them together into a single ObjectLiteralValue to // avoid an explosion in object literals. We only do this for literals with // at least one member defined. if (node.Properties.Length > 0) { // first see if we have a object literal that we should share with... string[] propNames = new string[node.Properties.Length]; for (int i = 0; i < node.Properties.Length; i++) { string propName = null; if (node.Properties[i].Name.Value != null) { propName = node.Properties[i].Name.Value.ToString(); } propNames[i] = propName; } var key = new ObjectLiteralKey(propNames); IAnalysisSet value; if (_scope.GlobalEnvironment.TryGetNodeValue( NodeEnvironmentKind.ObjectLiteralValue, key, out value)) { // cache the value under our node... _scope.GlobalEnvironment.AddNodeValue( NodeEnvironmentKind.ObjectLiteralValue, node, value ); } else { // create the value and cache it under oru node and the // shared key. var objLiteral = new ObjectLiteralValue(_entry, node); _scope.GlobalEnvironment.AddNodeValue( NodeEnvironmentKind.ObjectLiteralValue, node, objLiteral.Proxy ); _scope.GlobalEnvironment.AddNodeValue( NodeEnvironmentKind.ObjectLiteralValue, key, objLiteral.Proxy ); } } else { _scope.GlobalEnvironment.AddNodeValue( NodeEnvironmentKind.ObjectLiteralValue, node, new ObjectLiteralValue(_entry, node).Proxy ); } return base.Walk(node); }
public override bool Walk(ObjectLiteral node) { // If a single file has a bunch of duplicate ObjectLiteral values with the same // property names we will merge them together into a single ObjectLiteralValue to // avoid an explosion in object literals. We only do this for literals with // at least one member defined. if (node.Properties.Length > 0) { // first see if we have a object literal that we should share with... string[] propNames = new string[node.Properties.Length]; for (int i = 0; i < node.Properties.Length; i++) { string propName = null; if (node.Properties[i].Name.Value != null) { propName = node.Properties[i].Name.Value.ToString(); } propNames[i] = propName; } var key = new ObjectLiteralKey(propNames); IAnalysisSet value; if (_scope.GlobalEnvironment.TryGetNodeValue( NodeEnvironmentKind.ObjectLiteralValue, key, out value)) { // cache the value under our node... _scope.GlobalEnvironment.AddNodeValue( NodeEnvironmentKind.ObjectLiteralValue, node, value ); } else { // create the value and cache it under oru node and the // shared key. var objLiteral = new ObjectLiteralValue(_entry, node); _scope.GlobalEnvironment.AddNodeValue( NodeEnvironmentKind.ObjectLiteralValue, node, objLiteral.Proxy ); _scope.GlobalEnvironment.AddNodeValue( NodeEnvironmentKind.ObjectLiteralValue, key, objLiteral.Proxy ); } } else { _scope.GlobalEnvironment.AddNodeValue( NodeEnvironmentKind.ObjectLiteralValue, node, new ObjectLiteralValue(_entry, node).Proxy ); } return(base.Walk(node)); }