Esempio n. 1
0
        internal override string GetFunctionGuess(AstNode target)
        {
            // get our guess from the function call
            string funcName = m_func.GetFunctionGuess(target);

            // MSN VOODOO: if this is the addMethod method, then the
            // name of the function is the first parameter.
            // The syntax of the add method call is: obj.addMethod("name",function(){...})
            // so there should be two parameters....
            if (funcName == "addMethod" && m_args.Count == 2)
            {
                // the first one should be a string constant....
                ConstantWrapper firstParam = m_args[0] as ConstantWrapper;
                // and the second one should be the function expression we're looking for
                if ((firstParam != null) && (firstParam.Value is string) && (m_args[1] == target))
                {
                    // use that first parameter as the guess
                    funcName = firstParam.ToString();
                }
            }
            return(funcName);
        }
Esempio n. 2
0
        private string GuessAtName()
        {
            AstNode parent = Parent;

            if (parent != null)
            {
                if (parent is AstNodeList)
                {
                    // if the parent is an ASTList, then we're really interested
                    // in our parent's parent (probably a call)
                    parent = parent.Parent;
                }
                CallNode call = parent as CallNode;
                if (call != null && call.IsConstructor)
                {
                    // if this function expression is the object of a new, then we want the parent
                    parent = parent.Parent;
                }

                string guess = parent.GetFunctionGuess(this);
                if (guess != null && guess.Length > 0)
                {
                    if (guess.StartsWith("\"", StringComparison.Ordinal) &&
                        guess.EndsWith("\"", StringComparison.Ordinal))
                    {
                        // don't need to wrap it in quotes -- it already is
                        return(guess);
                    }
                    // wrap the guessed name in quotes
                    return(string.Format(CultureInfo.InvariantCulture, "\"{0}\"", guess));
                }
                else
                {
                    return(string.Format(CultureInfo.InvariantCulture, "anonymous_{0}", UniqueNumber));
                }
            }
            return(string.Empty);
        }
Esempio n. 3
0
 internal override string GetFunctionGuess(AstNode target)
 {
     return(m_operand.GetFunctionGuess(target));
 }
Esempio n. 4
0
 internal override string GetFunctionGuess(AstNode target)
 {
     return(m_caseValue.GetFunctionGuess(target));
 }