-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathset.h
More file actions
36 lines (31 loc) · 667 Bytes
/
set.h
File metadata and controls
36 lines (31 loc) · 667 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
#ifndef __set_h__
#define __set_h__
#include "stmt.h"
#include "id.h"
#include "expr.h"
#include <string>
class Set : public Stmt{
public:
Id *id;
Expr *expr;
Set(Id *i , Expr *x)
{
id = i;
expr = x;
if( check(id->type,expr->type) == NULL)
{
error("type error");
}
};
Type *check(Type *p1 , Type *p2)
{
if(Type::numeric(p1) && Type::numeric(p2) ) return p2;
else if(p1 == Type::Bool() && p2 == Type::Bool()) return p2;
else return NULL;
};
void gen(int b ,int a)
{
emit(id->toString() + " = " + expr->gen()->toString());
};
};
#endif