• Home
  • Raw
  • Download

Lines Matching full:symbol

27     const Symbol* symbol = this->find(name);  in isType()  local
28 return symbol && symbol->is<Type>(); in isType()
38 const Symbol* SymbolTable::findBuiltinSymbol(std::string_view name) const { in findBuiltinSymbol()
55 self->fSymbols.foreach([&](const SymbolKey& key, const Symbol* symbol) { in wouldShadowSymbolsFrom() argument
57 // We've already found a shadowed symbol; stop searching. in wouldShadowSymbolsFrom()
68 Symbol* SymbolTable::lookup(const SymbolKey& key) const { in lookup()
69 Symbol** symbolPPtr = fSymbols.find(key); in lookup()
74 // The symbol wasn't found; recurse into the parent symbol table. in lookup()
78 void SymbolTable::renameSymbol(const Context& context, Symbol* symbol, std::string_view newName) { in renameSymbol() argument
79 if (symbol->is<FunctionDeclaration>()) { in renameSymbol()
81 for (FunctionDeclaration* fn = &symbol->as<FunctionDeclaration>(); fn != nullptr; in renameSymbol()
87 symbol->setName(newName); in renameSymbol()
90 this->addWithoutOwnership(context, symbol); in renameSymbol()
93 std::unique_ptr<Symbol> SymbolTable::removeSymbol(const Symbol* symbol) { in removeSymbol() argument
94 // Remove the symbol from our symbol lookup table. in removeSymbol()
95 if (fSymbols.removeIfExists(MakeSymbolKey(symbol->name()))) { in removeSymbol()
96 // Transfer ownership of the symbol if we own it. (This will leave a nullptr behind in the in removeSymbol()
98 for (std::unique_ptr<Symbol>& owned : fOwnedSymbols) { in removeSymbol()
99 if (symbol == owned.get()) { in removeSymbol()
105 // We don't own the symbol after all. in removeSymbol()
109 void SymbolTable::moveSymbolTo(SymbolTable* otherTable, Symbol* sym, const Context& context) { in moveSymbolTo()
110 if (std::unique_ptr<Symbol> ownedSymbol = this->removeSymbol(sym)) { in moveSymbolTo()
123 void SymbolTable::addWithoutOwnership(const Context& context, Symbol* symbol) { in addWithoutOwnership() argument
124 if (!this->addWithoutOwnership(symbol)) { in addWithoutOwnership()
125 context.fErrors->error(symbol->position(), in addWithoutOwnership()
126 "symbol '" + std::string(symbol->name()) + "' was already defined"); in addWithoutOwnership()
130 void SymbolTable::addWithoutOwnershipOrDie(Symbol* symbol) { in addWithoutOwnershipOrDie() argument
131 if (!this->addWithoutOwnership(symbol)) { in addWithoutOwnershipOrDie()
132 SK_ABORT("symbol '%.*s' was already defined", in addWithoutOwnershipOrDie()
133 (int)symbol->name().size(), symbol->name().data()); in addWithoutOwnershipOrDie()
137 bool SymbolTable::addWithoutOwnership(Symbol* symbol) { in addWithoutOwnership() argument
138 if (symbol->name().empty()) { in addWithoutOwnership()
140 // If we find one here, we don't need to add its name to the symbol table. in addWithoutOwnership()
143 auto key = MakeSymbolKey(symbol->name()); in addWithoutOwnership()
146 if (symbol->is<FunctionDeclaration>()) { in addWithoutOwnership()
148 Symbol* existingSymbol = this->lookup(key); in addWithoutOwnership()
152 symbol->as<FunctionDeclaration>().setNextOverload(existingDecl); in addWithoutOwnership()
153 fSymbols[key] = symbol; in addWithoutOwnership()
159 // We are attempting to declare a symbol at global scope that already exists in a parent in addWithoutOwnership()
160 // module. This is a duplicate symbol and should be rejected. in addWithoutOwnership()
164 std::swap(symbol, fSymbols[key]); in addWithoutOwnership()
165 return symbol == nullptr; in addWithoutOwnership()
168 void SymbolTable::injectWithoutOwnership(Symbol* symbol) { in injectWithoutOwnership() argument
169 auto key = MakeSymbolKey(symbol->name()); in injectWithoutOwnership()
170 fSymbols[key] = symbol; in injectWithoutOwnership()
179 // If we are making an array of a builtin type, we add it as high as possible in the symbol in addArrayDimension()
184 // Reuse an existing array type with this name if one already exists in our symbol table. in addArrayDimension()
186 if (const Symbol* existingSymbol = this->find(arrayName)) { in addArrayDimension()
187 // We would expect an existing symbol named `Type[123]` to match our `Type[123]`. However, in addArrayDimension()
195 // Add a new array type to the symbol table. in addArrayDimension()
203 if (const Symbol* symbol = this->find(name)) { in instantiateSymbolRef() local
204 return symbol->instantiate(context, pos); in instantiateSymbolRef()