/// <summary> /// this.addListener(name, handler) /// /// returns the event listener /// </summary> private static IAnalysisSet EventEmitterAddListener(FunctionValue func, Node node, AnalysisUnit unit, IAnalysisSet @this, IAnalysisSet[] args) { if (args.Length >= 2 && args[1].Count > 0) { if (@this != null) { foreach (var thisArg in @this) { ExpandoValue expando = @thisArg.Value as ExpandoValue; if (expando != null) { foreach (var arg in args[0]) { var strValue = arg.Value.GetStringValue(); if (strValue != null) { var key = new EventListenerKey(strValue); VariableDef events; if (!expando.TryGetMetadata(key, out events)) { expando.SetMetadata(key, events = new VariableDef()); } events.AddTypes(unit, args[1]); } } } } } } return(@this ?? AnalysisSet.Empty); }
public override bool Equals(object obj) { EventListenerKey key = obj as EventListenerKey; if (key == null) { return(false); } return(EventName == key.EventName); }
/// <summary> /// this.addListener(name, handler) /// /// returns the event listener /// </summary> private static IAnalysisSet EventEmitterAddListener(FunctionValue func, Node node, AnalysisUnit unit, IAnalysisSet @this, IAnalysisSet[] args) { if (args.Length >= 2 && args[1].Count > 0) { if (@this != null) { foreach (var thisArg in @this) { ExpandoValue expando = @thisArg.Value as ExpandoValue; if (expando != null) { foreach (var arg in args[0]) { var strValue = arg.Value.GetStringValue(); if (strValue != null) { var key = new EventListenerKey(strValue); VariableDef events; if (!expando.TryGetMetadata(key, out events)) { expando.SetMetadata(key, events = new VariableDef()); } events.AddTypes(unit, args[1]); } } } } } } return @this ?? AnalysisSet.Empty; }