mirror of
https://codeberg.org/ProgramSnail/lang.git
synced 2025-12-06 06:58:46 +00:00
fixes, part of statement printers done
This commit is contained in:
parent
bf49f4030c
commit
c176d1b11d
4 changed files with 315 additions and 7 deletions
|
|
@ -19,13 +19,25 @@ public:
|
|||
: Node(node), import_name_(import_name), module_name_(module_name),
|
||||
symbols_(std::move(symbols)) {}
|
||||
|
||||
//
|
||||
|
||||
Identifier *get_import_name() { return &import_name_; }
|
||||
|
||||
const Identifier *get_import_name() const { return &import_name_; }
|
||||
|
||||
//
|
||||
|
||||
Identifier *get_module_name() { return &module_name_; }
|
||||
|
||||
const Identifier *get_module_name() const { return &module_name_; }
|
||||
|
||||
//
|
||||
|
||||
size_t symbols_size() const { return symbols_.size(); }
|
||||
|
||||
std::string *get_symbol(size_t id) { return symbols_.at(id).get(); }
|
||||
Identifier *get_symbol(size_t id) { return &symbols_.at(id); }
|
||||
|
||||
const std::string *get_symbol(size_t id) const {
|
||||
return symbols_.at(id).get();
|
||||
}
|
||||
const Identifier *get_symbol(size_t id) const { return &symbols_.at(id); }
|
||||
|
||||
private:
|
||||
Identifier import_name_;
|
||||
|
|
@ -71,6 +83,106 @@ public:
|
|||
optional_arguments_(optional_arguments),
|
||||
result_arguments_(result_arguments), expression_(expression) {}
|
||||
|
||||
//
|
||||
|
||||
SymbolDocs *get_docs() { return &docs_; }
|
||||
|
||||
const SymbolDocs *get_docs() const { return &docs_; }
|
||||
|
||||
//
|
||||
|
||||
size_t get_constraints_size() const { return arguments_.size(); }
|
||||
|
||||
Constraint *get_constraint(size_t id) { return &constraints_.at(id); }
|
||||
|
||||
const Constraint *get_constraint(size_t id) const {
|
||||
return &constraints_.at(id);
|
||||
}
|
||||
|
||||
//
|
||||
|
||||
ModifierType get_modifier() { return modifier_; }
|
||||
|
||||
//
|
||||
|
||||
Identifier *get_name() { return &name_; }
|
||||
|
||||
const Identifier *get_name() const { return &name_; }
|
||||
|
||||
//
|
||||
|
||||
std::optional<std::string *> get_argument_annotation(size_t id) {
|
||||
if (annotations_.at(id).has_value()) {
|
||||
return &annotations_[id].value();
|
||||
}
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
std::optional<const std::string *> get_argument_annotation(size_t id) const {
|
||||
if (annotations_.at(id).has_value()) {
|
||||
return &annotations_[id].value();
|
||||
}
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
//
|
||||
|
||||
size_t get_arguments_size() const { return arguments_.size(); }
|
||||
|
||||
Identifier *get_argument(size_t id) { return &arguments_.at(id); }
|
||||
|
||||
const Identifier *get_argument(size_t id) const { return &arguments_.at(id); }
|
||||
|
||||
//
|
||||
|
||||
Modifier get_argument_reference_type(size_t id) {
|
||||
return reference_types_.at(id);
|
||||
}
|
||||
|
||||
//
|
||||
|
||||
size_t get_argument_types_size() const { return types_.size(); }
|
||||
|
||||
std::optional<Type *> get_argument_type(size_t id) {
|
||||
if (types_.at(id).has_value()) {
|
||||
return types_[id].value().get();
|
||||
}
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
std::optional<const Type *> get_argument_type(size_t id) const {
|
||||
if (types_.at(id).has_value()) {
|
||||
return types_[id].value().get();
|
||||
}
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
//
|
||||
|
||||
bool is_argument_optional(size_t id) const {
|
||||
return optional_arguments_.at(id);
|
||||
}
|
||||
|
||||
//
|
||||
|
||||
bool is_argument_result(size_t id) const { return result_arguments_.at(id); }
|
||||
|
||||
//
|
||||
|
||||
std::optional<Expression *> get_expression() {
|
||||
if (expression_.has_value()) {
|
||||
return expression_.value().get();
|
||||
}
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
std::optional<const Expression *> get_expression() const {
|
||||
if (expression_.has_value()) {
|
||||
return expression_.value().get();
|
||||
}
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
private:
|
||||
SymbolDocs docs_;
|
||||
std::vector<Constraint> constraints_;
|
||||
|
|
@ -83,7 +195,7 @@ private:
|
|||
std::vector<bool> optional_arguments_;
|
||||
std::vector<bool> result_arguments_;
|
||||
std::optional<ExpressionProxy> expression_;
|
||||
}; // IN PROGRESS
|
||||
}; // refactor ??
|
||||
|
||||
class TypeDefinition : public Node {
|
||||
public:
|
||||
|
|
@ -95,6 +207,56 @@ public:
|
|||
name_(name), arguments_(std::move(arguments)), type_(std::move(type)),
|
||||
methods_(std::move(methods)) {}
|
||||
|
||||
//
|
||||
|
||||
SymbolDocs *get_docs() { return &docs_; }
|
||||
|
||||
const SymbolDocs *get_docs() const { return &docs_; }
|
||||
|
||||
//
|
||||
|
||||
bool is_on_heap() { return is_on_heap_; }
|
||||
|
||||
//
|
||||
|
||||
Identifier *get_name() { return &name_; }
|
||||
|
||||
const Identifier *get_name() const { return &name_; }
|
||||
|
||||
//
|
||||
|
||||
size_t get_arguments_size() const { return arguments_.size(); }
|
||||
|
||||
Identifier *get_argument(size_t id) { return &arguments_.at(id); }
|
||||
|
||||
const Identifier *get_argument(size_t id) const { return &arguments_.at(id); }
|
||||
|
||||
//
|
||||
|
||||
std::optional<VariantType *> get_type() {
|
||||
if (type_.has_value()) {
|
||||
return &type_.value();
|
||||
}
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
std::optional<const VariantType *> get_type() const {
|
||||
if (type_.has_value()) {
|
||||
return &type_.value();
|
||||
}
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
//
|
||||
|
||||
size_t get_methods_size() const { return methods_.size(); }
|
||||
|
||||
FunctionDefinition *get_method(size_t id) { return &methods_.at(id); }
|
||||
|
||||
const FunctionDefinition *get_method(size_t id) const {
|
||||
return &methods_.at(id);
|
||||
}
|
||||
|
||||
private:
|
||||
SymbolDocs docs_;
|
||||
bool is_on_heap_;
|
||||
|
|
@ -102,7 +264,7 @@ private:
|
|||
std::vector<Identifier> arguments_;
|
||||
std::optional<VariantType> type_; // TupleType is VariantType with one variant
|
||||
std::vector<FunctionDefinition> methods_;
|
||||
}; // IN PROGRESS
|
||||
};
|
||||
|
||||
class TypeclassDefinition : public Node {
|
||||
public:
|
||||
|
|
@ -113,11 +275,45 @@ public:
|
|||
base_typeclasses_(std::move(base_typeclasses)),
|
||||
methods_(std::move(methods)) {}
|
||||
|
||||
//
|
||||
|
||||
SymbolDocs *get_docs() { return &docs_; }
|
||||
|
||||
const SymbolDocs *get_docs() const { return &docs_; }
|
||||
|
||||
//
|
||||
|
||||
Identifier *get_name() { return &name_; }
|
||||
|
||||
const Identifier *get_name() const { return &name_; }
|
||||
|
||||
//
|
||||
|
||||
size_t get_base_typeclasses_size() const { return base_typeclasses_.size(); }
|
||||
|
||||
Identifier *get_base_typeclass(size_t id) {
|
||||
return &base_typeclasses_.at(id);
|
||||
}
|
||||
|
||||
const Identifier *get_base_typeclass(size_t id) const {
|
||||
return &base_typeclasses_.at(id);
|
||||
}
|
||||
|
||||
//
|
||||
|
||||
size_t get_methods_size() const { return methods_.size(); }
|
||||
|
||||
FunctionDefinition *get_method(size_t id) { return &methods_.at(id); }
|
||||
|
||||
const FunctionDefinition *get_method(size_t id) const {
|
||||
return &methods_.at(id);
|
||||
}
|
||||
|
||||
private:
|
||||
SymbolDocs docs_;
|
||||
Identifier name_;
|
||||
std::vector<Identifier> base_typeclasses_;
|
||||
std::vector<FunctionDefinition> methods_;
|
||||
}; // IN PROGRESS
|
||||
};
|
||||
|
||||
} // namespace nodes
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue