diff options
| author | Patrick Walton <pcwalton@mimiga.net> | 2011-08-24 15:18:57 -0700 |
|---|---|---|
| committer | Patrick Walton <pcwalton@mimiga.net> | 2011-08-24 15:19:59 -0700 |
| commit | 72d78e6a93829703f64bd59f502410bebe64ae91 (patch) | |
| tree | 8e06727a5acf867cc825dc2ddc144cd5fd041c81 /src/rt/rust_shape.cpp | |
| parent | 0dc1d7ee57bed7f0bd54e0369633fc09e200bbd6 (diff) | |
| download | rust-72d78e6a93829703f64bd59f502410bebe64ae91.tar.gz rust-72d78e6a93829703f64bd59f502410bebe64ae91.zip | |
rt: Factor out type param construction into from_tydesc and from_obj_shape. (The latter is unimplemented at the moment.)
Diffstat (limited to 'src/rt/rust_shape.cpp')
| -rw-r--r-- | src/rt/rust_shape.cpp | 36 |
1 files changed, 25 insertions, 11 deletions
diff --git a/src/rt/rust_shape.cpp b/src/rt/rust_shape.cpp index 3e1b64b3a2a..8e99c41ea02 100644 --- a/src/rt/rust_shape.cpp +++ b/src/rt/rust_shape.cpp @@ -17,23 +17,37 @@ namespace shape { using namespace shape; -// Forward declarations - -struct rust_obj; -struct size_align; -struct type_param; - - // Constants const uint8_t CMP_EQ = 0u; const uint8_t CMP_LT = 1u; const uint8_t CMP_LE = 2u; -} // end namespace shape +// Type parameters + +type_param * +type_param::make(const type_desc **tydescs, unsigned n_tydescs, + arena &arena) { + if (!n_tydescs) + return NULL; + + type_param *ptrs = arena.alloc<type_param>(n_tydescs); + for (uint32_t i = 0; i < n_tydescs; i++) { + const type_desc *subtydesc = tydescs[i]; + ptrs[i].shape = subtydesc->shape; + ptrs[i].tables = subtydesc->shape_tables; + ptrs[i].params = from_tydesc(subtydesc, arena); + } + return ptrs; +} + +type_param * +type_param::from_obj_shape(const uint8_t *sp, arena &arena) { + // TODO + abort(); +} -namespace shape { // A shape printer, useful for debugging @@ -469,7 +483,7 @@ upcall_cmp_type(int8_t *result, rust_task *task, type_desc *tydesc, const type_desc **subtydescs, uint8_t *data_0, uint8_t *data_1, uint8_t cmp_type) { shape::arena arena; - shape::type_param *params = shape::type_param::make(tydesc, arena); + shape::type_param *params = shape::type_param::from_tydesc(tydesc, arena); shape::cmp cmp(task, tydesc->shape, params, tydesc->shape_tables, data_0, data_1); cmp.walk(true); @@ -488,7 +502,7 @@ upcall_log_type(rust_task *task, type_desc *tydesc, uint8_t *data, return; // TODO: Don't evaluate at all? shape::arena arena; - shape::type_param *params = shape::type_param::make(tydesc, arena); + shape::type_param *params = shape::type_param::from_tydesc(tydesc, arena); std::stringstream ss; shape::log log(task, tydesc->shape, params, tydesc->shape_tables, data, |
