source: translator/SynTree/CodeGenVisitor.cc @ c8ffe20b

ADTaaron-thesisarm-ehast-experimentalcleanup-dtorsctordeferred_resndemanglerenumforall-pointer-decaygc_noraiijacob/cs343-translationjenkins-sandboxmemorynew-astnew-ast-unique-exprnew-envno_listpersistent-indexerpthread-emulationqualifiedEnumresolv-newstringwith_gc
Last change on this file since c8ffe20b was 51b7345, checked in by Peter A. Buhr <pabuhr@…>, 10 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.