Skip to content

Commit 275f945

Browse files
committed
Dump the value category and the expression type
Signed-off-by: Roberto Raggi <[email protected]>
1 parent c7fe1fb commit 275f945

34 files changed

+509
-202
lines changed

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

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,15 @@ export function gen_ast_dump_cc({ ast, output }: { ast: AST; output: string }) {
105105
nodes.forEach(({ name, base, members }) => {
106106
emit();
107107
emit(`void ASTPrinter::visit(${name}* ast) {`);
108-
emit(` out_ << std::format("{}\\n", "${astName(name)}");`);
108+
if (base == "ExpressionAST") {
109+
emit(` out_ << "${astName(name)}";`);
110+
emit(` if (ast->type) {`);
111+
emit(` out_ << std::format(" [{} {}]", to_string(ast->valueCategory), to_string(ast->type));`);
112+
emit(` }`);
113+
emit(` out_ << "\\n";`);
114+
} else {
115+
emit(` out_ << std::format("{}\\n", "${astName(name)}");`);
116+
}
109117

110118
const baseMembers = ast.baseMembers.get(base);
111119

0 commit comments

Comments
 (0)