internal override SObject GetMember(ScriptProcessor processor, SObject accessor, bool isIndexer) { if (isIndexer && accessor.TypeOf() == LITERAL_TYPE_NUMBER) { if (Prototype.GetIndexerGetFunction() != IndexerGetFunction) { IndexerGetFunction = Prototype.GetIndexerGetFunction(); } if (IndexerGetFunction != null) { return(IndexerGetFunction.Call(processor, this, this, new SObject[] { accessor })); } else { return(processor.Undefined); } } string memberName; if (accessor is SString) { memberName = ((SString)accessor).Value; } else { memberName = accessor.ToString(processor).Value; } if (Members.ContainsKey(PROPERTY_GET_PREFIX + memberName)) // getter property { return(((SFunction)Members[PROPERTY_GET_PREFIX + memberName].Data).Call(processor, this, this, new SObject[] { })); } else if (Members.ContainsKey(memberName)) { return(Members[memberName]); } else if (Prototype != null && Prototype.HasMember(processor, memberName)) { return(Prototype.GetMember(processor, accessor, isIndexer)); } else if (SuperClass != null) { return(SuperClass.GetMember(processor, accessor, isIndexer)); } return(processor.Undefined); }
internal override void SetMember(ScriptProcessor processor, SObject accessor, bool isIndexer, SObject value) { if (isIndexer) { if (Prototype.GetIndexerSetFunction() != IndexerSetFunction) { IndexerSetFunction = Prototype.GetIndexerSetFunction(); } } if (isIndexer && accessor.TypeOf() == LITERAL_TYPE_NUMBER && IndexerSetFunction != null) { IndexerSetFunction.Call(processor, this, this, new SObject[] { accessor, value }); } else { string memberName; if (accessor is SString) { memberName = ((SString)accessor).Value; } else { memberName = accessor.ToString(processor).Value; } if (Members.ContainsKey(PROPERTY_SET_PREFIX + memberName)) // setter property { ((SFunction)Members[PROPERTY_SET_PREFIX + memberName].Data).Call(processor, this, this, new SObject[] { value }); } if (Members.ContainsKey(memberName)) { Members[memberName].Data = value; } else if (Prototype != null && Prototype.HasMember(processor, memberName) && !Prototype.IsStaticMember(memberName)) { // This is the case when new members got added to the prototype, and we haven't copied them over to the instance yet. // So we do that now, and then set the value of that member: AddMember(memberName, value); } else { SuperClass?.SetMember(processor, accessor, isIndexer, value); } } }
internal override SObject GetMember(ScriptProcessor processor, SObject accessor, bool isIndexer) { if (isIndexer && accessor.TypeOf() == LITERAL_TYPE_NUMBER) { if (Prototype.GetIndexerGetFunction() != IndexerGetFunction) IndexerGetFunction = Prototype.GetIndexerGetFunction(); if (IndexerGetFunction != null) { return IndexerGetFunction.Call(processor, this, this, new SObject[] { accessor }); } else { return processor.Undefined; } } string memberName; if (accessor is SString) memberName = ((SString)accessor).Value; else memberName = accessor.ToString(processor).Value; if (Members.ContainsKey(PROPERTY_GET_PREFIX + memberName)) // getter property { return ((SFunction)Members[PROPERTY_GET_PREFIX + memberName].Data).Call(processor, this, this, new SObject[] { }); } else if (Members.ContainsKey(memberName)) { return Members[memberName]; } else if (Prototype != null && Prototype.HasMember(processor, memberName)) { return Prototype.GetMember(processor, accessor, isIndexer); } else if (SuperClass != null) { return SuperClass.GetMember(processor, accessor, isIndexer); } return processor.Undefined; }
internal override void SetMember(ScriptProcessor processor, SObject accessor, bool isIndexer, SObject value) { if (isIndexer) { if (Prototype.GetIndexerSetFunction() != IndexerSetFunction) IndexerSetFunction = Prototype.GetIndexerSetFunction(); } if (isIndexer && accessor.TypeOf() == LITERAL_TYPE_NUMBER && IndexerSetFunction != null) { IndexerSetFunction.Call(processor, this, this, new SObject[] { accessor, value }); } else { string memberName; if (accessor is SString) memberName = ((SString)accessor).Value; else memberName = accessor.ToString(processor).Value; if (Members.ContainsKey(PROPERTY_SET_PREFIX + memberName)) // setter property { ((SFunction)Members[PROPERTY_SET_PREFIX + memberName].Data).Call(processor, this, this, new SObject[] { value }); } if (Members.ContainsKey(memberName)) { Members[memberName].Data = value; } else if (Prototype != null && Prototype.HasMember(processor, memberName) && !Prototype.IsStaticMember(memberName)) { // This is the case when new members got added to the prototype, and we haven't copied them over to the instance yet. // So we do that now, and then set the value of that member: AddMember(memberName, value); } else { SuperClass?.SetMember(processor, accessor, isIndexer, value); } } }