summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--script-beta/config.lua1
-rw-r--r--script-beta/files.lua8
-rw-r--r--script-beta/parser/compile.lua10
-rw-r--r--script/config.lua1
4 files changed, 17 insertions, 3 deletions
diff --git a/script-beta/config.lua b/script-beta/config.lua
index f5869ce1..bc6bf863 100644
--- a/script-beta/config.lua
+++ b/script-beta/config.lua
@@ -102,6 +102,7 @@ local ConfigTemplate = {
"?/init.lua",
"?/?.lua"
}, Array(String)},
+ special = {{}, Hash(String, String)},
},
diagnostics = {
enable = {true, Boolean},
diff --git a/script-beta/files.lua b/script-beta/files.lua
index 8451b4f1..9e72ddd8 100644
--- a/script-beta/files.lua
+++ b/script-beta/files.lua
@@ -219,7 +219,13 @@ function m.getAst(uri)
end
if file.ast == nil then
local clock = os.clock()
- local state, err = parser:compile(file.text, 'lua', config.config.runtime.version)
+ local state, err = parser:compile(file.text
+ , 'lua'
+ , config.config.runtime.version
+ , {
+ special = config.config.runtime.special,
+ }
+ )
local passed = os.clock() - clock
if passed > 0.1 then
log.warn(('Compile [%s] takes [%.3f] sec, size [%.3f] kb.'):format(uri, passed, #file.text / 1000))
diff --git a/script-beta/parser/compile.lua b/script-beta/parser/compile.lua
index 50c558fc..4d765262 100644
--- a/script-beta/parser/compile.lua
+++ b/script-beta/parser/compile.lua
@@ -16,7 +16,7 @@ local specials = {
_ENV = nil
local LocalLimit = 200
-local pushError, Compile, CompileBlock, Block, GoToTag, ENVMode, Compiled, LocalCount, Version, Root
+local pushError, Compile, CompileBlock, Block, GoToTag, ENVMode, Compiled, LocalCount, Version, Root, Options
local function addRef(node, obj)
if not node.ref then
@@ -56,6 +56,11 @@ local vmMap = {
local name = obj[1]
if specials[name] then
addSpecial(name, obj)
+ elseif Options and Options.special then
+ local asName = Options.special[name]
+ if specials[asName] then
+ addSpecial(asName, obj)
+ end
end
end
return obj
@@ -518,7 +523,7 @@ local function PostCompile()
end
end
-return function (self, lua, mode, version)
+return function (self, lua, mode, version, options)
local state, err = self:parse(lua, mode, version)
if not state then
return nil, err
@@ -534,6 +539,7 @@ return function (self, lua, mode, version)
LocalCount = 0
Version = version
Root = state.ast
+ Options = options
state.ENVMode = ENVMode
if type(state.ast) == 'table' then
Compile(state.ast)
diff --git a/script/config.lua b/script/config.lua
index 479ca6ab..d1a65605 100644
--- a/script/config.lua
+++ b/script/config.lua
@@ -98,6 +98,7 @@ local ConfigTemplate = {
"?/init.lua",
"?/?.lua"
}, Array(String)},
+ special = {{}, Hash(String, String)},
},
diagnostics = {
enable = {true, Boolean},