-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconstant.h
More file actions
39 lines (30 loc) · 768 Bytes
/
constant.h
File metadata and controls
39 lines (30 loc) · 768 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#ifndef __constant_h__
#define __constant_h__
#include "expr.h"
#include "word.h"
#include <string>
#include "num.h"
class Type;
class Token;
class Constant : public Expr{
public:
Constant(Token *tok, Type *p)
: Expr(tok,p)
{
};
Constant(int i)
: Expr(new Num(i) ,Type::Int())
{
};
~Constant(){
};
static const Constant *True , *False;
void jumping(int t , int f)
{
if(this == Constant::True && t != 0) emit("goto L" + std::to_string(t));
else if(this == Constant::False && f != 0) emit("goto L" + std::to_string(f));
}
};
const Constant* Constant::True = new Constant(Word::word(TRUE),Type::Bool());
const Constant* Constant::False = new Constant(Word::word(FALSE),Type::Bool());
#endif