public DirectivePrologue(string value, Context context, JSParser parser)
     : base(value, PrimitiveType.String, context, parser)
 {
     // this is a "use strict" directive if the source context is EXACTLY "use strict"
     // don't consider the quotes so it can be " or ' delimiters
     UseStrict = string.CompareOrdinal(Context.Code, 1, "use strict", 0, 10) == 0;
 }
Esempio n. 2
0
        public BlockScope(ActivationObject parent, Context context, CodeSettings settings)
            : base(parent, settings)
        {
            if (context == null)
            {
                throw new ArgumentNullException("context");
            }

            m_context = context.Clone();
        }
 internal JScriptException(JSError errorNumber, Context context)
 {
     m_valueObject = null;
     m_context = (context == null ? null : context.Clone());
     m_fileContext = (context == null ? null : context.Document.FileContext);
     m_errorCode = errorNumber;
     SetHResult();
 }
 protected IterationStatement(Context context, JSParser parser)
     : base(context, parser)
 {
 }
 public LexicalDeclaration(Context context, JSParser parser)
     : base(context, parser)
 {
 }
Esempio n. 6
0
 public ConstStatement(Context context, JSParser parser)
     : base(context, parser)
 {
 }
Esempio n. 7
0
 public Var(Context context, JSParser parser)
     : base(context, parser)
 {
 }
        public void MarkSegment(AstNode node, int startLine, int startColumn, string name, Context context)
        {
            if (node == null || string.IsNullOrEmpty(name))
            {
                return;
            }

            // see if this is within a function object node, 
            // AND if this segment has the same name as the function name
            // AND this context isn't the same as the entire function context.
            // this should only be true for the function NAME segment.
            var functionObject = node as FunctionObject;
            if (functionObject != null 
                && string.CompareOrdinal(name, functionObject.Name) == 0
                && context != functionObject.Context)
            {
                // it does -- so this is the segment that corresponds to the function object's name, which
                // for this format we want to output a separate segment for. It used to be its own Lookup
                // node child of the function object, so we need to create a fake node here, start a new 
                // symbol from it, end the symbol, then write it.
                var fakeLookup = new Lookup(context, functionObject.Parser) { Name = name };
                var nameSymbol = JavaScriptSymbol.StartNew(fakeLookup, startLine, startColumn, GetSourceFileIndex(functionObject.Context.Document.FileContext));

                // the name will never end on a different line -- it's a single unbreakable token. The length is just
                // the length of the name, so add that number to the column start. And the parent context is the function
                // name (again)
                nameSymbol.End(startLine, startColumn + name.Length, name);
                nameSymbol.WriteTo(m_writer);
            }
        }
 public ConstantWrapperPP(Context context, JSParser parser)
     : base(context, parser)
 {
 }
Esempio n. 10
0
 public WithScope(ActivationObject parent, Context context, CodeSettings settings)
     : base(parent, context, settings)
 {
     IsInWithScope = true;
 }
Esempio n. 11
0
 public Conditional(Context context, JSParser parser)
     : base(context, parser)
 {
 }
Esempio n. 12
0
 public bool IsBefore(Context other)
 {
     // this context is BEFORE the other context if it starts on an earlier line,
     // OR if it starts on the same line but at an earlier column
     // (or if the other context is null)
     return other == null
         || StartLineNumber < other.StartLineNumber
         || (StartLineNumber == other.StartLineNumber && StartColumn < other.StartColumn);
 }
Esempio n. 13
0
        public Context UpdateWith(Context other)
        {
            if (other != null)
            {
                if (other.StartPosition < this.StartPosition)
                {
                    this.StartPosition = other.StartPosition;
                    this.StartLineNumber = other.StartLineNumber;
                    this.StartLinePosition = other.StartLinePosition;
                    this.SourceOffsetStart = other.SourceOffsetStart;
                }

                if (other.EndPosition > this.EndPosition)
                {
                    this.EndPosition = other.EndPosition;
                    this.EndLineNumber = other.EndLineNumber;
                    this.EndLinePosition = other.EndLinePosition;
                    this.SourceOffsetEnd = other.SourceOffsetEnd;
                }
            }

            return this;
        }
