Skip to content

Commit

Permalink
move some sub projects around
Browse files Browse the repository at this point in the history
fix playground not working due to ffi dependency
  • Loading branch information
CapsAdmin committed Sep 25, 2024
1 parent 19fc6bb commit b76f6cd
Show file tree
Hide file tree
Showing 37 changed files with 33 additions and 33 deletions.
File renamed without changes.
2 changes: 1 addition & 1 deletion language_server/server/lsp.lua → language_server/lsp.lua
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
--DONT_ANALYZE
local b64 = require("nattlua.other.base64")
local EditorHelper = require("nattlua.editor_helper.editor")
local EditorHelper = require("language_server.editor_helper")
local formating = require("nattlua.other.formating")
local path = require("nattlua.other.path")
local lsp = {}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
-- Redirect print function to stderr for debug output
local ffi = require("ffi")
local lsp = require("language_server.server.lsp")
local lsp = require("language_server.lsp")
local json = require("nattlua.other.json")
local rpc_util = require("nattlua.other.jsonrpc")
local INPUT = io.stdin
Expand Down
2 changes: 1 addition & 1 deletion nattlua/c_declarations/main.lua
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ local Code = require("nattlua.code").New
local Compiler = require("nattlua.compiler")
local variables = Table()
local types = Table()
local ffi = require("ffi")
local analyzer_context = require("nattlua.analyzer.context")

local function C_DECLARATIONS()
Expand Down Expand Up @@ -85,6 +84,7 @@ end
function cparser.sizeof(cdecl, len)
-- TODO: support non string sizeof
if jit and cdecl.Type == "string" and cdecl:IsLiteral() then
local ffi = require("ffi")
local analyzer = analyzer_context:GetCurrentAnalyzer()
local env = analyzer:GetScopeHelper(analyzer.function_scope)
local vars, typs = analyze(cdecl:GetData(), "typeof", env, analyzer)
Expand Down
4 changes: 2 additions & 2 deletions nattlua/cli.lua
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ default.build = function(path, path_to)
f:close()
end
default["language-server"] = function()
require("language_server.server.main")()
require("language_server.main")()
end

function _G.RUN_CLI(cmd, ...)
Expand Down Expand Up @@ -60,4 +60,4 @@ function _G.RUN_CLI(cmd, ...)
local func = assert(default[cmd], "Unknown command " .. cmd)
io.write("running ", cmd, " with arguments ", table.concat(args, " "), "\n")
func(unpack(args))
end
end
4 changes: 2 additions & 2 deletions nlconfig.lua
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ local analyzer_config = {
local config = {}
config["build:vscode"] = function()
os.execute(
"cd language_server/vscode && yarn && yarn build && code --install-extension nattlua-0.0.1.vsix"
"cd vscode_extension && yarn && yarn build && code --install-extension nattlua-0.0.1.vsix"
)
end
config.install = function()
Expand Down Expand Up @@ -191,4 +191,4 @@ config.check = function()
)
compiler:Analyze()
end
return config
return config
4 changes: 2 additions & 2 deletions test/nattlua/lsp/editor.lua
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
local EditorHelper = require("nattlua.editor_helper.editor")
local EditorHelper = require("language_server.editor_helper")
local path = "./test.nlua"

