Skip to content

Commit

Permalink
refactor: rename structures
Browse files Browse the repository at this point in the history
  • Loading branch information
JaDogg committed May 27, 2024
1 parent 6f5a595 commit a179285
Show file tree
Hide file tree
Showing 42 changed files with 837 additions and 810 deletions.
40 changes: 20 additions & 20 deletions compiler/src/ast/ast.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@
using namespace yaksha;
// ------- expressions -----
assign_expr::assign_expr(token *name, token *opr, expr *right, bool promoted,
ykdatatype *promoted_data_type)
yk_datatype *promoted_data_type)
: name_(name), opr_(opr), right_(right), promoted_(promoted),
promoted_data_type_(promoted_data_type) {}
void assign_expr::accept(expr_visitor *v) { v->visit_assign_expr(this); }
ast_type assign_expr::get_type() { return ast_type::EXPR_ASSIGN; }
token *assign_expr::locate() { return name_; }
expr *ast_pool::c_assign_expr(token *name, token *opr, expr *right,
bool promoted, ykdatatype *promoted_data_type) {
bool promoted, yk_datatype *promoted_data_type) {
auto o = new assign_expr(name, opr, right, promoted, promoted_data_type);
cleanup_expr_.push_back(o);
return o;
Expand Down Expand Up @@ -261,27 +261,27 @@ stmt *ast_pool::c_class_stmt(token *name, std::vector<parameter> members,
cleanup_stmt_.push_back(o);
return o;
}
compins_stmt::compins_stmt(token *name, ykdatatype *data_type, token *meta1,
ykdatatype *meta2, void *meta3)
compins_stmt::compins_stmt(token *name, yk_datatype *data_type, token *meta1,
yk_datatype *meta2, void *meta3)
: name_(name), data_type_(data_type), meta1_(meta1), meta2_(meta2),
meta3_(meta3) {}
void compins_stmt::accept(stmt_visitor *v) { v->visit_compins_stmt(this); }
ast_type compins_stmt::get_type() { return ast_type::STMT_COMPINS; }
token *compins_stmt::locate() { return name_; }
stmt *ast_pool::c_compins_stmt(token *name, ykdatatype *data_type, token *meta1,
ykdatatype *meta2, void *meta3) {
stmt *ast_pool::c_compins_stmt(token *name, yk_datatype *data_type,
token *meta1, yk_datatype *meta2, void *meta3) {
auto o = new compins_stmt(name, data_type, meta1, meta2, meta3);
cleanup_stmt_.push_back(o);
return o;
}
const_stmt::const_stmt(token *name, ykdatatype *data_type, expr *expression,
const_stmt::const_stmt(token *name, yk_datatype *data_type, expr *expression,
bool is_global)
: name_(name), data_type_(data_type), expression_(expression),
is_global_(is_global) {}
void const_stmt::accept(stmt_visitor *v) { v->visit_const_stmt(this); }
ast_type const_stmt::get_type() { return ast_type::STMT_CONST; }
token *const_stmt::locate() { return name_; }
stmt *ast_pool::c_const_stmt(token *name, ykdatatype *data_type,
stmt *ast_pool::c_const_stmt(token *name, yk_datatype *data_type,
expr *expression, bool is_global) {
auto o = new const_stmt(name, data_type, expression, is_global);
cleanup_stmt_.push_back(o);
Expand All @@ -298,15 +298,15 @@ stmt *ast_pool::c_continue_stmt(token *continue_token) {
return o;
}
def_stmt::def_stmt(token *name, std::vector<parameter> params,
stmt *function_body, ykdatatype *return_type,
stmt *function_body, yk_datatype *return_type,
annotations annotations)
: name_(name), params_(std::move(params)), function_body_(function_body),
return_type_(return_type), annotations_(annotations) {}
void def_stmt::accept(stmt_visitor *v) { v->visit_def_stmt(this); }
ast_type def_stmt::get_type() { return ast_type::STMT_DEF; }
token *def_stmt::locate() { return name_; }
stmt *ast_pool::c_def_stmt(token *name, std::vector<parameter> params,
stmt *function_body, ykdatatype *return_type,
stmt *function_body, yk_datatype *return_type,
annotations annotations) {
auto o = new def_stmt(name, std::move(params), function_body, return_type,
annotations);
Expand Down Expand Up @@ -376,19 +376,19 @@ stmt *ast_pool::c_expression_stmt(expr *expression) {
return o;
}
foreach_stmt::foreach_stmt(token *for_keyword, token *name,
ykdatatype *data_type, token *in_keyword,
yk_datatype *data_type, token *in_keyword,
expr *expression, stmt *for_body,
ykdatatype *expr_datatype)
yk_datatype *expr_datatype)
: for_keyword_(for_keyword), name_(name), data_type_(data_type),
in_keyword_(in_keyword), expression_(expression), for_body_(for_body),
expr_datatype_(expr_datatype) {}
void foreach_stmt::accept(stmt_visitor *v) { v->visit_foreach_stmt(this); }
ast_type foreach_stmt::get_type() { return ast_type::STMT_FOREACH; }
token *foreach_stmt::locate() { return for_keyword_; }
stmt *ast_pool::c_foreach_stmt(token *for_keyword, token *name,
ykdatatype *data_type, token *in_keyword,
yk_datatype *data_type, token *in_keyword,
expr *expression, stmt *for_body,
ykdatatype *expr_datatype) {
yk_datatype *expr_datatype) {
auto o = new foreach_stmt(for_keyword, name, data_type, in_keyword,
expression, for_body, expr_datatype);
cleanup_stmt_.push_back(o);
Expand Down Expand Up @@ -434,18 +434,18 @@ stmt *ast_pool::c_import_stmt(token *import_token,
cleanup_stmt_.push_back(o);
return o;
}
let_stmt::let_stmt(token *name, ykdatatype *data_type, expr *expression)
let_stmt::let_stmt(token *name, yk_datatype *data_type, expr *expression)
: name_(name), data_type_(data_type), expression_(expression) {}
void let_stmt::accept(stmt_visitor *v) { v->visit_let_stmt(this); }
ast_type let_stmt::get_type() { return ast_type::STMT_LET; }
token *let_stmt::locate() { return name_; }
stmt *ast_pool::c_let_stmt(token *name, ykdatatype *data_type,
stmt *ast_pool::c_let_stmt(token *name, yk_datatype *data_type,
expr *expression) {
auto o = new let_stmt(name, data_type, expression);
cleanup_stmt_.push_back(o);
return o;
}
nativeconst_stmt::nativeconst_stmt(token *name, ykdatatype *data_type,
nativeconst_stmt::nativeconst_stmt(token *name, yk_datatype *data_type,
token *ccode_keyword, token *code_str,
bool is_global)
: name_(name), data_type_(data_type), ccode_keyword_(ccode_keyword),
Expand All @@ -455,7 +455,7 @@ void nativeconst_stmt::accept(stmt_visitor *v) {
}
ast_type nativeconst_stmt::get_type() { return ast_type::STMT_NATIVECONST; }
token *nativeconst_stmt::locate() { return name_; }
stmt *ast_pool::c_nativeconst_stmt(token *name, ykdatatype *data_type,
stmt *ast_pool::c_nativeconst_stmt(token *name, yk_datatype *data_type,
token *ccode_keyword, token *code_str,
bool is_global) {
auto o =
Expand All @@ -473,14 +473,14 @@ stmt *ast_pool::c_pass_stmt(token *pass_token) {
return o;
}
return_stmt::return_stmt(token *return_keyword, expr *expression,
ykdatatype *result_type)
yk_datatype *result_type)
: return_keyword_(return_keyword), expression_(expression),
result_type_(result_type) {}
void return_stmt::accept(stmt_visitor *v) { v->visit_return_stmt(this); }
ast_type return_stmt::get_type() { return ast_type::STMT_RETURN; }
token *return_stmt::locate() { return return_keyword_; }
stmt *ast_pool::c_return_stmt(token *return_keyword, expr *expression,
ykdatatype *result_type) {
yk_datatype *result_type) {
auto o = new return_stmt(return_keyword, expression, result_type);
cleanup_stmt_.push_back(o);
return o;
Expand Down
65 changes: 33 additions & 32 deletions compiler/src/ast/ast.h
Original file line number Diff line number Diff line change
Expand Up @@ -172,15 +172,15 @@ namespace yaksha {
// ------- expressions ------
struct assign_expr : expr {
assign_expr(token *name, token *opr, expr *right, bool promoted,
ykdatatype *promoted_data_type);
yk_datatype *promoted_data_type);
void accept(expr_visitor *v) override;
ast_type get_type() override;
token *locate() override;
token *name_;
token *opr_;
expr *right_;
bool promoted_;
ykdatatype *promoted_data_type_;
yk_datatype *promoted_data_type_;
};
struct assign_arr_expr : expr {
assign_arr_expr(expr *assign_oper, token *opr, expr *right);
Expand Down Expand Up @@ -368,25 +368,25 @@ namespace yaksha {
annotations annotations_;
};
struct compins_stmt : stmt {
compins_stmt(token *name, ykdatatype *data_type, token *meta1,
ykdatatype *meta2, void *meta3);
compins_stmt(token *name, yk_datatype *data_type, token *meta1,
yk_datatype *meta2, void *meta3);
void accept(stmt_visitor *v) override;
ast_type get_type() override;
token *locate() override;
token *name_;
ykdatatype *data_type_;
yk_datatype *data_type_;
token *meta1_;
ykdatatype *meta2_;
yk_datatype *meta2_;
void *meta3_;
};
struct const_stmt : stmt {
const_stmt(token *name, ykdatatype *data_type, expr *expression,
const_stmt(token *name, yk_datatype *data_type, expr *expression,
bool is_global);
void accept(stmt_visitor *v) override;
ast_type get_type() override;
token *locate() override;
token *name_;
ykdatatype *data_type_;
yk_datatype *data_type_;
expr *expression_;
bool is_global_;
};
Expand All @@ -399,14 +399,14 @@ namespace yaksha {
};
struct def_stmt : stmt {
def_stmt(token *name, std::vector<parameter> params, stmt *function_body,
ykdatatype *return_type, annotations annotations);
yk_datatype *return_type, annotations annotations);
void accept(stmt_visitor *v) override;
ast_type get_type() override;
token *locate() override;
token *name_;
std::vector<parameter> params_;
stmt *function_body_;
ykdatatype *return_type_;
yk_datatype *return_type_;
annotations annotations_;
};
struct defer_stmt : stmt {
Expand Down Expand Up @@ -478,19 +478,19 @@ namespace yaksha {
expr *expression_;
};
struct foreach_stmt : stmt {
foreach_stmt(token *for_keyword, token *name, ykdatatype *data_type,
foreach_stmt(token *for_keyword, token *name, yk_datatype *data_type,
token *in_keyword, expr *expression, stmt *for_body,
ykdatatype *expr_datatype);
yk_datatype *expr_datatype);
void accept(stmt_visitor *v) override;
ast_type get_type() override;
token *locate() override;
token *for_keyword_;
token *name_;
ykdatatype *data_type_;
yk_datatype *data_type_;
token *in_keyword_;
expr *expression_;
stmt *for_body_;
ykdatatype *expr_datatype_;
yk_datatype *expr_datatype_;
};
struct forendless_stmt : stmt {
forendless_stmt(token *for_keyword, stmt *for_body);
Expand Down Expand Up @@ -524,12 +524,12 @@ namespace yaksha {
file_info *data_;
};
struct let_stmt : stmt {
let_stmt(token *name, ykdatatype *data_type, expr *expression);
let_stmt(token *name, yk_datatype *data_type, expr *expression);
void accept(stmt_visitor *v) override;
ast_type get_type() override;
token *locate() override;
token *name_;
ykdatatype *data_type_;
yk_datatype *data_type_;
expr *expression_;
};
struct macros_stmt : stmt {
Expand All @@ -545,13 +545,13 @@ namespace yaksha {
token *curly_close_;
};
struct nativeconst_stmt : stmt {
nativeconst_stmt(token *name, ykdatatype *data_type, token *ccode_keyword,
nativeconst_stmt(token *name, yk_datatype *data_type, token *ccode_keyword,
token *code_str, bool is_global);
void accept(stmt_visitor *v) override;
ast_type get_type() override;
token *locate() override;
token *name_;
ykdatatype *data_type_;
yk_datatype *data_type_;
token *ccode_keyword_;
token *code_str_;
bool is_global_;
Expand All @@ -565,13 +565,13 @@ namespace yaksha {
};
struct return_stmt : stmt {
return_stmt(token *return_keyword, expr *expression,
ykdatatype *result_type);
yk_datatype *result_type);
void accept(stmt_visitor *v) override;
ast_type get_type() override;
token *locate() override;
token *return_keyword_;
expr *expression_;
ykdatatype *result_type_;
yk_datatype *result_type_;
};
struct runtimefeature_stmt : stmt {
runtimefeature_stmt(token *runtimefeature_token, token *feature);
Expand Down Expand Up @@ -602,7 +602,7 @@ namespace yaksha {
ast_pool();
~ast_pool();
expr *c_assign_expr(token *name, token *opr, expr *right, bool promoted,
ykdatatype *promoted_data_type);
yk_datatype *promoted_data_type);
expr *c_assign_arr_expr(expr *assign_oper, token *opr, expr *right);
expr *c_assign_member_expr(expr *set_oper, token *opr, expr *right);
expr *c_binary_expr(expr *left, token *opr, expr *right);
Expand Down Expand Up @@ -632,13 +632,13 @@ namespace yaksha {
expr *operation, token *close_paren, stmt *for_body);
stmt *c_class_stmt(token *name, std::vector<parameter> members,
annotations annotations);
stmt *c_compins_stmt(token *name, ykdatatype *data_type, token *meta1,
ykdatatype *meta2, void *meta3);
stmt *c_const_stmt(token *name, ykdatatype *data_type, expr *expression,
stmt *c_compins_stmt(token *name, yk_datatype *data_type, token *meta1,
yk_datatype *meta2, void *meta3);
stmt *c_const_stmt(token *name, yk_datatype *data_type, expr *expression,
bool is_global);
stmt *c_continue_stmt(token *continue_token);
stmt *c_def_stmt(token *name, std::vector<parameter> params,
stmt *function_body, ykdatatype *return_type,
stmt *function_body, yk_datatype *return_type,
annotations annotations);
stmt *c_defer_stmt(token *defer_keyword, expr *expression,
stmt *del_statement);
Expand All @@ -654,24 +654,25 @@ namespace yaksha {
stmt *c_enum_stmt(token *name, std::vector<parameter> members,
annotations annotations);
stmt *c_expression_stmt(expr *expression);
stmt *c_foreach_stmt(token *for_keyword, token *name, ykdatatype *data_type,
token *in_keyword, expr *expression, stmt *for_body,
ykdatatype *expr_datatype);
stmt *c_foreach_stmt(token *for_keyword, token *name,
yk_datatype *data_type, token *in_keyword,
expr *expression, stmt *for_body,
yk_datatype *expr_datatype);
stmt *c_forendless_stmt(token *for_keyword, stmt *for_body);
stmt *c_if_stmt(token *if_keyword, expr *expression, stmt *if_branch,
token *else_keyword, stmt *else_branch);
stmt *c_import_stmt(token *import_token, std::vector<token *> import_names,
token *name, file_info *data);
stmt *c_let_stmt(token *name, ykdatatype *data_type, expr *expression);
stmt *c_let_stmt(token *name, yk_datatype *data_type, expr *expression);
stmt *c_macros_stmt(token *macros_token, token *not_symbol_tok,
token *curly_open, std::vector<token *> lisp_code,
token *curly_close);
stmt *c_nativeconst_stmt(token *name, ykdatatype *data_type,
stmt *c_nativeconst_stmt(token *name, yk_datatype *data_type,
token *ccode_keyword, token *code_str,
bool is_global);
stmt *c_pass_stmt(token *pass_token);
stmt *c_return_stmt(token *return_keyword, expr *expression,
ykdatatype *result_type);
yk_datatype *result_type);
stmt *c_runtimefeature_stmt(token *runtimefeature_token, token *feature);
stmt *c_token_soup_stmt(std::vector<token *> soup);
stmt *c_while_stmt(token *while_keyword, expr *expression,
Expand All @@ -686,7 +687,7 @@ namespace yaksha {
*/
struct parameter {
token *name_;
ykdatatype *data_type_;
yk_datatype *data_type_;
token *enum_val_override_;
};
/**
Expand Down
2 changes: 1 addition & 1 deletion compiler/src/ast/ast_vis.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ void ast_vis::visit_class_stmt(class_stmt *obj) {
end_block();
}
void ast_vis::field(const std::string &name, const std::string &literal_obj,
ykdatatype *dt) {
yk_datatype *dt) {
text_ << R"(<div class="field"><div class="field_title">)"
<< ::string_utils::html_escape(name) << "</div>";
text_ << ::string_utils::html_escape(literal_obj) << ": <code>";
Expand Down
2 changes: 1 addition & 1 deletion compiler/src/ast/ast_vis.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ namespace yaksha {
void field(const std::string &name, stmt *stmt);
void field(const std::string &name, const std::string &literal_obj);
void field(const std::string &name, const std::string &literal_obj,
ykdatatype *dt);
yk_datatype *dt);
void begin_block(const std::string &name);
void end_block();
void visit_expression_stmt(expression_stmt *obj) override;
Expand Down
2 changes: 1 addition & 1 deletion compiler/src/ast/codefiles.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ namespace yaksha {
file_info *scan_or_null(import_stmt *st);
std::vector<file_info *> files_;
file_info *main_file_info_{nullptr};
ykdt_pool pool_;
yk_datatype_pool pool_;
yaksha_macros yaksha_macros_{};
entry_struct_func_compiler *esc_;
directives directives_{};
Expand Down
6 changes: 3 additions & 3 deletions compiler/src/ast/environment.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,10 @@ environment::~environment() = default;
bool environment::is_defined(const std::string &name) {
return variables_.find(name) != variables_.end();
}
void environment::define(const std::string &name, ykobject data) {
void environment::define(const std::string &name, yk_object data) {
variables_.emplace(name, std::move(data));
}
ykobject environment::get(const std::string &name) { return variables_[name]; }
void environment::assign(const std::string &name, ykobject data) {
yk_object environment::get(const std::string &name) { return variables_[name]; }
void environment::assign(const std::string &name, yk_object data) {
variables_[name] = std::move(data);
}
Loading

0 comments on commit a179285

Please sign in to comment.