60class SimpleTypeExprAST :
public TypeExprAST {
63 explicit SimpleTypeExprAST(std::shared_ptr<Token> tok)
64 : TypeExprAST(ParseKind::Simple),
65 name(sammine_util::QualifiedName::local(tok ? tok->lexeme :
"")) {
67 location = tok->get_location();
71 : TypeExprAST(ParseKind::Simple), name(std::move(qn)) {
74 static bool classof(
const TypeExprAST *node) {
75 return node->getKind() == ParseKind::Simple;
77 std::string to_string()
const override {
return name.mangled(); }
80class PointerTypeExprAST :
public TypeExprAST {
82 std::unique_ptr<TypeExprAST> pointee;
83 bool is_linear =
false;
84 explicit PointerTypeExprAST(std::unique_ptr<TypeExprAST> pointee,
85 bool is_linear =
false)
86 : TypeExprAST(ParseKind::Pointer), pointee(std::move(pointee)),
87 is_linear(is_linear) {}
88 static bool classof(
const TypeExprAST *node) {
89 return node->getKind() == ParseKind::Pointer;
91 std::string to_string()
const override {
92 return (is_linear ?
"'" :
"") + std::string(
"ptr<") + pointee->to_string() +
">";
96class ArrayTypeExprAST :
public TypeExprAST {
98 std::unique_ptr<TypeExprAST> element;
100 ArrayTypeExprAST(std::unique_ptr<TypeExprAST> element,
size_t size)
101 : TypeExprAST(ParseKind::Array), element(std::move(element)),
103 static bool classof(
const TypeExprAST *node) {
104 return node->getKind() == ParseKind::Array;
106 std::string to_string()
const override {
107 return "[" + element->to_string() +
";" + std::to_string(size) +
"]";
111class FunctionTypeExprAST :
public TypeExprAST {
113 std::vector<std::unique_ptr<TypeExprAST>> paramTypes;
114 std::unique_ptr<TypeExprAST> returnType;
115 FunctionTypeExprAST(std::vector<std::unique_ptr<TypeExprAST>> paramTypes,
116 std::unique_ptr<TypeExprAST> returnType)
117 : TypeExprAST(ParseKind::Function),
118 paramTypes(std::move(paramTypes)), returnType(std::move(returnType)) {}
119 static bool classof(
const TypeExprAST *node) {
120 return node->getKind() == ParseKind::Function;
122 std::string to_string()
const override {
123 std::string res =
"(";
124 for (
size_t i = 0; i < paramTypes.size(); i++) {
125 res += paramTypes[i]->to_string();
126 if (i != paramTypes.size() - 1)
129 res +=
") -> " + returnType->to_string();
135class GenericTypeExprAST :
public TypeExprAST {
138 std::vector<std::unique_ptr<TypeExprAST>> type_args;
140 std::vector<std::unique_ptr<TypeExprAST>> type_args,
142 : TypeExprAST(ParseKind::Generic), base_name(std::move(base_name)),
143 type_args(std::move(type_args)) {
146 static bool classof(
const TypeExprAST *node) {
147 return node->getKind() == ParseKind::Generic;
149 std::string to_string()
const override {
150 std::string res = base_name.mangled() +
"<";
151 for (
size_t i = 0; i < type_args.size(); i++) {
152 res += type_args[i]->to_string();
153 if (i != type_args.size() - 1)
161class TupleTypeExprAST :
public TypeExprAST {
163 std::vector<std::unique_ptr<TypeExprAST>> element_types;
164 TupleTypeExprAST(std::vector<std::unique_ptr<TypeExprAST>> element_types)
165 : TypeExprAST(ParseKind::Tuple),
166 element_types(std::move(element_types)) {}
167 static bool classof(
const TypeExprAST *node) {
168 return node->getKind() == ParseKind::Tuple;
170 std::string to_string()
const override {
171 std::string res =
"(";
172 for (
size_t i = 0; i < element_types.size(); i++) {
173 res += element_types[i]->to_string();
174 if (i != element_types.size() - 1)
208 bool is_mutable =
false;
209 std::unique_ptr<TypeExprAST> type_expr;
211 explicit TypedVarAST(std::shared_ptr<Token> name,
212 std::unique_ptr<TypeExprAST> type_expr,
213 bool is_mutable =
false)
214 : AstBase(NodeKind::TypedVarAST), is_mutable(is_mutable),
215 type_expr(std::move(type_expr)) {
216 this->join_location(name);
218 this->name = name->lexeme;
220 this->join_location(this->type_expr->location);
222 explicit TypedVarAST(std::shared_ptr<Token> name,
bool is_mutable =
false)
223 : AstBase(NodeKind::TypedVarAST), is_mutable(is_mutable) {
224 this->join_location(name);
226 this->name = name->lexeme;
228 std::string to_string()
const;
229 AST_NODE_METHODS(
"TypedVarAST", NodeKind::TypedVarAST)
238 llvm::Function *function;
240 std::unique_ptr<TypeExprAST> return_type_expr;
241 std::vector<std::unique_ptr<AST::TypedVarAST>> parameterVectors;
242 std::vector<std::string> type_params;
243 bool is_var_arg =
false;
244 bool is_generic()
const {
return !type_params.empty(); }
246 explicit PrototypeAST(
249 std::unique_ptr<TypeExprAST> return_type_expr,
250 std::vector<std::unique_ptr<AST::TypedVarAST>> parameterVectors)
251 : AstBase(NodeKind::PrototypeAST),
252 return_type_expr(std::move(return_type_expr)) {
253 this->functionName = std::move(functionName);
254 this->join_location(name_loc);
255 if (this->return_type_expr)
256 this->join_location(this->return_type_expr->location);
258 this->parameterVectors = std::move(parameterVectors);
260 for (
size_t i = 0; i < this->parameterVectors.size(); i++)
261 assert(this->parameterVectors[i]);
262 for (
size_t i = 0; i < this->parameterVectors.size(); i++)
263 this->join_location(this->parameterVectors[i]->get_location());
266 explicit PrototypeAST(
269 std::vector<std::unique_ptr<AST::TypedVarAST>> parameterVectors)
270 : AstBase(NodeKind::PrototypeAST) {
271 this->functionName = std::move(functionName);
272 this->join_location(name_loc);
274 this->parameterVectors = std::move(parameterVectors);
276 for (
size_t i = 0; i < this->parameterVectors.size(); i++)
277 assert(this->parameterVectors[i]);
278 for (
size_t i = 0; i < this->parameterVectors.size(); i++)
279 this->join_location(this->parameterVectors[i]->get_location());
282 bool returnsUnit()
const {
return return_type_expr ==
nullptr; }
284 std::string to_string()
const;
286 AST_NODE_METHODS(
"PrototypeAST", NodeKind::PrototypeAST)
291class ExternAST :
public DefinitionAST {
293 std::unique_ptr<PrototypeAST> Prototype;
294 bool is_exposed =
false;
296 ExternAST(std::unique_ptr<PrototypeAST> Prototype)
297 : DefinitionAST(NodeKind::ExternAST), Prototype(std::move(Prototype)) {
298 this->join_location(this->Prototype.get());
300 AST_NODE_METHODS(
"ExternAST", NodeKind::ExternAST)
326class FuncDefAST :
public DefinitionAST {
328 ~FuncDefAST() =
default;
329 std::unique_ptr<PrototypeAST> Prototype;
330 std::unique_ptr<BlockAST> Block;
331 bool is_exported =
false;
333 FuncDefAST(std::unique_ptr<PrototypeAST> Prototype,
334 std::unique_ptr<BlockAST> Block)
335 : DefinitionAST(NodeKind::FuncDefAST), Prototype(std::move(Prototype)),
336 Block(std::move(Block)) {
337 this->join_location(this->Prototype.get())
338 ->join_location(this->Block.get());
341 std::string getFunctionName()
const {
return Prototype->functionName.mangled(); }
343 bool returnsUnit()
const {
return Prototype->returnsUnit(); }
345 std::string to_string()
const;
347 AST_NODE_METHODS(
"FuncDefAST", NodeKind::FuncDefAST)
351class StructDefAST :
public DefinitionAST {
354 std::vector<std::unique_ptr<TypedVarAST>> struct_members;
355 bool is_exported =
false;
359 decltype(struct_members) struct_members)
360 : DefinitionAST(NodeKind::StructDefAST),
361 struct_name(std::move(name)),
362 struct_members(std::move(struct_members)) {
363 this->join_location(name_loc);
364 for (
auto &m : struct_members)
365 this->join_location(m.get());
367 AST_NODE_METHODS(
"StructDefAST", NodeKind::StructDefAST)
378class EnumDefAST :
public DefinitionAST {
381 std::vector<EnumVariantDef> variants;
382 std::vector<std::string> type_params;
383 bool is_integer_backed =
false;
384 bool is_exported =
false;
385 std::optional<std::string> backing_type_name;
389 std::vector<EnumVariantDef> variants)
390 : DefinitionAST(NodeKind::EnumDefAST),
391 enum_name(std::move(name)), variants(std::move(variants)) {
392 this->join_location(name_loc);
393 for (
auto &v : this->variants)
394 this->join_location(v.location);
396 AST_NODE_METHODS(
"EnumDefAST", NodeKind::EnumDefAST)
400class TypeAliasDefAST :
public DefinitionAST {
403 std::unique_ptr<TypeExprAST> type_expr;
404 bool is_exported =
false;
406 explicit TypeAliasDefAST(std::shared_ptr<Token> name_tok,
407 std::unique_ptr<TypeExprAST> type_expr)
408 : DefinitionAST(NodeKind::TypeAliasDefAST),
409 type_expr(std::move(type_expr)) {
411 alias_name = sammine_util::QualifiedName::local(name_tok->lexeme);
412 this->join_location(name_tok);
414 this->join_location(this->type_expr->location);
416 AST_NODE_METHODS(
"TypeAliasDefAST", NodeKind::TypeAliasDefAST)
420class VarDefAST :
public ExprAST {
422 bool is_mutable =
false;
423 bool is_tuple_destructure =
false;
424 std::unique_ptr<TypedVarAST> TypedVar;
425 std::vector<std::unique_ptr<TypedVarAST>> destructure_vars;
426 std::unique_ptr<ExprAST> Expression;
428 explicit VarDefAST(std::shared_ptr<Token> let,
429 std::unique_ptr<TypedVarAST> TypedVar,
430 std::unique_ptr<ExprAST> Expression,
431 bool is_mutable =
false)
432 : ExprAST(NodeKind::VarDefAST), is_mutable(is_mutable),
433 TypedVar(std::move(TypedVar)), Expression(std::move(Expression)) {
435 this->join_location(let)
436 ->join_location(this->TypedVar.get())
437 ->join_location(this->Expression.get());
441 explicit VarDefAST(std::shared_ptr<Token> let,
442 std::vector<std::unique_ptr<TypedVarAST>> destructure_vars,
443 std::unique_ptr<ExprAST> Expression,
444 bool is_mutable =
false)
445 : ExprAST(NodeKind::VarDefAST), is_mutable(is_mutable),
446 is_tuple_destructure(
true),
447 destructure_vars(std::move(destructure_vars)),
448 Expression(std::move(Expression)) {
449 this->join_location(let);
450 for (
auto &v : this->destructure_vars)
451 this->join_location(v.get());
452 this->join_location(this->Expression.get());
455 std::string to_string()
const override;
456 AST_NODE_METHODS(
"VarDefAST", NodeKind::VarDefAST)
471class StringExprAST :
public ExprAST {
473 std::string string_content;
475 explicit StringExprAST(std::shared_ptr<Token> t)
476 : ExprAST(NodeKind::StringExprAST) {
479 string_content = t->lexeme;
481 std::string to_string()
const override;
482 AST_NODE_METHODS(
"StringExprAST", NodeKind::StringExprAST)
505class BinaryExprAST :
public ExprAST {
507 std::shared_ptr<Token> Op;
508 std::unique_ptr<ExprAST> LHS, RHS;
509 BinaryExprAST(std::shared_ptr<Token> op, std::unique_ptr<ExprAST> LHS,
510 std::unique_ptr<ExprAST> RHS)
511 : ExprAST(NodeKind::BinaryExprAST), Op(op), LHS(std::move(LHS)),
512 RHS(std::move(RHS)) {
513 this->join_location(this->Op)
514 ->join_location(this->LHS.get())
515 ->join_location(this->RHS.get());
518 std::string to_string()
const override;
519 AST_NODE_METHODS(
"BinaryExprAST", NodeKind::BinaryExprAST)
521class ReturnExprAST :
public ExprAST {
525 std::unique_ptr<ExprAST> return_expr;
526 ReturnExprAST(std::shared_ptr<Token> return_tok,
527 std::unique_ptr<ExprAST> return_expr)
528 : ExprAST(NodeKind::ReturnExprAST), is_implicit(
false),
529 return_expr(std::move(return_expr)) {
530 if (this->return_expr ==
nullptr) {
531 this->join_location(return_tok);
532 }
else if (return_tok ==
nullptr) {
533 this->join_location(this->return_expr.get());
534 }
else if (return_tok && this->return_expr) {
535 this->join_location(return_tok)->join_location(this->return_expr.get());
539 ReturnExprAST(std::unique_ptr<ExprAST> return_expr)
540 : ExprAST(NodeKind::ReturnExprAST), is_implicit(
true),
541 return_expr(std::move(return_expr)) {
542 this->join_location(this->return_expr.get());
545 std::string to_string()
const override;
546 AST_NODE_METHODS(
"ReturnExprAST", NodeKind::ReturnExprAST)
548class CallExprAST :
public ExprAST {
552 std::vector<std::unique_ptr<AST::ExprAST>> arguments;
553 std::vector<std::unique_ptr<TypeExprAST>> explicit_type_args;
554 explicit CallExprAST(
555 std::shared_ptr<Token> tok,
556 std::vector<std::unique_ptr<AST::ExprAST>> arguments = {})
557 : ExprAST(NodeKind::CallExprAST),
558 functionName(sammine_util::QualifiedName::local(
559 tok ? tok->lexeme :
"")) {
561 for (
auto &arg : arguments)
563 this->join_location(arg.get());
564 this->arguments = std::move(arguments);
566 explicit CallExprAST(
568 std::vector<std::unique_ptr<AST::ExprAST>> arguments = {})
569 : ExprAST(NodeKind::CallExprAST), functionName(std::move(qn)) {
570 this->location = loc;
571 for (
auto &arg : arguments)
573 this->join_location(arg.get());
574 this->arguments = std::move(arguments);
577 std::string to_string()
const override;
578 AST_NODE_METHODS(
"CallExprAST", NodeKind::CallExprAST)
581class UnitExprAST :
public ExprAST {
586 explicit UnitExprAST(std::shared_ptr<Token> left_paren,
587 std::shared_ptr<Token> right_paren)
588 : ExprAST(NodeKind::UnitExprAST), is_implicit(
false) {
591 this->join_location(left_paren)->join_location(right_paren);
593 explicit UnitExprAST() : ExprAST(NodeKind::UnitExprAST), is_implicit(
true) {}
595 std::string to_string()
const override;
596 AST_NODE_METHODS(
"UnitExprAST", NodeKind::UnitExprAST)
598class IfExprAST :
public ExprAST {
600 std::unique_ptr<ExprAST> bool_expr;
601 std::unique_ptr<BlockAST> thenBlockAST, elseBlockAST;
602 explicit IfExprAST(std::unique_ptr<ExprAST> bool_expr,
603 std::unique_ptr<BlockAST> thenBlockAST,
604 std::unique_ptr<BlockAST> elseBlockAST)
605 : ExprAST(NodeKind::IfExprAST), bool_expr(std::move(bool_expr)),
606 thenBlockAST(std::move(thenBlockAST)),
607 elseBlockAST(std::move(elseBlockAST)) {
608 this->join_location(this->bool_expr.get())
609 ->join_location(this->thenBlockAST.get())
610 ->join_location(this->elseBlockAST.get());
613 std::string to_string()
const override;
614 AST_NODE_METHODS(
"IfExprAST", NodeKind::IfExprAST)
616class VariableExprAST :
public ExprAST {
618 std::string variableName;
619 VariableExprAST(std::shared_ptr<Token> var)
620 : ExprAST(NodeKind::VariableExprAST) {
623 variableName = var->lexeme;
626 std::string to_string()
const override;
627 AST_NODE_METHODS(
"VariableExprAST", NodeKind::VariableExprAST)
629class DerefExprAST :
public ExprAST {
631 std::unique_ptr<ExprAST> operand;
632 explicit DerefExprAST(std::shared_ptr<Token> star_tok,
633 std::unique_ptr<ExprAST> operand)
634 : ExprAST(NodeKind::DerefExprAST), operand(std::move(operand)) {
635 this->join_location(star_tok)->join_location(this->operand.get());
637 std::string to_string()
const override;
638 AST_NODE_METHODS(
"DerefExprAST", NodeKind::DerefExprAST)
641class AddrOfExprAST :
public ExprAST {
643 std::unique_ptr<ExprAST> operand;
644 explicit AddrOfExprAST(std::shared_ptr<Token> amp_tok,
645 std::unique_ptr<ExprAST> operand)
646 : ExprAST(NodeKind::AddrOfExprAST), operand(std::move(operand)) {
647 this->join_location(amp_tok)->join_location(this->operand.get());
649 std::string to_string()
const override;
650 AST_NODE_METHODS(
"AddrOfExprAST", NodeKind::AddrOfExprAST)
652class AllocExprAST :
public ExprAST {
654 std::unique_ptr<TypeExprAST> type_arg;
655 std::unique_ptr<ExprAST> operand;
656 explicit AllocExprAST(std::shared_ptr<Token> tok,
657 std::unique_ptr<TypeExprAST> type_arg,
658 std::unique_ptr<ExprAST> operand)
659 : ExprAST(NodeKind::AllocExprAST), type_arg(std::move(type_arg)),
660 operand(std::move(operand)) {
661 this->join_location(tok)->join_location(this->operand.get());
663 std::string to_string()
const override;
664 AST_NODE_METHODS(
"AllocExprAST", NodeKind::AllocExprAST)
667class FreeExprAST :
public ExprAST {
669 std::unique_ptr<ExprAST> operand;
670 explicit FreeExprAST(std::shared_ptr<Token> tok,
671 std::unique_ptr<ExprAST> operand)
672 : ExprAST(NodeKind::FreeExprAST), operand(std::move(operand)) {
673 this->join_location(tok)->join_location(this->operand.get());
675 std::string to_string()
const override;
676 AST_NODE_METHODS(
"FreeExprAST", NodeKind::FreeExprAST)
678class ArrayLiteralExprAST :
public ExprAST {
680 std::vector<std::unique_ptr<ExprAST>> elements;
681 explicit ArrayLiteralExprAST(std::vector<std::unique_ptr<ExprAST>> elements)
682 : ExprAST(NodeKind::ArrayLiteralExprAST),
683 elements(std::move(elements)) {
684 for (
auto &e : this->elements)
686 this->join_location(e.get());
688 std::string to_string()
const override;
689 AST_NODE_METHODS(
"ArrayLiteralExprAST", NodeKind::ArrayLiteralExprAST)
692class IndexExprAST :
public ExprAST {
694 std::unique_ptr<ExprAST> array_expr;
695 std::unique_ptr<ExprAST> index_expr;
696 explicit IndexExprAST(std::unique_ptr<ExprAST> array_expr,
697 std::unique_ptr<ExprAST> index_expr)
698 : ExprAST(NodeKind::IndexExprAST), array_expr(std::move(array_expr)),
699 index_expr(std::move(index_expr)) {
700 this->join_location(this->array_expr.get())
701 ->join_location(this->index_expr.get());
703 std::string to_string()
const override;
704 AST_NODE_METHODS(
"IndexExprAST", NodeKind::IndexExprAST)
707class LenExprAST :
public ExprAST {
709 std::unique_ptr<ExprAST> operand;
710 explicit LenExprAST(std::shared_ptr<Token> tok,
711 std::unique_ptr<ExprAST> operand)
712 : ExprAST(NodeKind::LenExprAST), operand(std::move(operand)) {
713 this->join_location(tok)->join_location(this->operand.get());
715 std::string to_string()
const override;
716 AST_NODE_METHODS(
"LenExprAST", NodeKind::LenExprAST)
719class UnaryNegExprAST :
public ExprAST {
721 std::unique_ptr<ExprAST> operand;
722 explicit UnaryNegExprAST(std::shared_ptr<Token> op_tok,
723 std::unique_ptr<ExprAST> operand)
724 : ExprAST(NodeKind::UnaryNegExprAST), operand(std::move(operand)) {
725 this->join_location(op_tok)->join_location(this->operand.get());
727 std::string to_string()
const override;
728 AST_NODE_METHODS(
"UnaryNegExprAST", NodeKind::UnaryNegExprAST)
731class StructLiteralExprAST :
public ExprAST {
734 std::vector<std::string> field_names;
735 std::vector<std::unique_ptr<ExprAST>> field_values;
736 explicit StructLiteralExprAST(
737 std::shared_ptr<Token> name_tok,
738 std::vector<std::string> field_names,
739 std::vector<std::unique_ptr<ExprAST>> field_values)
740 : ExprAST(NodeKind::StructLiteralExprAST),
741 struct_name(sammine_util::QualifiedName::local(
742 name_tok ? name_tok->lexeme :
"")),
743 field_names(std::move(field_names)),
744 field_values(std::move(field_values)) {
745 this->join_location(name_tok);
746 for (
auto &v : this->field_values)
748 this->join_location(v.get());
750 explicit StructLiteralExprAST(
752 std::vector<std::string> field_names,
753 std::vector<std::unique_ptr<ExprAST>> field_values)
754 : ExprAST(NodeKind::StructLiteralExprAST),
755 struct_name(std::move(qn)),
756 field_names(std::move(field_names)),
757 field_values(std::move(field_values)) {
758 this->location = loc;
759 for (
auto &v : this->field_values)
761 this->join_location(v.get());
763 std::string to_string()
const override;
764 AST_NODE_METHODS(
"StructLiteralExprAST", NodeKind::StructLiteralExprAST)
767class FieldAccessExprAST :
public ExprAST {
769 std::unique_ptr<ExprAST> object_expr;
770 std::string field_name;
771 explicit FieldAccessExprAST(std::unique_ptr<ExprAST> object_expr,
772 std::shared_ptr<Token> field_tok)
773 : ExprAST(NodeKind::FieldAccessExprAST),
774 object_expr(std::move(object_expr)) {
775 this->join_location(this->object_expr.get());
776 this->join_location(field_tok);
778 this->field_name = field_tok->lexeme;
780 std::string to_string()
const override;
781 AST_NODE_METHODS(
"FieldAccessExprAST", NodeKind::FieldAccessExprAST)
798class CaseExprAST :
public ExprAST {
800 std::unique_ptr<ExprAST> scrutinee;
801 std::vector<CaseArm> arms;
803 explicit CaseExprAST(std::shared_ptr<Token> case_tok,
804 std::unique_ptr<ExprAST> scrutinee,
805 std::vector<CaseArm> arms)
806 : ExprAST(NodeKind::CaseExprAST), scrutinee(std::move(scrutinee)),
807 arms(std::move(arms)) {
808 this->join_location(case_tok)->join_location(this->scrutinee.get());
809 for (
auto &arm : this->arms) {
811 this->join_location(arm.body.get());
815 std::string to_string()
const override;
816 AST_NODE_METHODS(
"CaseExprAST", NodeKind::CaseExprAST)
819class WhileExprAST :
public ExprAST {
821 std::unique_ptr<ExprAST> condition;
822 std::unique_ptr<BlockAST> body;
823 explicit WhileExprAST(std::unique_ptr<ExprAST> condition,
824 std::unique_ptr<BlockAST> body)
825 : ExprAST(NodeKind::WhileExprAST), condition(std::move(condition)),
826 body(std::move(body)) {
827 this->join_location(this->condition.get())
828 ->join_location(this->body.get());
830 std::string to_string()
const override;
831 AST_NODE_METHODS(
"WhileExprAST", NodeKind::WhileExprAST)
834class TupleLiteralExprAST :
public ExprAST {
836 std::vector<std::unique_ptr<ExprAST>> elements;
837 explicit TupleLiteralExprAST(std::vector<std::unique_ptr<ExprAST>> elements)
838 : ExprAST(NodeKind::TupleLiteralExprAST),
839 elements(std::move(elements)) {
840 for (
auto &e : this->elements)
842 this->join_location(e.get());
844 std::string to_string()
const override;
845 AST_NODE_METHODS(
"TupleLiteralExprAST", NodeKind::TupleLiteralExprAST)
848class TypeClassDeclAST :
public DefinitionAST {
850 std::string class_name;
851 std::string type_param;
852 std::vector<std::unique_ptr<PrototypeAST>> methods;
853 explicit TypeClassDeclAST(std::shared_ptr<Token> tok, std::string name,
855 std::vector<std::unique_ptr<PrototypeAST>> methods)
856 : DefinitionAST(NodeKind::TypeClassDeclAST),
857 class_name(std::move(name)), type_param(std::move(param)),
858 methods(std::move(methods)) {
859 this->join_location(tok);
861 AST_NODE_METHODS(
"TypeClassDeclAST", NodeKind::TypeClassDeclAST)
864class TypeClassInstanceAST :
public DefinitionAST {
866 std::string class_name;
867 std::unique_ptr<TypeExprAST> concrete_type_expr;
868 std::vector<std::unique_ptr<FuncDefAST>> methods;
869 explicit TypeClassInstanceAST(
870 std::shared_ptr<Token> tok, std::string class_name,
871 std::unique_ptr<TypeExprAST> type_expr,
872 std::vector<std::unique_ptr<FuncDefAST>> methods)
873 : DefinitionAST(NodeKind::TypeClassInstanceAST),
874 class_name(std::move(class_name)),
875 concrete_type_expr(std::move(type_expr)),
876 methods(std::move(methods)) {
877 this->join_location(tok);
879 AST_NODE_METHODS(
"TypeClassInstanceAST", NodeKind::TypeClassInstanceAST)