Skip to content

Commit

Permalink
[mycpp] Fix build of osh_eval.cc
Browse files Browse the repository at this point in the history
- Fix initialization of managed vars
- Legacy code generation with GLOBAL_LIST(...)
  • Loading branch information
Andy Chu committed Jan 7, 2021
1 parent f95a61c commit eb035e8
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
4 changes: 2 additions & 2 deletions mycpp/cppgen_pass.py
Expand Up @@ -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):
Expand Down
11 changes: 6 additions & 5 deletions mycpp/gc_heap.h
Expand Up @@ -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<T, N> and initializer
// lists like {1, 2, 3} to macros

#define COMMA ,

namespace gc_heap {

template <class T>
Expand Down Expand Up @@ -547,6 +552,7 @@ inline Slab<T>* NewSlab(int len) {

#ifdef MYLIB_LEGACY
#define GLOBAL_STR(name, val) Str* name = new Str(val);
#define GLOBAL_LIST(T, N, name, array) List<T>* name = new List<T>(array);
#endif

#ifndef MYLIB_LEGACY
Expand Down Expand Up @@ -709,11 +715,6 @@ constexpr int maskbit(int offset) {
// List<T>
//

// Silly definition for passing types like GlobalList<T, N> 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.
Expand Down

0 comments on commit eb035e8

Please sign in to comment.