首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >LUA - ZeroBrane IDE:编译特性

LUA - ZeroBrane IDE:编译特性
EN

Stack Overflow用户
提问于 2020-09-09 09:28:01
回答 1查看 221关注 0票数 0

在ZeroBrane Studio中,如果我使用“(F7)”--到底会发生什么?

会有一个独立的.exe由我的Lua代码创建吗?

如果是的话-在哪个目录?我使用Windows 10。(在文档中找不到任何信息)

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2020-09-09 16:26:34

从我对源代码的快速查看中可以看出,它只是通过使用编译文件的loadstring加载代码来检查代码是否有错误。没有输出文件,只有一些关于任何错误的文本输出。

但这只是一个假设。单击该按钮时,请随意检查这是否是调用的函数。

https://github.com/pkulchenko/ZeroBraneStudio/blob/5daf55d79449431ca9794f6b8a65476dc203b780/src/editor

代码语言:javascript
复制
function CompileProgram(editor, params)
  local params = {
    jumponerror = (params or {}).jumponerror ~= false,
    reportstats = (params or {}).reportstats ~= false,
    keepoutput = (params or {}).keepoutput,
  }
  local doc = ide:GetDocument(editor)
  local filePath = doc:GetFilePath() or doc:GetFileName()
  local loadstring = loadstring or load
  local func, err = loadstring(StripShebang(editor:GetTextDyn()), '@'..filePath)
  local line = not func and tonumber(err:match(":(%d+)%s*:")) or nil

  if not params.keepoutput then ClearOutput() end

  compileTotal = compileTotal + 1
  if func then
    compileOk = compileOk + 1
    if params.reportstats then
      ide:Print(TR("Compilation successful; %.0f%% success rate (%d/%d).")
        :format(compileOk/compileTotal*100, compileOk, compileTotal))
    end
  else
    ide:GetOutput():Activate()
    ide:Print(TR("Compilation error").." "..TR("on line %d"):format(line)..":")
    ide:Print((err:gsub("\n$", "")))
    -- check for escapes invalid in LuaJIT/Lua 5.2 that are allowed in Lua 5.1
    if err:find('invalid escape sequence') then
      local s = editor:GetLineDyn(line-1)
      local cleaned = s
        :gsub('\\[abfnrtv\\"\']', '  ')
        :gsub('(\\x[0-9a-fA-F][0-9a-fA-F])', function(s) return string.rep(' ', #s) end)
        :gsub('(\\%d%d?%d?)', function(s) return string.rep(' ', #s) end)
        :gsub('(\\z%s*)', function(s) return string.rep(' ', #s) end)
      local invalid = cleaned:find("\\")
      if invalid then
        ide:Print(TR("Consider removing backslash from escape sequence '%s'.")
          :format(s:sub(invalid,invalid+1)))
      end
    end
    if line and params.jumponerror and line-1 ~= editor:GetCurrentLine() then
      editor:GotoLine(line-1)
    end
  end

  return func ~= nil -- return true if it compiled ok
end
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/63808715

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档