-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathTerm.cpp
More file actions
62 lines (50 loc) · 1.3 KB
/
Copy pathTerm.cpp
File metadata and controls
62 lines (50 loc) · 1.3 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
#include <Term.h>
#include <util.h>
Term::Term() : type(NOOP) {}
Term::Term(const Endianness endianness) : type(SET_ENDIANNESS) {
value.as_endianness = endianness;
}
Term::Term(const Signedness signedness) : type(SET_SIGNEDNESS) {
value.as_signedness = signedness;
}
Term::Term(const Width width) : type(SET_WIDTH) {
value.as_width = width;
}
Term::Term(const Format format) : type(SET_FORMAT) {
value.as_format = format;
}
Term::Term(const Type type, const void* const source = 0) : type(type) {
switch (type) {
case NOOP:
break;
case PUSH:
case POP:
break;
case WRITE_SIGNED:
value.as_signed = *static_cast<const Signed*>(source);
break;
case WRITE_UNSIGNED:
value.as_unsigned = *static_cast<const Unsigned*>(source);
break;
case WRITE_DOUBLE:
value.as_double = *static_cast<const Double*>(source);
break;
default:
IMPOSSIBLE("invalid Term type");
}
}
Term Term::push() {
return Term(PUSH);
}
Term Term::pop() {
return Term(POP);
}
Term Term::write(const uint64_t value) {
return Term(WRITE_UNSIGNED, static_cast<const void*>(&value));
}
Term Term::write(const int64_t value) {
return Term(WRITE_SIGNED, static_cast<const void*>(&value));
}
Term Term::write(const double value) {
return Term(WRITE_DOUBLE, static_cast<const void*>(&value));
}