Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixes std imports #567

Merged
merged 7 commits into from
Feb 17, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions src/gear2/modnames.nim
Original file line number Diff line number Diff line change
Expand Up @@ -59,5 +59,7 @@ proc moduleSuffix*(path: string; searchPaths: openArray[string]): string =
id = id div 36'u32

when isMainModule:
echo moduleSuffix("/Users/rumpf/projects/nim/lib/system.nim")
echo moduleSuffix("/Users/araq/projects/nim/lib/system.nim")
#echo moduleSuffix("/Users/rumpf/projects/nim/lib/system.nim")
#echo moduleSuffix("/Users/araq/projects/nim/lib/system.nim")
echo moduleSuffix("/Users/rumpf/projects/nimony/lib/std/system.nim", [])
echo moduleSuffix("/Users/rumpf/projects/nimony/lib/std/system.nim", ["/Users/rumpf/projects/nimony/lib"])
5 changes: 2 additions & 3 deletions src/hexer/lifter.nim
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import std/[assertions, tables]

include nifprelude
import nifindexes, symparser, treemangler, typekeys
import ".." / nimony / [nimony_model, decls, programs, typenav, expreval, xints]
import ".." / nimony / [nimony_model, decls, programs, typenav, expreval, xints, builtintypes]

type
TypeCursor = Cursor
Expand Down Expand Up @@ -63,8 +63,7 @@ proc hasHook(c: var LiftingCtx; s: SymId): bool =
false

proc getCompilerProc(c: var LiftingCtx; name: string): SymId =
const systemSuffix = "sys9azlf"
result = pool.syms.getOrIncl(name & ".0." & systemSuffix)
result = pool.syms.getOrIncl(name & ".0." & SystemModuleSuffix)

