Lines Matching refs:decl
30 bool Parser::variable_exists(VariableDeclStmtNode *decl) const { in variable_exists()
31 if (scopes_->current_var()->lookup(decl->id_->name_, SCOPE_LOCAL) == NULL) { in variable_exists()
37 VariableDeclStmtNode *Parser::variable_add(vector<int> *types, VariableDeclStmtNode *decl) { in variable_add() argument
39 if (variable_exists(decl)) { in variable_add()
40 fprintf(stderr, "redeclaration of variable %s", decl->id_->name_.c_str()); in variable_add()
43 decl->scope_id_ = string("v") + std::to_string(scopes_->current_var()->id_) + string("_"); in variable_add()
44 scopes_->current_var()->add(decl->id_->name_, decl); in variable_add()
45 return decl; in variable_add()
48 VariableDeclStmtNode *Parser::variable_add(vector<int> *types, VariableDeclStmtNode *decl, ExprNode… in variable_add() argument
49 AssignExprNode::Ptr assign(new AssignExprNode(decl->id_->copy(), ExprNode::Ptr(init_expr))); in variable_add()
50 decl->init_.push_back(move(assign)); in variable_add()
52 if (variable_exists(decl)) { in variable_add()
53 fprintf(stderr, "redeclaration of variable %s", decl->id_->name_.c_str()); in variable_add()
56 decl->scope_id_ = string("v") + std::to_string(scopes_->current_var()->id_) + string("_"); in variable_add()
57 scopes_->current_var()->add(decl->id_->name_, decl); in variable_add()
58 return decl; in variable_add()
61 StructVariableDeclStmtNode *Parser::variable_add(StructVariableDeclStmtNode *decl, ExprNodeList *ar… in variable_add() argument
68 id->prepend_dot(decl->id_->name_); in variable_add()
75 decl->init_ = move(*args); in variable_add()
78 if (variable_exists(decl)) { in variable_add()
79 fprintf(stderr, "ccpg: warning: redeclaration of variable '%s'\n", decl->id_->name_.c_str()); in variable_add()
82 decl->scope_id_ = string("v") + std::to_string(scopes_->current_var()->id_) + string("_"); in variable_add()
83 scopes_->current_var()->add(decl->id_->name_, decl); in variable_add()
84 return decl; in variable_add()
128 bool Parser::table_exists(TableDeclStmtNode *decl, bool search_local) { in table_exists() argument
129 if (scopes_->top_table()->lookup(decl->id_->name_, search_local) == NULL) { in table_exists()
194 …auto decl = new FuncDeclStmtNode(IdentExprNode::Ptr(id), move(*formals), BlockStmtNode::Ptr(body)); in func_add() local
195 if (scopes_->top_func()->lookup(decl->id_->name_, SCOPE_LOCAL)) { in func_add()
197 return decl; in func_add()
203 delete decl; in func_add()
207 decl->scope_ = scope; in func_add()
208 scopes_->top_func()->add(id->name_, decl); in func_add()
209 return decl; in func_add()