]> git.saurik.com Git - apple/javascriptcore.git/blobdiff - runtime/JSNameScope.cpp
JavaScriptCore-7601.1.46.3.tar.gz
[apple/javascriptcore.git] / runtime / JSNameScope.cpp
index 53468d6a8f24861c3a517472c854f11970a7458d..d159f69be2a6fc80a13588b470fbed72cf8c4d0d 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2008, 2009, 2012 Apple Inc. All Rights Reserved.
+ * Copyright (C) 2008, 2009, 2012, 2015 Apple Inc. All Rights Reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
 #include "JSNameScope.h"
 
 #include "Error.h"
-#include "Operations.h"
+#include "JSCInlines.h"
+#include "JSCatchScope.h"
+#include "JSFunctionNameScope.h"
 
 namespace JSC {
 
-const ClassInfo JSNameScope::s_info = { "NameScope", &Base::s_info, 0, 0, CREATE_METHOD_TABLE(JSNameScope) };
+const ClassInfo JSNameScope::s_info = { "NameScope", &Base::s_info, 0, CREATE_METHOD_TABLE(JSNameScope) };
 
-void JSNameScope::visitChildren(JSCell* cell, SlotVisitor& visitor)
+JSNameScope* JSNameScope::create(VM& vm, JSGlobalObject* globalObject, JSScope* currentScope, SymbolTable* symbolTable, JSValue value, Type type)
 {
-    JSNameScope* thisObject = jsCast<JSNameScope*>(cell);
-    ASSERT_GC_OBJECT_INHERITS(thisObject, &s_info);
-    COMPILE_ASSERT(StructureFlags & OverridesVisitChildren, OverridesVisitChildrenWithoutSettingFlag);
-    ASSERT(thisObject->structure()->typeInfo().overridesVisitChildren());
-
-    Base::visitChildren(thisObject, visitor);
-    visitor.append(&thisObject->m_registerStore);
+    switch (type) {
+    case CatchScope:
+        return JSCatchScope::create(vm, globalObject, currentScope, symbolTable, value);
+    case FunctionNameScope:
+        return JSFunctionNameScope::create(vm, globalObject, currentScope, symbolTable, value);
+    }
+    RELEASE_ASSERT_NOT_REACHED();
+    return nullptr;
 }
 
-JSObject* JSNameScope::toThisObject(JSCell*, ExecState* exec)
+JSValue JSNameScope::toThis(JSCell*, ExecState* exec, ECMAMode ecmaMode)
 {
+    if (ecmaMode == StrictMode)
+        return jsUndefined();
     return exec->globalThisValue();
 }
 
@@ -59,11 +64,11 @@ void JSNameScope::put(JSCell* cell, ExecState* exec, PropertyName propertyName,
         // (a) is unlikely, and (b) is an error.
         // Also with a single entry the symbol table lookup should simply be
         // a pointer compare.
-        PropertySlot slot;
+        PropertySlot slot(thisObject);
         bool isWritable = true;
         symbolTableGet(thisObject, propertyName, slot, isWritable);
         if (!isWritable) {
-            throwError(exec, createTypeError(exec, StrictModeReadonlyPropertyWriteError));
+            exec->vm().throwException(exec, createTypeError(exec, StrictModeReadonlyPropertyWriteError));
             return;
         }
     }
@@ -73,9 +78,9 @@ void JSNameScope::put(JSCell* cell, ExecState* exec, PropertyName propertyName,
     RELEASE_ASSERT_NOT_REACHED();
 }
 
-bool JSNameScope::getOwnPropertySlot(JSCell* cell, ExecState*, PropertyName propertyName, PropertySlot& slot)
+bool JSNameScope::getOwnPropertySlot(JSObject* object, ExecState*, PropertyName propertyName, PropertySlot& slot)
 {
-    return symbolTableGet(jsCast<JSNameScope*>(cell), propertyName, slot);
+    return symbolTableGet(jsCast<JSNameScope*>(object), propertyName, slot);
 }
 
 } // namespace JSC