local function single_file(code)
Expand Down Expand Up @@ -243,4 +243,4 @@ do
assert(hints[1].start == 7)
assert(hints[1].stop == 7)
assert(hints[1].label == "20")
end
end
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ const getAllFiles = function (dirPath, arrayOfFiles) {

let tests = []

for (let path of getAllFiles("../../test/nattlua/analyzer/")) {
for (let path of getAllFiles("../test/nattlua/analyzer/")) {
if (path.endsWith(".nlua")) {
tests.push(fs.readFileSync(path).toString())
} else {
Expand All @@ -46,7 +46,7 @@ fs.writeFileSync("src/random.json", JSON.stringify(tests))
await finished(Readable.fromWeb(res.body).pipe(fileStream))
})()

execSync("cd ../../ && luajit nattlua.lua build fast")
execSync("cd ../ && luajit nattlua.lua build fast")

require("esbuild")
.build({
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// prettier-ignore
export const assortedExamples = {
ffi:
`local ffi = require("ffi")
ffi:
`local ffi = require("ffi")
ffi.cdef[[
unsigned long compressBound(unsigned long sourceLen);
int compress2(char *dest, unsigned long *destLen, const char *source, unsigned long sourceLen, int level);
Expand Down Expand Up @@ -33,8 +33,8 @@ local c = compress(txt)
print("Compressed size: ", #c)
local txt2 = uncompress(c, #txt)
assert(txt2 == txt)`,
string_parse:
`local cfg = [[
string_parse:
`local cfg = [[
name=Lua
cycle=123
debug=yes
Expand All @@ -51,8 +51,8 @@ end
local tbl = parse(cfg) -- hover me`,


type_assert:
`local function assert_whole_number<|T: number|>
type_assert:
`local function assert_whole_number<|T: number|>
if math.floor(T) ~= T then
type_error("Expected whole number", 2)
return any
Expand All @@ -64,16 +64,16 @@ end
local x = assert_whole_number<|5.5|>`,


array:
`local function Array<|T: any, L: number|>
array:
`local function Array<|T: any, L: number|>
return {[1..L] = T}
end
local list: Array<|number, 3|> = {1, 2, 3, 4}`,


list_generic:
`function List<|T: any|>
list_generic:
`function List<|T: any|>
return {[1..inf] = T | nil}
end
Expand All @@ -83,8 +83,8 @@ names[2] = "bar"
names[-1] = "faz"`,


load_evaluation:
`local function build_summary_function(tbl)
load_evaluation:
`local function build_summary_function(tbl)
local lua = {}
table.insert(lua, "local sum = 0")
table.insert(lua, "for i = " .. tbl.init .. ", " .. tbl.max .. " do")
Expand All @@ -102,8 +102,8 @@ local func = build_summary_function({
})`,


anagram_proof:
`local bytes = {}
anagram_proof:
`local bytes = {}
for i,v in ipairs({
"P", "S", "E", "L", "E",
}) do
Expand All @@ -115,10 +115,10 @@ local anagram = string.char(all_letters, all_letters, all_letters, all_letters,
assert(anagram == "SLEEP")
print<|anagram|> -- see console or hover me`,

base64: import("../../../test/nattlua/analyzer/complex/base64.nlua"),
typescript: import("../../../test/nattlua/analyzer/complex/typescript.nlua"),
spritemanager: import("../../../test/nattlua/analyzer/complex/spritemanager.nlua"),
brainfudge: import("../../../test/nattlua/analyzer/complex/brainfudge.nlua"),
["js-array"]: import("../../../test/nattlua/analyzer/complex/array.nlua"),
["maze"]: import("../../../test/nattlua/analyzer/complex/maze.nlua"),
base64: import("../../test/nattlua/analyzer/complex/base64.nlua"),
typescript: import("../../test/nattlua/analyzer/complex/typescript.nlua"),
spritemanager: import("../../test/nattlua/analyzer/complex/spritemanager.nlua"),
brainfudge: import("../../test/nattlua/analyzer/complex/brainfudge.nlua"),
["js-array"]: import("../../test/nattlua/analyzer/complex/array.nlua"),
["maze"]: import("../../test/nattlua/analyzer/complex/maze.nlua"),
}
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ export const loadLua = async () => {
openStandardLibs: true,
})

await loadLuaModule(lua, import("./../../../build_output.lua"), "nattlua")
await loadLuaModule(lua, import("./../../build_output.lua"), "nattlua")
await lua.doString("for k, v in pairs(package.preload) do print(k,v) end require('nattlua') for k,v in pairs(IMPORTS) do package.preload[k] = v end")
await loadLuaModule(lua, import("./../../server/lsp.lua"), "lsp", "@language_server/server/lsp.lua")
await loadLuaModule(lua, import("./../../language_server/lsp.lua"), "lsp", "@language_server/lsp.lua")

await lua.doString(`
local lsp = require("lsp")
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 comments on commit b76f6cd

Please sign in to comment.