source: translator/SynTree/CodeGenVisitor.cc@ 643a2e1

ADT aaron-thesis arm-eh ast-experimental cleanup-dtors ctor deferred_resn demangler enum forall-pointer-decay gc_noraii jacob/cs343-translation jenkins-sandbox memory new-ast new-ast-unique-expr new-env no_list persistent-indexer pthread-emulation qualifiedEnum resolv-new string with_gc
Last change on this file since 643a2e1 was 51b73452, checked in by Peter A. Buhr <pabuhr@…>, 11 years ago

initial commit

  • Property mode set to 100644
File size: 1.0 KB
Line 
1#include <iostream>
2#include <list>
3
4#include "Statement.h"
5#include "Expression.h"
6#include "CodeGenVisitor.h"
7using namespace std;
8
9//*** Types
10void CodeGenVisitor::visit(Type *type){ }
11void CodeGenVisitor::visit(BasicType *basicType) { }
12
13//*** Constant
14void CodeGenVisitor::visit(Constant *constant) {
15 cout << constant->get_value() << endl;
16}
17
18//*** Expressions
19void CodeGenVisitor::visit(Expression *expr){ }
20
21void CodeGenVisitor::visit(ConstantExpr *cnst){
22 if(cnst != 0)
23 visit(cnst->get_constant());
24}
25
26//*** Statements
27void CodeGenVisitor::visit(Statement *stmt){ }
28
29void CodeGenVisitor::visit(ExprStmt *exprStmt){
30 if(exprStmt != 0)
31 exprStmt->get_expr()->accept(*this); // visit(exprStmt->get_expr()) doesn't work
32}
33
34void CodeGenVisitor::visit(SwitchStmt *switchStmt){
35 cout << "switch(" << endl;
36 // visit(switchStmt->get_condition()); // why doesn't this work?
37 switchStmt->get_condition()->accept(*this);
38
39 cout << ") {" << endl;
40 // visit(switchStmt->get_body()); // why doesn't this work?
41 cout << "}" << endl;
42}
43
44
Note: See TracBrowser for help on using the repository browser.