|
38 | 38 | local function load_definitions(root_node, parent_config) |
39 | 39 | local path = "nattlua/definitions/index.nlua" |
40 | 40 | local config = {} |
| 41 | + |
41 | 42 | if parent_config then |
42 | 43 | for k, v in pairs(parent_config) do |
43 | 44 | config[k] = v |
44 | 45 | end |
45 | 46 | end |
| 47 | + |
46 | 48 | config.file_path = config.file_path or path |
47 | 49 | config.file_name = config.file_name or "@" .. path |
48 | 50 | config.root_directory = ROOT_PATH |
@@ -79,24 +81,25 @@ return { |
79 | 81 | local typesystem_env = Table() |
80 | 82 | typesystem_env.string_metatable = Table() |
81 | 83 | compiler:SetEnvironments(runtime_env, typesystem_env) |
82 | | - |
83 | 84 | -- Use parent analyzer's config if it exists or just use a fresh analyzer |
84 | 85 | local analyzer |
| 86 | + |
85 | 87 | if parent_analyzer then |
86 | 88 | analyzer = require("nattlua.analyzer.analyzer").New(parent_analyzer.config) |
87 | | - -- Ensure we're using a common statement count if we want to track it |
88 | | - -- but for base environment it might be noisy. Let's at least record parsed paths. |
| 89 | + -- Ensure we're using a common statement count if we want to track it |
| 90 | + -- but for base environment it might be noisy. Let's at least record parsed paths. |
89 | 91 | end |
90 | | - |
| 92 | + |
91 | 93 | assert(compiler:Analyze(analyzer)) |
92 | | - |
| 94 | + |
93 | 95 | if parent_analyzer then |
94 | 96 | for path, _ in pairs(compiler.analyzer.parsed_paths) do |
95 | 97 | parent_analyzer.parsed_paths[path] = true |
96 | 98 | end |
| 99 | + |
97 | 100 | parent_analyzer.statement_count = (parent_analyzer.statement_count or 0) + (compiler.analyzer.statement_count or 0) |
98 | 101 | end |
99 | | - |
| 102 | + |
100 | 103 | typesystem_env.string_metatable:Set( |
101 | 104 | LStringNoMeta("__index"), |
102 | 105 | assert(typesystem_env:Get(LStringNoMeta("string")), "failed to find string table") |
|
0 commit comments