inline bool JSLexicalEnvironment::symbolTablePut(ExecState* exec, PropertyName propertyName, JSValue value, bool shouldThrow) { VM& vm = exec->vm(); ASSERT(!Heap::heap(value) || Heap::heap(value) == Heap::heap(this)); WriteBarrierBase<Unknown>* reg; WatchpointSet* set; { GCSafeConcurrentJITLocker locker(symbolTable()->m_lock, exec->vm().heap); SymbolTable::Map::iterator iter = symbolTable()->find(locker, propertyName.uid()); if (iter == symbolTable()->end(locker)) return false; ASSERT(!iter->value.isNull()); if (iter->value.isReadOnly()) { if (shouldThrow) throwTypeError(exec, StrictModeReadonlyPropertyWriteError); return true; } ScopeOffset offset = iter->value.scopeOffset(); // Defend against the inspector asking for a var after it has been optimized out. if (!isValid(offset)) return false; set = iter->value.watchpointSet(); reg = &variableAt(offset); } reg->set(vm, this, value); if (set) set->invalidate(VariableWriteFireDetail(this, propertyName)); // Don't mess around - if we had found this statically, we would have invalidated it. return true; }
void MemberCallExpressionAST::typeCheck(TypeChecker& checker) { mAccessExpression->typeCheck(checker); if (auto varRef = std::dynamic_pointer_cast<VariableReferenceExpressionAST>(mAccessExpression)) { auto varSymbol = std::dynamic_pointer_cast<VariableSymbol>(mSymbolTable->find(varRef->name())); auto varRefType = checker.findType(varSymbol->variableType()); std::string objName = varRefType->name(); if (!checker.objectExists(objName)) { checker.typeError(varRefType->name() + " is not an object type."); } auto classSymbol = std::dynamic_pointer_cast<ClassSymbol>(Helpers::findSymbolInNamespace(mSymbolTable, objName)); mMemberCallExpression->setCallTable(classSymbol->symbolTable()); mMemberCallExpression->generateSymbols(checker.binder(), mSymbolTable); mMemberCallExpression->typeCheck(checker); } else { auto varRefType = mAccessExpression->expressionType(checker); std::string objName = varRefType->name(); if (!checker.objectExists(objName)) { checker.typeError(varRefType->name() + " is not an object type."); } auto classSymbol = std::dynamic_pointer_cast<ClassSymbol>(Helpers::findSymbolInNamespace(mSymbolTable, objName)); mMemberCallExpression->setCallTable(classSymbol->symbolTable()); mMemberCallExpression->generateSymbols(checker.binder(), mSymbolTable); mMemberCallExpression->typeCheck(checker); } }
void JSGlobalObject::visitChildren(SlotVisitor& visitor) { JSVariableObject::visitChildren(visitor); visitIfNeeded(visitor, &m_globalScopeChain); visitIfNeeded(visitor, &m_methodCallDummy); visitIfNeeded(visitor, &m_regExpConstructor); visitIfNeeded(visitor, &m_errorConstructor); visitIfNeeded(visitor, &m_evalErrorConstructor); visitIfNeeded(visitor, &m_rangeErrorConstructor); visitIfNeeded(visitor, &m_referenceErrorConstructor); visitIfNeeded(visitor, &m_syntaxErrorConstructor); visitIfNeeded(visitor, &m_typeErrorConstructor); visitIfNeeded(visitor, &m_URIErrorConstructor); visitIfNeeded(visitor, &m_evalFunction); visitIfNeeded(visitor, &m_callFunction); visitIfNeeded(visitor, &m_applyFunction); visitIfNeeded(visitor, &m_objectPrototype); visitIfNeeded(visitor, &m_functionPrototype); visitIfNeeded(visitor, &m_arrayPrototype); visitIfNeeded(visitor, &m_booleanPrototype); visitIfNeeded(visitor, &m_stringPrototype); visitIfNeeded(visitor, &m_numberPrototype); visitIfNeeded(visitor, &m_datePrototype); visitIfNeeded(visitor, &m_regExpPrototype); visitIfNeeded(visitor, &m_argumentsStructure); visitIfNeeded(visitor, &m_arrayStructure); visitIfNeeded(visitor, &m_booleanObjectStructure); visitIfNeeded(visitor, &m_callbackConstructorStructure); visitIfNeeded(visitor, &m_callbackFunctionStructure); visitIfNeeded(visitor, &m_callbackObjectStructure); visitIfNeeded(visitor, &m_dateStructure); visitIfNeeded(visitor, &m_emptyObjectStructure); visitIfNeeded(visitor, &m_nullPrototypeObjectStructure); visitIfNeeded(visitor, &m_errorStructure); visitIfNeeded(visitor, &m_functionStructure); visitIfNeeded(visitor, &m_numberObjectStructure); visitIfNeeded(visitor, &m_regExpMatchesArrayStructure); visitIfNeeded(visitor, &m_regExpStructure); visitIfNeeded(visitor, &m_stringObjectStructure); visitIfNeeded(visitor, &m_internalFunctionStructure); if (m_registerArray) { // Outside the execution of global code, when our variables are torn off, // we can mark the torn-off array. visitor.appendValues(m_registerArray.get(), m_registerArraySize); } else if (m_registers) { // During execution of global code, when our variables are in the register file, // the symbol table tells us how many variables there are, and registers // points to where they end, and the registers used for execution begin. visitor.appendValues(m_registers - symbolTable().size(), symbolTable().size()); } }
void JSVariableObject::getOwnPropertyNames(ExecState* exec, PropertyNameArray& propertyNames, EnumerationMode mode) { SymbolTable::const_iterator end = symbolTable().end(); for (SymbolTable::const_iterator it = symbolTable().begin(); it != end; ++it) { if (!(it->second.getAttributes() & DontEnum) || (mode == IncludeDontEnumProperties)) propertyNames.add(Identifier(exec, it->first.get())); } JSObject::getOwnPropertyNames(exec, propertyNames, mode); }
void JSActivation::getOwnPropertyNames(ExecState* exec, PropertyNameArray& propertyNames, EnumerationMode mode) { SymbolTable::const_iterator end = symbolTable().end(); for (SymbolTable::const_iterator it = symbolTable().begin(); it != end; ++it) { ASSERT(it->second.getIndex() < static_cast<int>(d()->functionExecutable->capturedVariableCount())); if (!(it->second.getAttributes() & DontEnum) || (mode == IncludeDontEnumProperties)) propertyNames.add(Identifier(exec, it->first.get())); } // Skip the JSVariableObject implementation of getOwnPropertyNames JSObject::getOwnPropertyNames(exec, propertyNames, mode); }
FrSymbol *FrTextSpans::makeSymbol(FrSymbol *symbol) const { if (FrSymbolTable::current() != symbolTable() && symbol) { FrSymbolTable *symtab = symbolTable()->select() ; FrSymbol *sym = FrSymbolTable::add(symbol->symbolName()) ; symtab->select() ; return sym ; } else return symbol ; }
void JSActivation::getOwnPropertyNames(ExecState* exec, PropertyNameArray& propertyNames, EnumerationMode mode) { SymbolTable::const_iterator end = symbolTable().end(); for (SymbolTable::const_iterator it = symbolTable().begin(); it != end; ++it) { if (it->second.getAttributes() & DontEnum && mode != IncludeDontEnumProperties) continue; if (it->second.getIndex() >= m_numCapturedVars) continue; propertyNames.add(Identifier(exec, it->first.get())); } // Skip the JSVariableObject implementation of getOwnPropertyNames JSObject::getOwnPropertyNames(exec, propertyNames, mode); }
FrSymbol *FrTextSpans::makeSymbol(const char *symname) const { if (!symname) symname = "" ; if (FrSymbolTable::current() != symbolTable()) { FrSymbolTable *symtab = symbolTable()->select() ; FrSymbol *sym = FrSymbolTable::add(symname) ; symtab->select() ; return sym ; } return FrSymbolTable::add(symname) ; }
void JSGlobalObject::addStaticGlobals(GlobalPropertyInfo* globals, int count) { addRegisters(count); for (int i = 0; i < count; ++i) { GlobalPropertyInfo& global = globals[i]; ASSERT(global.attributes & DontDelete); int index = symbolTable()->size(); SymbolTableEntry newEntry(index, global.attributes); symbolTable()->add(global.identifier.impl(), newEntry); registerAt(index).set(vm(), this, global.value); } }
inline bool JSActivation::symbolTablePutWithAttributes(const Identifier& propertyName, JSValue value, unsigned attributes) { ASSERT(!Heap::heap(value) || Heap::heap(value) == Heap::heap(this)); SymbolTable::iterator iter = symbolTable().find(propertyName.impl()); if (iter == symbolTable().end()) return false; SymbolTableEntry& entry = iter->second; ASSERT(!entry.isNull()); if (entry.getIndex() >= static_cast<int>(d()->functionExecutable->capturedVariableCount())) return false; entry.setAttributes(attributes); registerAt(entry.getIndex()) = value; return true; }
bool JSVariableObject::deleteProperty(ExecState* exec, const Identifier& propertyName) { if (symbolTable().contains(propertyName.impl())) return false; return JSObject::deleteProperty(exec, propertyName); }
inline bool JSActivation::symbolTablePutWithAttributes(JSGlobalData& globalData, const Identifier& propertyName, JSValue value, unsigned attributes) { ASSERT(!Heap::heap(value) || Heap::heap(value) == Heap::heap(this)); SymbolTable::iterator iter = symbolTable().find(propertyName.impl()); if (iter == symbolTable().end()) return false; SymbolTableEntry& entry = iter->second; ASSERT(!entry.isNull()); if (entry.getIndex() >= m_numCapturedVars) return false; entry.setAttributes(attributes); registerAt(entry.getIndex()).set(globalData, this, value); return true; }
void QScriptStaticScopeObject::addSymbolTableProperty(const JSC::Identifier& name, JSC::JSValue value, unsigned attributes) { int index = growRegisterArray(1); JSC::SymbolTableEntry newEntry(index, attributes | JSC::DontDelete); symbolTable().add(name.ustring().rep(), newEntry); registerAt(index) = value; }
bool JSVariableObject::deleteProperty(ExecState* exec, const Identifier& propertyName, bool checkDontDelete) { if (symbolTable().contains(propertyName.ustring().rep())) return false; return JSObject::deleteProperty(exec, propertyName, checkDontDelete); }
void navigationTest() { ElfFileSet s; s.addFile(QStringLiteral(BINDIR "elf-dissector")); QVERIFY(s.size() > 1); ElfModel model; model.setFileSet(&s); auto file = s.file(0); auto symTab = file->symbolTable(); for (uint i = 0; i < symTab->header()->entryCount(); ++i) { auto idx = model.indexForNode(symTab->entry(i)); QVERIFY(idx.isValid()); if (strcmp(symTab->entry(i)->name(), "") == 0) continue; QCOMPARE(idx.data(Qt::DisplayRole).toString(), QString(symTab->entry(i)->name())); auto url = idx.data(ElfModel::NodeUrl).toUrl(); QVERIFY(url.isValid()); QVERIFY(!url.path().isEmpty()); QVERIFY(!url.scheme().isEmpty()); auto idx2 = model.indexForUrl(url); QCOMPARE(idx, idx2); } }
const ElfSymbol * ElfImage::findSymbol(uint64_t address, bool findNearIfPossible) const { const ElfSymbolTable *symTab = symbolTable(); if (symTab) return symTab->find(address, findNearIfPossible); else return nullptr; }
JSGlobalObject::NewGlobalVar JSGlobalObject::addGlobalVar(const Identifier& ident, ConstantMode constantMode) { ConcurrentJITLocker locker(symbolTable()->m_lock); int index = symbolTable()->size(locker); SymbolTableEntry newEntry(index, (constantMode == IsConstant) ? ReadOnly : 0); if (constantMode == IsVariable) newEntry.prepareToWatch(); SymbolTable::Map::AddResult result = symbolTable()->add(locker, ident.impl(), newEntry); if (result.isNewEntry) addRegisters(1); else index = result.iterator->value.getIndex(); NewGlobalVar var; var.registerNumber = index; var.set = result.iterator->value.watchpointSet(); return var; }
bool JSVariableObject::symbolTableGet(const Identifier& propertyName, PropertyDescriptor& descriptor) { SymbolTableEntry entry = symbolTable().inlineGet(propertyName.impl()); if (!entry.isNull()) { descriptor.setDescriptor(registerAt(entry.getIndex()).jsValue(), entry.getAttributes() | DontDelete); return true; } return false; }
bool JSVariableObject::getPropertyAttributes(ExecState* exec, const Identifier& propertyName, unsigned& attributes) const { SymbolTableEntry entry = symbolTable().get(propertyName.ustring().rep()); if (!entry.isNull()) { attributes = entry.getAttributes() | DontDelete; return true; } return JSObject::getPropertyAttributes(exec, propertyName, attributes); }
inline bool JSActivation::symbolTableGet(const Identifier& propertyName, PropertySlot& slot) { SymbolTableEntry entry = symbolTable().inlineGet(propertyName.impl()); if (!entry.isNull()) { ASSERT(entry.getIndex() < static_cast<int>(d()->functionExecutable->capturedVariableCount())); slot.setRegisterSlot(®isterAt(entry.getIndex())); return true; } return false; }
const Symbol* Symbol::findSymbol(Name name) const { if (symbolTable()) { if (Symbol *symbol = symbolTable()->find(name)) { #if 0 if (symbol->symbolState() != Symbol::ResolvedState) { symbol->resolve(); } #endif return symbol; } } return 0; }
inline bool JSActivation::symbolTableGet(const Identifier& propertyName, PropertySlot& slot) { SymbolTableEntry entry = symbolTable().inlineGet(propertyName.impl()); if (entry.isNull()) return false; if (entry.getIndex() >= m_numCapturedVars) return false; slot.setValue(registerAt(entry.getIndex()).get()); return true; }
/*! Creates a static scope object with a fixed set of undeletable properties. It's not possible to add new properties to the object after construction. */ QScriptStaticScopeObject::QScriptStaticScopeObject(WTF::NonNullPassRefPtr<JSC::Structure> structure, int propertyCount, const PropertyInfo* props) : JSC::JSVariableObject(structure, new Data(/*canGrow=*/false)) { int index = growRegisterArray(propertyCount); for (int i = 0; i < propertyCount; ++i, --index) { const PropertyInfo& prop = props[i]; JSC::SymbolTableEntry entry(index, prop.attributes); symbolTable().add(prop.identifier.ustring().rep(), entry); registerAt(index) = prop.value; } }
inline bool JSActivation::symbolTablePutWithAttributes(VM& vm, PropertyName propertyName, JSValue value, unsigned attributes) { ASSERT(!Heap::heap(value) || Heap::heap(value) == Heap::heap(this)); WriteBarrierBase<Unknown>* reg; { ConcurrentJITLocker locker(symbolTable()->m_lock); SymbolTable::Map::iterator iter = symbolTable()->find(locker, propertyName.publicName()); if (iter == symbolTable()->end(locker)) return false; SymbolTableEntry& entry = iter->value; ASSERT(!entry.isNull()); if (!isValid(entry)) return false; entry.setAttributes(attributes); reg = ®isterAt(entry.getIndex()); } reg->set(vm, this, value); return true; }
inline bool JSLexicalEnvironment::symbolTableGet(PropertyName propertyName, PropertySlot& slot) { SymbolTableEntry entry = symbolTable()->inlineGet(propertyName.uid()); if (entry.isNull()) return false; // Defend against the inspector asking for a var after it has been optimized out. if (!isValid(entry)) return false; slot.setValue(this, DontEnum, registerAt(entry.getIndex()).get()); return true; }
inline bool JSLexicalEnvironment::symbolTableGet(PropertyName propertyName, PropertyDescriptor& descriptor) { SymbolTableEntry entry = symbolTable()->inlineGet(propertyName.uid()); if (entry.isNull()) return false; // Defend against the inspector asking for a var after it has been optimized out. if (!isValid(entry)) return false; descriptor.setDescriptor(registerAt(entry.getIndex()).get(), entry.getAttributes()); return true; }
inline bool JSActivation::symbolTableGet(PropertyName propertyName, PropertySlot& slot) { SymbolTableEntry entry = symbolTable()->inlineGet(propertyName.publicName()); if (entry.isNull()) return false; // Defend against the inspector asking for a var after it has been optimized out. if (isTornOff() && !isValid(entry)) return false; slot.setValue(this, DontEnum, registerAt(entry.getIndex()).get()); return true; }
inline bool JSActivation::symbolTableGet(PropertyName propertyName, PropertyDescriptor& descriptor) { SymbolTableEntry entry = symbolTable()->inlineGet(propertyName.publicName()); if (entry.isNull()) return false; // Defend against the inspector asking for a var after it has been optimized out. if (isTornOff() && !isValid(entry)) return false; descriptor.setDescriptor(registerAt(entry.getIndex()).get(), entry.getAttributes()); return true; }
inline bool JSActivation::symbolTablePut(const Identifier& propertyName, JSValue value) { ASSERT(!Heap::heap(value) || Heap::heap(value) == Heap::heap(this)); SymbolTableEntry entry = symbolTable().inlineGet(propertyName.impl()); if (entry.isNull()) return false; if (entry.isReadOnly()) return true; ASSERT(entry.getIndex() < static_cast<int>(d()->functionExecutable->capturedVariableCount())); registerAt(entry.getIndex()) = value; return true; }
void MemberAccessAST::verify(SemanticVerifier& verifier) { mAccessExpression->verify(verifier); mMemberExpression->verify(verifier); if (getField(verifier.typeChecker()).accessModifier() == AccessModifiers::Private) { auto className = mAccessExpression->expressionType(verifier.typeChecker())->name(); auto classSymbol = std::dynamic_pointer_cast<ClassSymbol>(mSymbolTable->find(className)); if (!classSymbol->symbolTable()->containsTable(mSymbolTable)) { verifier.semanticError("Cannot access private field of class " + className + "."); } } }