 Chromium Code Reviews
 Chromium Code Reviews Issue 2771803005:
  Hide WasmModule.origin field behind readable accessors.  (Closed)
    
  
    Issue 2771803005:
  Hide WasmModule.origin field behind readable accessors.  (Closed) 
  | Index: src/wasm/wasm-module.h | 
| diff --git a/src/wasm/wasm-module.h b/src/wasm/wasm-module.h | 
| index bfedbff61fb720e5c66da75fa5ed300544e19a63..28436beaad6c6494b53829d08d80af5e549e0ca4 100644 | 
| --- a/src/wasm/wasm-module.h | 
| +++ b/src/wasm/wasm-module.h | 
| @@ -154,7 +154,6 @@ struct V8_EXPORT_PRIVATE WasmModule { | 
| // the fact that we index on uint32_t, so we may technically not be | 
| // able to represent some start_function_index -es. | 
| int start_function_index = -1; // start function, if any | 
| - ModuleOrigin origin = kWasmOrigin; // origin of the module | 
| std::vector<WasmGlobal> globals; // globals in this module. | 
| uint32_t globals_size = 0; // size of globals table. | 
| @@ -182,6 +181,15 @@ struct V8_EXPORT_PRIVATE WasmModule { | 
| ~WasmModule() { | 
| if (owned_zone) delete owned_zone; | 
| } | 
| + | 
| + ModuleOrigin get_origin() const { return origin; } | 
| + void set_origin(ModuleOrigin new_value) { origin = new_value; } | 
| + bool is_wasm() const { return origin == kWasmOrigin; } | 
| + bool is_asm_js() const { return origin == kAsmJsOrigin; } | 
| + | 
| + private: | 
| + // TODO(kschimpf) - Encapsulate more fields. | 
| + ModuleOrigin origin = kWasmOrigin; // origin of the module | 
| 
Mircea Trofin
2017/03/24 22:25:14
the naming style in V8 for fields would be "origin
 
Karl
2017/03/24 22:41:40
I'm a bit nervous about changing the field name fr
 | 
| }; | 
| typedef Managed<WasmModule> WasmModuleWrapper; | 
| @@ -318,7 +326,7 @@ struct V8_EXPORT_PRIVATE ModuleEnv { | 
| return &module->function_tables[index]; | 
| } | 
| - bool asm_js() { return module->origin == kAsmJsOrigin; } | 
| + bool asm_js() { return module->is_asm_js(); } | 
| // Only used for testing. | 
| Handle<Code> GetFunctionCode(uint32_t index) { |