1010#include " ByteCodeGenError.h"
1111#include " Context.h"
1212#include " Floating.h"
13+ #include " IntegralAP.h"
1314#include " Opcode.h"
1415#include " Program.h"
1516#include " clang/AST/ASTLambda.h"
@@ -209,9 +210,11 @@ static void emit(Program &P, std::vector<std::byte> &Code, const T &Val,
209210 }
210211}
211212
212- template <>
213- void emit (Program &P, std::vector<std::byte> &Code, const Floating &Val,
214- bool &Success) {
213+ // / Emits a serializable value. These usually (potentially) contain
214+ // / heap-allocated memory and aren't trivially copyable.
215+ template <typename T>
216+ static void emitSerialized (std::vector<std::byte> &Code, const T &Val,
217+ bool &Success) {
215218 size_t Size = Val.bytesToSerialize ();
216219
217220 if (Code.size () + Size > std::numeric_limits<unsigned >::max ()) {
@@ -228,6 +231,24 @@ void emit(Program &P, std::vector<std::byte> &Code, const Floating &Val,
228231 Val.serialize (Code.data () + ValPos);
229232}
230233
234+ template <>
235+ void emit (Program &P, std::vector<std::byte> &Code, const Floating &Val,
236+ bool &Success) {
237+ emitSerialized (Code, Val, Success);
238+ }
239+
240+ template <>
241+ void emit (Program &P, std::vector<std::byte> &Code,
242+ const IntegralAP<false > &Val, bool &Success) {
243+ emitSerialized (Code, Val, Success);
244+ }
245+
246+ template <>
247+ void emit (Program &P, std::vector<std::byte> &Code, const IntegralAP<true > &Val,
248+ bool &Success) {
249+ emitSerialized (Code, Val, Success);
250+ }
251+
231252template <typename ... Tys>
232253bool ByteCodeEmitter::emitOp (Opcode Op, const Tys &... Args, const SourceInfo &SI) {
233254 bool Success = true ;
0 commit comments