コード例 #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);
        }
コード例 #2
0
        public static bool NeedsParens(AstNode expression, bool outerHasNoArguments)
        {
            var visitor = new NewParensVisitor(outerHasNoArguments);

            expression.Accept(visitor);
            return(visitor.m_needsParens);
        }
コード例 #3
0
 public static void Apply(AstNode node)
 {
     if (node != null)
     {
         node.Accept(s_instance);
     }
 }
コード例 #4
0
        public static bool Apply(TextWriter writer, AstNode node)
        {
            if (node != null)
            {
                var visitor = new JSONOutputVisitor(writer);
                node.Accept(visitor);
                return(visitor.IsValid);
            }

            return(false);
        }
コード例 #5
0
        public bool Match(AstNode 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);
        }
コード例 #6
0
        public static void Apply(AstNode node, ActivationObject scope, CodeSettings 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 ResolutionVisitor(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);
            }
        }