Commit f2365ec7 authored by Marius Wachtler's avatar Marius Wachtler

AST & BST: make enums smaller

parent 9ef680bb
...@@ -65,7 +65,7 @@ public: ...@@ -65,7 +65,7 @@ public:
// import dis // import dis
// print dis.dis(g) // print dis.dis(g)
enum class VarScopeType { enum class VarScopeType : unsigned char {
FAST, FAST,
GLOBAL, GLOBAL,
CLOSURE, CLOSURE,
......
...@@ -146,7 +146,7 @@ namespace AST_TYPE { ...@@ -146,7 +146,7 @@ namespace AST_TYPE {
#define GENERATE_ENUM(ENUM, N) ENUM = N, #define GENERATE_ENUM(ENUM, N) ENUM = N,
#define GENERATE_STRING(STRING, N) m[N] = #STRING; #define GENERATE_STRING(STRING, N) m[N] = #STRING;
enum AST_TYPE { FOREACH_TYPE(GENERATE_ENUM) }; enum AST_TYPE : unsigned char { FOREACH_TYPE(GENERATE_ENUM) };
static const char* stringify(int n) { static const char* stringify(int n) {
static std::map<int, const char*> m; static std::map<int, const char*> m;
...@@ -730,7 +730,7 @@ public: ...@@ -730,7 +730,7 @@ public:
class AST_Num : public AST_expr { class AST_Num : public AST_expr {
public: public:
enum NumType { enum NumType : unsigned char {
// These values must correspond to the values in parse_ast.py // These values must correspond to the values in parse_ast.py
INT = 0x10, INT = 0x10,
FLOAT = 0x20, FLOAT = 0x20,
...@@ -852,7 +852,7 @@ public: ...@@ -852,7 +852,7 @@ public:
class AST_Str : public AST_expr { class AST_Str : public AST_expr {
public: public:
enum StrType { enum StrType : unsigned char {
UNSET = 0x00, UNSET = 0x00,
STR = 0x10, STR = 0x10,
UNICODE = 0x20, UNICODE = 0x20,
...@@ -1007,7 +1007,7 @@ public: ...@@ -1007,7 +1007,7 @@ public:
// These are basically bytecodes, framed as pseudo-AST-nodes. // These are basically bytecodes, framed as pseudo-AST-nodes.
class AST_LangPrimitive : public AST_expr { class AST_LangPrimitive : public AST_expr {
public: public:
enum Opcodes { enum Opcodes : unsigned char {
LANDINGPAD, // grabs the info about the last raised exception LANDINGPAD, // grabs the info about the last raised exception
LOCALS, LOCALS,
GET_ITER, GET_ITER,
......
...@@ -147,7 +147,7 @@ namespace BST_TYPE { ...@@ -147,7 +147,7 @@ namespace BST_TYPE {
#define GENERATE_ENUM(ENUM, N) ENUM = N, #define GENERATE_ENUM(ENUM, N) ENUM = N,
#define GENERATE_STRING(STRING, N) m[N] = #STRING; #define GENERATE_STRING(STRING, N) m[N] = #STRING;
enum BST_TYPE { FOREACH_TYPE(GENERATE_ENUM) }; enum BST_TYPE : unsigned char { FOREACH_TYPE(GENERATE_ENUM) };
static const char* stringify(int n) { static const char* stringify(int n) {
static std::map<int, const char*> m; static std::map<int, const char*> m;
...@@ -758,7 +758,7 @@ public: ...@@ -758,7 +758,7 @@ public:
// These are basically bytecodes, framed as pseudo-BST-nodes. // These are basically bytecodes, framed as pseudo-BST-nodes.
class BST_LangPrimitive : public BST_expr { class BST_LangPrimitive : public BST_expr {
public: public:
enum Opcodes { enum Opcodes : unsigned char {
LANDINGPAD, // grabs the info about the last raised exception LANDINGPAD, // grabs the info about the last raised exception
LOCALS, LOCALS,
GET_ITER, GET_ITER,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment