public override JsStatement VisitFunctionStatement(JsFunctionStatement statement, IDictionary <string, string> data)
        {
            IDictionary <string, string> newData;

            if (!_renames.TryGetValue(statement, out newData))
            {
                newData = data;
            }
            bool renamed    = false;
            var  paramNames = statement.ParameterNames.Select(n => { string s; if (newData.TryGetValue(n, out s))
                                                                     {
                                                                         renamed = true; return(s);
                                                                     }
                                                                     else
                                                                     {
                                                                         return(n);
                                                                     } }).ToList();

            if (renamed)
            {
                return(JsStatement.Function(statement.Name, paramNames, VisitStatement(statement.Body, newData)));
            }
            else
            {
                return(base.VisitFunctionStatement(statement, newData));
            }
        }
Exemplo n.º 2
0
            public override JsStatement VisitFunctionStatement(JsFunctionStatement statement, Tuple <Dictionary <string, string>, HashSet <string> > data)
            {
                var newData = BuildMap(data.Item1, statement);

                _result[statement] = newData.Item1;
                return(base.VisitFunctionStatement(statement, newData));
            }
Exemplo n.º 3
0
        public override JsStatement VisitFunctionStatement(JsFunctionStatement statement, Tuple <JsDeclarationScope, DeclarationScopeHierarchy> data)
        {
            data.Item2.ChildScopes.Add(statement);
            var hier = new DeclarationScopeHierarchy(data.Item1);

            _result[statement] = hier;
            return(base.VisitFunctionStatement(statement, Tuple.Create((JsDeclarationScope)statement, hier)));
        }
Exemplo n.º 4
0
 public override JsStatement VisitFunctionStatement(JsFunctionStatement statement, object data)
 {
     _result.Add(statement.Name);
     foreach (var p in statement.ParameterNames)
     {
         _result.Add(p);
     }
     return(base.VisitFunctionStatement(statement, data));
 }
Exemplo n.º 5
0
 public object VisitFunctionStatement(JsFunctionStatement statement, bool addNewline)
 {
     _cb.Append("function " + statement.Name + "(");
     for (int i = 0; i < statement.ParameterNames.Count; i++)
     {
         if (i != 0)
         {
             _cb.Append("," + _space);
         }
         _cb.Append(statement.ParameterNames[i]);
     }
     _cb.Append(")" + _space);
     VisitStatement(statement.Body, addNewline);
     return(null);
 }
 public override JsStatement VisitFunctionStatement(JsFunctionStatement statement, object data)
 {
     return(statement);
 }
Exemplo n.º 7
0
 public override JsStatement VisitFunctionStatement(JsFunctionStatement statement, Tuple <ImmutableStack <JsDeclarationScope>, HashSet <string> > data)
 {
     _result[statement] = new HashSet <string>();
     MaybeAddGlobal(statement.Name, data.Item2, data.Item1);
     return(base.VisitFunctionStatement(statement, Tuple.Create(data.Item1.Push(statement), Union(data.Item2, _locals[statement]))));
 }
Exemplo n.º 8
0
            public override JsStatement VisitFunctionStatement(JsFunctionStatement statement, object data)
            {
                var body = (JsBlockStatement)VisitStatement(statement.Body, null);

                return(JsStatement.Function(statement.Name, statement.ParameterNames, JsStatement.Block(MakePrefix(statement).Concat(body.Statements))));
            }
Exemplo n.º 9
0
 public override JsStatement VisitFunctionStatement(JsFunctionStatement statement, HashSet <string> data)
 {
     return(base.VisitFunctionStatement(statement, _result[statement] = new HashSet <string>(statement.ParameterNames)));
 }
Exemplo n.º 10
0
            public override JsStatement VisitFunctionStatement(JsFunctionStatement statement, Tuple <Dictionary <string, string>, HashSet <string> > data)
            {
                var newData = BuildMap(data.Item1, statement);

                return(JsStatement.Function(statement.Name, statement.ParameterNames.Select(p => { string s; newData.Item1.TryGetValue(p, out s); return s ?? p; }), VisitStatement(statement.Body, newData)));
            }
Exemplo n.º 11
0
 public override JsStatement  VisitFunctionStatement(JsFunctionStatement statement, object data)
 {
     return(statement);                      // Don't patch return values of nested functions.
 }
Exemplo n.º 12
0
 public override JsStatement VisitFunctionStatement(JsFunctionStatement statement, object data)
 {
     // Inside a function, "this" is in another context and should thus not be replaced.
     return(statement);
 }
        public virtual JsStatement VisitFunctionStatement(JsFunctionStatement statement, TData data)
        {
            var body = VisitStatement(statement.Body, data);

            return(ReferenceEquals(body, statement.Body) ? statement : new JsFunctionStatement(statement.Name, statement.ParameterNames, body));
        }
Exemplo n.º 14
0
 public override JsStatement VisitFunctionStatement(JsFunctionStatement statement, IList <string> data)
 {
     return(base.VisitFunctionStatement(statement, _result[statement] = new List <string>()));
 }