proc isTrivialForFields(c: var LiftingCtx; n: Cursor): bool =
var n = n
Expand Down
2 changes: 1 addition & 1 deletion src/nimony/builtintypes.nim
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ proc tagToken(tag: string; info: PackedLineInfo = NoLineInfo): PackedToken {.inl
parLeToken(pool.tags.getOrIncl(tag), info)

const
SystemModuleSuffix* = "sys9azlf"
SystemModuleSuffix* = "sysvq0asl" # "sys9azlf"
StringName* = "string.0." & SystemModuleSuffix
StringAField* = "a.0." & SystemModuleSuffix
StringIField* = "i.0." & SystemModuleSuffix
Expand Down
7 changes: 2 additions & 5 deletions src/nimony/nimony.nim
Original file line number Diff line number Diff line change
Expand Up @@ -139,11 +139,8 @@ proc handleCmdLine() =
quit "too few command line arguments"
elif args.len > 2 - int(cmd == FullProject):
quit "too many command line arguments"
if useEnv:
let nimPath = getEnv("NIMPATH")
for entry in split(nimPath, PathSep):
if entry.strip != "":
config.paths.add entry
semos.setupPaths(config, useEnv)

case cmd
of None:
quit "command missing"
Expand Down
6 changes: 1 addition & 5 deletions src/nimony/nimsem.nim
Original file line number Diff line number Diff line change
Expand Up @@ -105,11 +105,7 @@ proc handleCmdLine() =
of cmdEnd: assert false, "cannot happen"
if args.len != 3:
quit "want exactly 3 command line arguments"
if useEnv:
let nimPath = getEnv("NIMPATH")
for entry in split(nimPath, PathSep):
if entry.strip != "":
config.paths.add entry
semos.setupPaths(config, useEnv)
case cmd
of None:
quit "command missing"
Expand Down
22 changes: 18 additions & 4 deletions src/nimony/semos.nim
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

## Path handling and `exec` like features as `sem.nim` needs it.

from std / strutils import multiReplace
from std / strutils import multiReplace, split, strip
import std / [tables, sets, os, syncio, formatfloat, assertions]
include nifprelude
import ".." / lib / nifchecksums
Expand All @@ -17,13 +17,27 @@ import nimony_model, symtabs, builtintypes, decls, symparser, asthelpers,

import ".." / gear2 / modnames

proc stdlibFile*(f: string): string =
proc stdlibDir*(): string =
let appDir = getAppDir()
let (head, tail) = splitPath(appDir)
if tail == "bin":
result = head / "lib" / f
result = head / "lib"
else:
result = appDir / "lib"

proc setupPaths*(config: var NifConfig; useEnv: bool) =
if useEnv:
let nimPath = getEnv("NIMPATH")
for entry in split(nimPath, PathSep):
if entry.strip != "":
config.paths.add entry
if config.paths.len == 0:
config.paths.add stdlibDir()
else:
result = appDir / "lib" / f
config.paths.add stdlibDir()

proc stdlibFile*(f: string): string =
result = stdlibDir() / f

proc binDir*(): string =
let appDir = getAppDir()
Expand Down
4 changes: 2 additions & 2 deletions tests/nimony/generics/texplicitprocinst.nif
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,11 @@
(discard .))) 8,4
(proc :foo.3.texhjoap . ~8,~3 .
(at foo.1.texhjoap 4,~1
(i -1) 9 string.0.sys9azlf) 6,~3
(i -1) 9 string.0.sysvq0asl) 6,~3
(params 1
(param :x.6 . . ~3,2
(i -1) .) 7
(param :y.2 . . ~4,3 string.0.sys9azlf .)) ~8,~3 . ~8,~3 . ~8,~3 . 21,~3
(param :y.2 . . ~4,3 string.0.sysvq0asl .)) ~8,~3 . ~8,~3 . ~8,~3 . 21,~3
(stmts
(discard .))) 28,10
(proc :importedGeneric.0.texhjoap . 0,1,tests/nimony/generics/deps/mgenericproc.nim .
Expand Down
6 changes: 3 additions & 3 deletions tests/nimony/nosystem/t2.nif
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
(typedesc 1 T.1.t2er4ggt1) 35
(pragmas 2
(magic 7 TypeOf)) . .) 10,9
(type ~8 :string.0.t2er4ggt1 x . . string.0.sys9azlf) ,12
(type ~8 :string.0.t2er4ggt1 x . . string.0.sysvq0asl) ,12
(proc 5 :\2B.0.t2er4ggt1
(add -3) . . 9
(params 1
Expand All @@ -38,12 +38,12 @@
(params 1
(param :x.2 . . 3
(i -1) .) 9
(param :y.1 . . string.0.sys9azlf .)) 21
(param :y.1 . . string.0.sysvq0asl .)) 21
(i -1) . . 2,1
(stmts 4
(result :result.0 . . 10,~3
(i -1) .) 4
(var :x.4 . . string.0.sys9azlf 4 "abc") 7,1
(var :x.4 . . string.0.sysvq0asl 4 "abc") 7,1
(asgn ~7 result.0 2 +4) 2,2
(asgn ~2 x.4 2 "34") ~2,~1
(ret result.0))) ,19
Expand Down
4 changes: 2 additions & 2 deletions tests/nimony/nosystem/tbool.nif
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@
(proc :dollar`.bool.0.tbokvwxm9 x . .
(params
(param :e.0 . .
(bool) .)) string.0.sys9azlf . .
(bool) .)) string.0.sysvq0asl . .
(stmts 23
(result :result.0 . . string.0.sys9azlf .) 23
(result :result.0 . . string.0.sysvq0asl .) 23
(case e.0 ~18,1
(of
(ranges ~8
Expand Down
2 changes: 1 addition & 1 deletion tests/nimony/nosystem/tdistinct.nif
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
(typedesc 1 T.1.tdiuhv8dm) 35
(pragmas 2
(magic 7 TypeOf)) . .) 10,11
(type ~8 :string.0.tdiuhv8dm x . . string.0.sys9azlf) ,13
(type ~8 :string.0.tdiuhv8dm x . . string.0.sysvq0asl) ,13
(proc 5 :\2B.0.tdiuhv8dm
(add -3) . . 9
(params 1
Expand Down
12 changes: 6 additions & 6 deletions tests/nimony/nosystem/tenumsizes.nif
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@
(tup +3 "a3")))) 5
(proc :dollar`.A.0.tene657oj x . .
(params
(param :e.0 . . A.0.tene657oj .)) string.0.sys9azlf . .
(param :e.0 . . A.0.tene657oj .)) string.0.sysvq0asl . .
(stmts 4
(result :result.0 . . string.0.sys9azlf .) 4
(result :result.0 . . string.0.sysvq0asl .) 4
(case e.0 ~7,1
(of
(ranges a0.0.tene657oj)
Expand Down Expand Up @@ -47,9 +47,9 @@
(tup +5 "b3")))) 5,2
(proc :dollar`.B.0.tene657oj x . .
(params
(param :e.1 . . B.0.tene657oj .)) string.0.sys9azlf . .
(param :e.1 . . B.0.tene657oj .)) string.0.sysvq0asl . .
(stmts 4
(result :result.1 . . string.0.sys9azlf .) 4
(result :result.1 . . string.0.sysvq0asl .) 4
(case e.1 ~2,1
(of
(ranges ~5 b0.0.tene657oj)
Expand Down Expand Up @@ -81,9 +81,9 @@
(tup +30001 "c3")))) 5,4
(proc :dollar`.C.0.tene657oj x . .
(params
(param :e.2 . . C.0.tene657oj .)) string.0.sys9azlf . .
(param :e.2 . . C.0.tene657oj .)) string.0.sysvq0asl . .
(stmts 4
(result :result.2 . . string.0.sys9azlf .) 4
(result :result.2 . . string.0.sysvq0asl .) 4
(case e.2 ~7,1
(of
(ranges c0.0.tene657oj)
Expand Down
6 changes: 3 additions & 3 deletions tests/nimony/nosystem/tgeneric_obj.nif
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
(typedesc 1 T.3.tge7jvqqk1) 35
(pragmas 2
(magic 7 TypeOf)) . .) 10,14
(type ~8 :string.0.tge7jvqqk1 x . . string.0.sys9azlf) 4,16
(type ~8 :string.0.tge7jvqqk1 x . . string.0.sysvq0asl) 4,16
(gvar :myset.0.tge7jvqqk1 . . 10
(set 1
(u +8)) .) 4,17
Expand Down Expand Up @@ -100,12 +100,12 @@
(params 1
(param :x.2 . . 3
(i -1) .) 9
(param :y.1 . . string.0.sys9azlf .)) 21
(param :y.1 . . string.0.sysvq0asl .)) 21
(i -1) . . 2,1
(stmts 4
(result :result.0 . . 10,~6
(i -1) .) 4
(var :x.5 . . string.0.sys9azlf 4 "abc") 7,1
(var :x.5 . . string.0.sysvq0asl 4 "abc") 7,1
(asgn ~7 result.0 2 +4) 2,2
(asgn ~2 x.5 2 "34") ~2,~1
(ret result.0))) ,43
Expand Down
8 changes: 4 additions & 4 deletions tests/nimony/nosystem/tresemtype.nif
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
(stmts 9
(type ~4 :Foo.3 . . . 2
(object . ~9,1
(fld :val.3.treckpe1i1 . . string.0.sys9azlf .))) 4,2
(fld :val.3.treckpe1i1 . . string.0.sysvq0asl .))) 4,2
(gvar :obj.3 . . 6 Foo.3 9
(oconstr ~3 Foo.3 4
(kv ~4 val.3.treckpe1i1 ~10,3 "abc")))) 3,5
Expand All @@ -56,13 +56,13 @@
(oconstr ~3 Foo.4 4
(kv ~4 val.4.treckpe1i1 2 x.4))))) 3,6
(proc :foo.2.treckpe1i1 . ~3,~6 .
(at foo.0.treckpe1i1 string.0.sys9azlf) 8,~6
(at foo.0.treckpe1i1 string.0.sysvq0asl) 8,~6
(params 1
(param :x.5 . . string.0.sys9azlf .)) ~3,~6 . ~3,~6 . ~3,~6 . ~1,~5
(param :x.5 . . string.0.sysvq0asl .)) ~3,~6 . ~3,~6 . ~3,~6 . ~1,~5
(stmts 9
(type ~4 :Foo.5 . . . 2
(object . ~9,1
(fld :val.5.treckpe1i1 . . string.0.sys9azlf .))) 4,2
(fld :val.5.treckpe1i1 . . string.0.sysvq0asl .))) 4,2
(var :obj.5 . . 6 Foo.5 9
(oconstr ~3 Foo.5 4
(kv ~4 val.5.treckpe1i1 2 x.5))))))
6 changes: 3 additions & 3 deletions tests/nimony/nosystem/ttemplate.nif
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
(typedesc 1 T.2.tte5tld8n) 35
(pragmas 2
(magic 7 TypeOf)) . .) 10,12
(type ~8 :string.0.tte5tld8n x . . string.0.sys9azlf) 15,15
(type ~8 :string.0.tte5tld8n x . . string.0.sysvq0asl) 15,15
(type ~13 :MyGeneric.0.tte5tld8n . ~4
(typevars 1
(typevar :T.3.tte5tld8n . . . .)) . 2
Expand Down Expand Up @@ -71,12 +71,12 @@
(params 1
(param :x.3 . . 3
(i -1) .) 9
(param :y.2 . . string.0.sys9azlf .)) 21
(param :y.2 . . string.0.sysvq0asl .)) 21
(i -1) . . 2,1
(stmts 4
(result :result.0 . . 10,~5
(i -1) .) 4
(var :x.5 . . string.0.sys9azlf 4 "abc") 7,1
(var :x.5 . . string.0.sysvq0asl 4 "abc") 7,1
(asgn ~7 result.0 23,~4
(expr 2
(expr
Expand Down
6 changes: 3 additions & 3 deletions tests/nimony/nosystem/tvarargs.nif
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
(typedesc 1 T.1.tvah6culb) 35
(pragmas 2
(magic 7 TypeOf)) . .) 10,9
(type ~8 :string.0.tvah6culb x . . string.0.sys9azlf) ,11
(type ~8 :string.0.tvah6culb x . . string.0.sysvq0asl) ,11
(proc 5 :\2B.0.tvah6culb
(add -3) . . 9
(params 1
Expand Down Expand Up @@ -73,7 +73,7 @@
(params 1
(param :f.1 . . 3
(mut 4 File.0.tvah6culb) .) 14
(param :s.0 . . string.0.sys9azlf .)) . . . 37
(param :s.0 . . string.0.sysvq0asl .)) . . . 37
(stmts
(discard .))) ,24
(cmd write.0.tvah6culb 6
Expand Down Expand Up @@ -104,7 +104,7 @@
(cmd
(ochoice write.0.tvah6culb write.1.tvah6culb) 6 stdout.0.tvah6culb 14 x.4))) ,2
(cmd write.0.tvah6culb 6 stdout.0.tvah6culb 14 '\0A'))) 4,36
(gvar :someVar.0.tvah6culb . . string.0.sys9azlf 10 "") 2,32
(gvar :someVar.0.tvah6culb . . string.0.sysvq0asl 10 "") 2,32
(stmts 2,1
(stmts
(cmd write.1.tvah6culb 6
Expand Down
6 changes: 3 additions & 3 deletions tests/nimony/sysbasics/tdollar.nif
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@
(tup +2 "Green1")))) 2,1
(proc :dollar`.Color1.0.tdoqc0e0v x . .
(params
(param :e.0 . . Color1.0.tdoqc0e0v .)) string.0.sys9azlf . .
(param :e.0 . . Color1.0.tdoqc0e0v .)) string.0.sysvq0asl . .
(stmts 9
(result :result.0 . . string.0.sys9azlf .) 9
(result :result.0 . . string.0.sysvq0asl .) 9
(case e.0 ~7,1
(of
(ranges Red1.0.tdoqc0e0v)
Expand All @@ -31,5 +31,5 @@
(proc 5 :fooColor.0.tdoqc0e0v . . . 14
(params) . . . 2,1
(stmts 4
(let :m.0 . . string.0.sys9azlf 4
(let :m.0 . . string.0.sysvq0asl 4
(call dollar`.Color1.0.tdoqc0e0v 1 Blue1.0.tdoqc0e0v)))))
2 changes: 1 addition & 1 deletion tests/nimony/sysbasics/tforloops1.nif
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@
(add ~25,~6
(i -1) ~1 m.2 1 n.3)))))) 4,20
(proc :inc.0.tfo6yv57p . 0,276,lib/std/system.nim .
(at inc.1.sys9azlf 19,~4
(at inc.1.sysvq0asl 19,~4
(i -1)) 21,276,lib/std/system.nim
(params 1
(param :x.2 . . 3
Expand Down
4 changes: 2 additions & 2 deletions tests/nimony/sysbasics/tsets.nif
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@
(tup +5 "F")))) 5
(proc :dollar`.Foo.0.tsefy5wha x . .
(params
(param :e.0 . . Foo.0.tsefy5wha .)) string.0.sys9azlf . .
(param :e.0 . . Foo.0.tsefy5wha .)) string.0.sysvq0asl . .
(stmts 6
(result :result.0 . . string.0.sys9azlf .) 6
(result :result.0 . . string.0.sysvq0asl .) 6
(case e.0 ~9,1
(of
(ranges A.0.tsefy5wha)
Expand Down
Loading