Esempio n. 14
0
 public Context CombineWith(Context other)
 {
     return other == null
         ? this.Clone()
         : new Context(Document)
             {
                 StartLineNumber = this.StartLineNumber,
                 StartLinePosition = this.StartLinePosition,
                 StartPosition = this.StartPosition,
                 EndLineNumber = other.EndLineNumber,
                 EndLinePosition = other.EndLinePosition,
                 EndPosition = other.EndPosition,
                 SourceOffsetStart = this.SourceOffsetStart,
                 SourceOffsetEnd = other.SourceOffsetEnd,
                 Token = this.Token
             };
 }
 public VariableDeclaration(Context context, JSParser parser)
     : base(context, parser)
 {
 }
Esempio n. 16
0
 public ForIn(Context context, JSParser parser)
     : base(context, parser)
 {
 }
        public ConstantWrapper(Object value, PrimitiveType primitiveType, Context context, JSParser parser)
            : base(context, parser)
        {
            PrimitiveType = primitiveType;

            // force numerics to be of type double
            Value = (primitiveType == PrimitiveType.Number ? System.Convert.ToDouble(value, CultureInfo.InvariantCulture) : value);
        }
Esempio n. 18
0
 public Block(Context context, JSParser parser)
     : base(context, parser)
 {
     m_list = new List<AstNode>();
 }
 public ObjectLiteralProperty(Context context, JSParser parser)
     : base(context, parser)
 {
 }
Esempio n. 20
0
 public Member(Context context, JSParser parser)
     : base(context, parser)
 {
 }
Esempio n. 21
0
 public IfNode(Context context, JSParser parser)
     : base(context, parser)
 {
 }
Esempio n. 22
0
 public Lookup(Context context, JSParser parser)
     : base(context, parser)
 {
     RefType = ReferenceType.Variable;
 }
Esempio n. 23
0
 public EmptyStatement(Context context, JSParser parser)
     : base(context, parser)
 {
 }
Esempio n. 24
0
 public DoWhile(Context context, JSParser parser)
     : base(context, parser)
 {
 }
Esempio n. 25
0
 public ReturnNode(Context context, JSParser parser)
     : base(context, parser)
 {
 }
Esempio n. 26
0
 public ConditionalCompilationIf(Context context, JSParser parser)
     : base(context, parser)
 {
 }
 public JScriptException(string message, Exception innerException)
     : base(message, innerException)
 {
     m_valueObject = message;
     m_context = null;
     m_fileContext = null;
     m_errorCode = JSError.UncaughtException;
     SetHResult();
 }
Esempio n. 28
0
 public Switch(Context context, JSParser parser)
     : base(context, parser)
 {
 }
 internal UndefinedReferenceException(Lookup lookup, Context context)
 {
     m_lookup = lookup;
     m_name = lookup.Name;
     m_type = lookup.RefType;
     m_context = context;
 }
        public void OutputNumber(double numericValue, Context originalContext)
        {
            // numerics are doubles in JavaScript, so force it now as a shortcut
            if (double.IsNaN(numericValue) || double.IsInfinity(numericValue))
            {
                // weird number -- just return the original source code as-is. 
                if (originalContext != null && !string.IsNullOrEmpty(originalContext.Code)
                    && !originalContext.Document.IsGenerated)
                {
                    m_writer.Write(originalContext.Code);
                    return;
                }

                // Hmmm... don't have an original source. 
                // Must be generated. Just generate the proper JS literal.
                //
                // DANGER! If we just output NaN and Infinity and -Infinity blindly, that assumes
                // that there aren't any local variables in this scope chain with that
                // name, and we're pulling the GLOBAL properties. Might want to use properties
                // on the Number object -- which, of course, assumes that Number doesn't
                // resolve to a local variable...
                string objectName = double.IsNaN(numericValue) ? "NaN" : "Infinity";

                // we're good to go -- just return the name because it will resolve to the
                // global properties (make a special case for negative infinity)
                m_writer.Write(double.IsNegativeInfinity(numericValue) ? "-Infinity" : objectName);
            }
            else if (numericValue == 0)
            {
                // special case zero because we don't need to go through all those
                // gyrations to get a "0" -- and because negative zero is different
                // than a positive zero
                m_writer.Write(1 / numericValue < 0 ? "-0" : "0");
            }
            else
            {
                // normal string representations
                m_writer.Write(GetSmallestRep(numericValue.ToString("R", CultureInfo.InvariantCulture)));
            }
        }