Beispiel #1
0
        public int Measure()
        {
            // we just want to measure the potential delta
            m_measure = true;
            m_delta   = 0;

            // do it and return the result
            m_expression.Accept(this);
            return(m_delta);
        }
Beispiel #2
0
 public static void Apply(JsAstNode node)
 {
     if (node != null)
     {
         node.Accept(s_instance);
     }
 }
Beispiel #3
0
        public static bool NeedsParens(JsAstNode expression, bool outerHasNoArguments)
        {
            var visitor = new JsNewParensVisitor(outerHasNoArguments);

            expression.Accept(visitor);
            return(visitor.m_needsParens);
        }
        public static bool Apply(TextWriter writer, JsAstNode node)
        {
            if (node != null)
            {
                var visitor = new JsonOutputVisitor(writer);
                node.Accept(visitor);
                return(visitor.IsValid);
            }

            return(false);
        }
Beispiel #5
0
        public bool Match(JsAstNode node, string identifiers)
        {
            // set the match to false
            m_isMatch = false;

            // identifiers cannot be null or blank and must match: IDENT(.IDENT)*
            // since for JS there has to be at least a global object, the dot must be AFTER the first character.
            if (node != null && !string.IsNullOrEmpty(identifiers))
            {
                // get all the parts
                var parts = identifiers.Split('.');

                // each part must be a valid JavaScript identifier. Assume everything is valid
                // unless at least one is invalid -- then forget it
                var isValid = true;
                foreach (var part in parts)
                {
                    if (!JsScanner.IsValidIdentifier(part))
                    {
                        isValid = false;
                        break;
                    }
                }

                // must be valid to continue
                if (isValid)
                {
                    // save the parts and start the index on the last one, since we'll be walking backwards
                    m_parts = parts;
                    m_index = parts.Length - 1;

                    node.Accept(this);
                }
            }

            return(m_isMatch);
        }
Beispiel #6
0
        public static void Apply(JsAstNode node, JsActivationObject scope, JsSettings settings)
        {
            if (node != null && scope != null)
            {
                // create the visitor and run it. This will create all the child
                // scopes and populate all the scopes with the var-decl, lex-decl,
                // and lookup references within them.
                var visitor = new JsResolutionVisitor(scope, settings);
                node.Accept(visitor);

                // now that all the scopes are created and they all know what decls
                // they contains, create all the fields
                CreateFields(scope);

                // now that all the fields have been created in all the scopes,
                // let's go through and resolve all the references
                ResolveLookups(scope, settings);

                // now that everything is declared and resolved as per the language specs,
                // we need to go back and add ghosted fields for older versions of IE that
                // incorrectly implement catch-variables and named function expressions.
                AddGhostedFields(scope);
            }
        }
Beispiel #7
0
        public static void Apply(JsAstNode node, JsParser parser)
        {
            var visitor = new JsFinalPassVisitor(parser);

            node.Accept(visitor);
        }