protected ActivationObject(Statement node, ActivationObject parent, ErrorSink errorSink) { _node = node; m_useStrict = false; Parent = parent; NameTable = new Dictionary<string, JSVariableField>(); ChildScopes = new List<ActivationObject>(); // if our parent is a scope.... if (parent != null) { // add us to the parent's list of child scopes parent.ChildScopes.Add(this); // if the parent is strict, so are we UseStrict = parent.UseStrict; } // create the two lists of declared items for this scope ScopeLookups = new HashSet<Lookup>(); VarDeclaredNames = new HashSet<INameDeclaration>(); LexicallyDeclaredNames = new HashSet<INameDeclaration>(); GhostedCatchParameters = new HashSet<ParameterDeclaration>(); GhostedFunctions = new HashSet<FunctionObject>(); _errorSink = errorSink; }
private ResolutionVisitor(ActivationObject rootScope, LocationResolver indexResolver, ErrorSink errorSink) { // create the lexical and variable scope stacks and push the root scope onto them m_lexicalStack = new Stack<ActivationObject>(); m_lexicalStack.Push(rootScope); m_variableStack = new Stack<ActivationObject>(); m_variableStack.Push(rootScope); _locationResolver = indexResolver; _errorSink = errorSink; }
internal FunctionScope(Statement node, ActivationObject parent, bool isExpression, FunctionObject funcObj, ErrorSink errorSink) : base(node, parent, errorSink) { m_refScopes = new HashSet<ActivationObject>(); if (isExpression) { // parent scopes automatically reference enclosed function expressions AddReference(Parent); } FunctionObject = funcObj; }
internal GlobalScope(JsAst node, ErrorSink errorSink) : base(node, null, errorSink) { // define the Global object's properties, and methods m_globalProperties = new HashSet<string>(new[] { "Infinity", "NaN", "undefined", "window", "Image", "JSON", "Math", "XMLHttpRequest", "DOMParser", "applicationCache", "clientInformation", "clipboardData", "closed", "console", "document", "event", "external", "frameElement", "frames", "history", "length", "localStorage", "location", "name", "navigator", "opener", "parent", "screen", "self", "sessionStorage", "status", "top"}); m_globalFunctions = new HashSet<string>(new[] { "decodeURI", "decodeURIComponent", "encodeURI", "encodeURIComponent", "escape", "eval", "importScripts", "isNaN", "isFinite", "parseFloat", "parseInt", "unescape", "ActiveXObject", "Array", "Boolean", "Date", "Error", "EvalError", "EventSource", "File", "FileList", "FileReader", "Function", "GeckoActiveXObject", "HTMLElement", "Number", "Object", "Proxy", "RangeError", "ReferenceError", "RegExp", "SharedWorker", "String", "SyntaxError", "TypeError", "URIError", "WebSocket", "Worker", "addEventListener", "alert", "attachEvent", "blur", "clearInterval", "clearTimeout", "close", "confirm", "createPopup", "detachEvent", "dispatchEvent", "execScript", "focus", "getComputedStyle", "getSelection", "moveBy", "moveTo", "navigate", "open", "postMessage", "prompt", "removeEventListener", "resizeBy", "resizeTo", "scroll", "scrollBy", "scrollTo", "setActive", "setInterval", "setTimeout", "showModalDialog", "showModelessDialog" }); }
public static void Apply(Node node, ActivationObject scope, LocationResolver indexResolver, ErrorSink errorSink) { 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, indexResolver, errorSink); node.Walk(visitor); // now that all the scopes are created and they all know what decls // they contains, create all the fields visitor.CreateFields(scope); // now that all the fields have been created in all the scopes, // let's go through and resolve all the references visitor.ResolveLookups(scope); // 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. visitor.AddGhostedFields(scope); } }
internal CatchScope(Statement node, ActivationObject parent, ParameterDeclaration catchParameter, ErrorSink errorSink) : base(node, parent, errorSink) { CatchParameter = catchParameter; }
public BlockScope(Statement node, ActivationObject parent, ErrorSink errorSink) : base(node, parent, errorSink) { }
private JSParser CreateParser(TextReader content, ErrorSink sink) { // TODO: JSParser should accept a TextReader return new JSParser(content.ReadToEnd(), sink); }
private ResolutionVisitor(ActivationObject rootScope, LocationResolver indexResolver, ErrorSink errorSink) { // create the lexical and variable scope stacks and push the root scope onto them m_lexicalStack = new Stack <ActivationObject>(); m_lexicalStack.Push(rootScope); m_variableStack = new Stack <ActivationObject>(); m_variableStack.Push(rootScope); _locationResolver = indexResolver; _errorSink = errorSink; }
internal FunctionScope(Statement node, ActivationObject parent, bool isExpression, FunctionObject funcObj, ErrorSink errorSink) : base(node, parent, errorSink) { m_refScopes = new HashSet <ActivationObject>(); if (isExpression) { // parent scopes automatically reference enclosed function expressions AddReference(Parent); } FunctionObject = funcObj; }
public WithScope(Statement node, ActivationObject parent, ErrorSink errorSink) : base(node, parent, errorSink) { IsInWithScope = true; }