From eb035e811fdef255472e149aec3044ce1ff022df Mon Sep 17 00:00:00 2001 From: Andy Chu Date: Thu, 7 Jan 2021 10:45:53 -0800 Subject: [PATCH] [mycpp] Fix build of osh_eval.cc - Fix initialization of managed vars - Legacy code generation with GLOBAL_LIST(...) --- mycpp/cppgen_pass.py | 4 ++-- mycpp/gc_heap.h | 11 ++++++----- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/mycpp/cppgen_pass.py b/mycpp/cppgen_pass.py index 8c03a4797a..7b158a839e 100644 --- a/mycpp/cppgen_pass.py +++ b/mycpp/cppgen_pass.py @@ -123,8 +123,8 @@ def CTypeIsManaged(c_type): """Do we need to add it to StackRoots?""" assert c_type != 'void' - # TODO: What about function types? I don't think we're using those? - return c_type not in ('int', 'double', 'bool') + # int, double, bool, scope_t enums, etc. are not managed + return c_type.endswith('*') def get_c_type(t, param=False, local=False): diff --git a/mycpp/gc_heap.h b/mycpp/gc_heap.h index 41072445be..7624d523e1 100644 --- a/mycpp/gc_heap.h +++ b/mycpp/gc_heap.h @@ -70,6 +70,11 @@ const int FixedSize = 7; // Fixed size headers: consult field_mask_ const int Scanned = 9; // Copy AND scan for non-NULL pointers. } // namespace Tag +// Silly definition for passing types like GlobalList and initializer +// lists like {1, 2, 3} to macros + +#define COMMA , + namespace gc_heap { template @@ -547,6 +552,7 @@ inline Slab* NewSlab(int len) { #ifdef MYLIB_LEGACY #define GLOBAL_STR(name, val) Str* name = new Str(val); +#define GLOBAL_LIST(T, N, name, array) List* name = new List(array); #endif #ifndef MYLIB_LEGACY @@ -709,11 +715,6 @@ constexpr int maskbit(int offset) { // List // - // Silly definition for passing types like GlobalList and initializer - // lists like {1, 2, 3} to macros - -#define COMMA , - // Type that is layout-compatible with List (unit tests assert this). Two // purposes: // - To make globals of "plain old data" at compile-time, not at startup time.