-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathVal.h
More file actions
87 lines (54 loc) · 1.36 KB
/
Val.h
File metadata and controls
87 lines (54 loc) · 1.36 KB
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
//
// Created by anirudhlath on 3/1/22.
//
#ifndef MSDSCRIPT_VAL_H
#define MSDSCRIPT_VAL_H
#include <string>
#include "pointer.h"
#include "Env.h"
class Expr;
CLASS(Val) {
public:
virtual PTR(Expr)to_expr() = 0;
virtual bool equals(PTR(Val)rhs) = 0;
virtual PTR(Val)add_to(PTR(Val)rhs) = 0;
virtual PTR(Val)mult_to(PTR(Val)rhs) = 0;
virtual std::string to_string() = 0;
virtual PTR(Val)call(PTR(Val)actual_arg) = 0;
};
class NumVal : public Val {
int num;
public:
NumVal(int num);
PTR(Expr)to_expr();
bool equals(PTR(Val)rhs);
PTR(Val)add_to(PTR(Val)rhs);
PTR(Val)mult_to(PTR(Val)rhs);
std::string to_string();
PTR(Val)call(PTR(Val)actual_arg);
};
class BoolVal : public Val {
bool boolean;
public:
BoolVal(bool boolean);
PTR(Expr)to_expr();
bool equals(PTR(Val)rhs);
PTR(Val)add_to(PTR(Val)rhs);
PTR(Val)mult_to(PTR(Val)rhs);
std::string to_string();
PTR(Val)call(PTR(Val)actual_arg);
};
class FunVal : public Val {
std::string formal_arg;
PTR(Expr)body;
PTR(Env)env;
public:
FunVal(std::string formal_arg, PTR(Expr)body, PTR(Env)env);
PTR(Expr)to_expr();
bool equals(PTR(Val)rhs);
PTR(Val)add_to(PTR(Val)rhs);
PTR(Val)mult_to(PTR(Val)rhs);
std::string to_string();
PTR(Val)call(PTR(Val)actual_arg);
};
#endif //MSDSCRIPT_VAL_H