Skip to content

Commit f295b39

Browse files
committed
Start to vove the type checker out of the parser
This is needed to check the instantiation of templates.
1 parent 7da1bfd commit f295b39

File tree

6 files changed

+1007
-801
lines changed

6 files changed

+1007
-801
lines changed

packages/cxx-gen-ast/src/gen_ast_h.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,18 @@ private:
228228
ASTKind kind_;
229229
};
230230
231+
template <typename T>
232+
auto make_node(Arena* arena) -> T* {
233+
auto node = new (arena) T();
234+
return node;
235+
}
236+
237+
template <typename T>
238+
auto make_list_node(Arena* arena, T* element = nullptr) -> List<T*>* {
239+
auto list = new (arena) List<T*>(element);
240+
return list;
241+
}
242+
231243
[[nodiscard]] inline auto firstSourceLocation(SourceLocation loc) -> SourceLocation { return loc; }
232244
233245
template <typename T>

src/parser/cxx/ast.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,18 @@ class AST : public Managed {
108108
ASTKind kind_;
109109
};
110110

111+
template <typename T>
112+
auto make_node(Arena* arena) -> T* {
113+
auto node = new (arena) T();
114+
return node;
115+
}
116+
117+
template <typename T>
118+
auto make_list_node(Arena* arena, T* element = nullptr) -> List<T*>* {
119+
auto list = new (arena) List<T*>(element);
120+
return list;
121+
}
122+
111123
[[nodiscard]] inline auto firstSourceLocation(SourceLocation loc)
112124
-> SourceLocation {
113125
return loc;

0 commit comments

Comments
 (0)