241 void push_context() {
249 sammine_util::abort(
"ICE: You are popping an empty lexical stack");
253 void registerNameT(
const std::string &name, T l) {
254 return this->top().registerNameT(name, l);
257 return this->top().recursiveQueryName(name);
260 T get_from_name(
const std::string &name)
const {
261 return this->top().get_from_name(name);
264 return this->top().queryName(name);
267 T recursive_get_from_name(
const std::string &name)
const {
268 return this->top().recursive_get_from_name(name);
272 return this->top().parent_scope;
345 static inline std::atomic<NodeId> next_id_{0};
349 if (first_location) {
350 this->location = loc;
351 first_location =
false;
353 this->location |= loc;
356 bool first_location =
true;
362 AstBase(NodeKind kind) : kind(kind), node_id_(next_id_++) {}
363 NodeId id()
const {
return node_id_; }
364 static void reset_id_counter() { next_id_ = 0; }
365 static void set_properties(
ASTProperties *p) { current_props_ = p; }
366 NodeKind getKind()
const {
return kind; }
370 AstBase *join_location(AstBase *ast) {
374 change_location(ast->get_location());
379 AstBase *join_location(std::shared_ptr<Token> tok) {
384 change_location(tok->get_location());
390 if (location.source_start <= 0 && location.source_end <= 0)
393 change_location(location);
398 this->location = loc;
399 first_location =
false;
401 bool synthesized()
const {
return get_type().synthesized(); }
402 Type get_type()
const {
404 return current_props_->get_type(node_id_);
405 return Type::NonExistent();
409 current_props_->set_type(node_id_, t);
A simple scoping class, doesn't differentiate between different names, like variable name,...
NameQueryResult
NameQueryResult enum.
Definition LexicalContext.h:13
LexicalContext class.
Definition LexicalContext.h:19