11#ifndef bytecode_compiler_H
22#define bytecode_compiler_H
33
4+ #include < variant>
45#include < clasp/core/common.h>
56#include < clasp/core/compPackage.fwd.h>
67
@@ -54,6 +55,14 @@ class LexicalVarInfo_O : public VarInfo_O {
5455 }
5556};
5657
58+ struct LexicalVarInfoV {
59+ LexicalVarInfoV (LexicalVarInfo_sp info) : _info(info) {};
60+ // Because we mutate infos, and store them in lexenvs, we have to
61+ // allocate them. This wrapper is just for var_info_v purposes.
62+ LexicalVarInfo_sp _info;
63+ LexicalVarInfo_sp info () const { return _info; }
64+ };
65+
5766FORWARD (SpecialVarInfo);
5867class SpecialVarInfo_O : public VarInfo_O {
5968 LISP_CLASS (comp, CompPkg, SpecialVarInfo_O, " SpecialVarInfo" , VarInfo_O);
@@ -74,6 +83,13 @@ class SpecialVarInfo_O : public VarInfo_O {
7483 CL_DEFMETHOD bool globalp () const { return this ->_globalp ; }
7584};
7685
86+ struct SpecialVarInfoV {
87+ SpecialVarInfoV (bool globalp) : _globalp(globalp) {};
88+ SpecialVarInfoV (SpecialVarInfo_sp info) : _globalp(info->globalp ()) {};
89+ bool _globalp;
90+ bool globalp () const { return _globalp; }
91+ };
92+
7793FORWARD (SymbolMacroVarInfo);
7894class SymbolMacroVarInfo_O : public VarInfo_O {
7995 LISP_CLASS (comp, CompPkg, SymbolMacroVarInfo_O, " SymbolMacroVarInfo" , VarInfo_O);
@@ -91,6 +107,13 @@ class SymbolMacroVarInfo_O : public VarInfo_O {
91107 CL_DEFMETHOD Function_sp expander () const { return this ->_expander ; }
92108};
93109
110+ struct SymbolMacroVarInfoV {
111+ SymbolMacroVarInfoV (Function_sp expander) : _expander(expander) {};
112+ SymbolMacroVarInfoV (SymbolMacroVarInfo_sp info) : _expander(info->expander ()) {};
113+ Function_sp _expander;
114+ Function_sp expander () const { return _expander; }
115+ };
116+
94117FORWARD (ConstantVarInfo);
95118class ConstantVarInfo_O : public VarInfo_O {
96119 LISP_CLASS (comp, CompPkg, ConstantVarInfo_O, " ConstantVarInfo" , VarInfo_O);
@@ -107,6 +130,19 @@ class ConstantVarInfo_O : public VarInfo_O {
107130 CL_DEFMETHOD T_sp value () const { return this ->_value ; }
108131};
109132
133+ struct ConstantVarInfoV {
134+ ConstantVarInfoV (T_sp value) : _value(value) {};
135+ ConstantVarInfoV (ConstantVarInfo_sp info) : _value(info->value ()) {};
136+ T_sp _value;
137+ T_sp value () const { return _value; }
138+ };
139+
140+ // non-heaped infos, to avoid consing. see var_info_v.
141+ // We use this thing instead of monostate for clarity.
142+ struct NoVarInfoV {};
143+
144+ typedef std::variant<NoVarInfoV, LexicalVarInfoV, SpecialVarInfoV, SymbolMacroVarInfoV, ConstantVarInfoV> VarInfoV;
145+
110146FORWARD (FunInfo);
111147class FunInfo_O : public General_O {
112148 LISP_ABSTRACT_CLASS (comp, CompPkg, FunInfo_O, " FunInfo" , General_O);
@@ -131,6 +167,13 @@ class GlobalFunInfo_O : public FunInfo_O {
131167 CL_DEFMETHOD T_sp cmexpander () const { return this ->_cmexpander ; }
132168};
133169
170+ struct GlobalFunInfoV {
171+ GlobalFunInfoV (T_sp cmexpander) : _cmexpander(cmexpander) {};
172+ GlobalFunInfoV (GlobalFunInfo_sp info) : _cmexpander(info->cmexpander ()) {};
173+ T_sp _cmexpander;
174+ T_sp cmexpander () const { return _cmexpander; }
175+ };
176+
134177FORWARD (LocalFunInfo);
135178class LocalFunInfo_O : public FunInfo_O {
136179 LISP_CLASS (comp, CompPkg, LocalFunInfo_O, " LocalFunInfo" , FunInfo_O);
@@ -147,6 +190,12 @@ class LocalFunInfo_O : public FunInfo_O {
147190 CL_DEFMETHOD T_sp funVar () const { return this ->fun_var ; }
148191};
149192
193+ struct LocalFunInfoV {
194+ LocalFunInfoV (LocalFunInfo_sp info) : _info(info) {};
195+ LocalFunInfo_sp _info;
196+ LocalFunInfo_sp info () const { return _info; }
197+ };
198+
150199// We have separate global and local macro classes because it is sometimes
151200// important to know that a binding is local - for example, a local binding
152201// shadows a global setf expander.
@@ -167,6 +216,13 @@ class GlobalMacroInfo_O : public FunInfo_O {
167216 CL_DEFMETHOD Function_sp expander () const { return this ->_expander ; }
168217};
169218
219+ struct GlobalMacroInfoV {
220+ GlobalMacroInfoV (Function_sp expander) : _expander(expander) {};
221+ GlobalMacroInfoV (GlobalMacroInfo_sp info) : _expander(info->expander ()) {};
222+ Function_sp _expander;
223+ Function_sp expander () const { return _expander; }
224+ };
225+
170226FORWARD (LocalMacroInfo);
171227class LocalMacroInfo_O : public FunInfo_O {
172228 LISP_CLASS (comp, CompPkg, LocalMacroInfo_O, " LocalMacroInfo" , FunInfo_O);
@@ -183,6 +239,17 @@ class LocalMacroInfo_O : public FunInfo_O {
183239 CL_DEFMETHOD Function_sp expander () const { return this ->_expander ; }
184240};
185241
242+ struct LocalMacroInfoV {
243+ LocalMacroInfoV (Function_sp expander) : _expander(expander) {};
244+ LocalMacroInfoV (LocalMacroInfo_sp info) : _expander(info->expander ()) {};
245+ Function_sp _expander;
246+ Function_sp expander () const { return _expander; }
247+ };
248+
249+ struct NoFunInfoV {};
250+
251+ typedef std::variant<NoFunInfoV, GlobalFunInfoV, LocalFunInfoV, GlobalMacroInfoV, LocalMacroInfoV> FunInfoV;
252+
186253FORWARD (Lexenv);
187254class Context ; // forward decl
188255class Lexenv_O : public General_O {
0 commit comments