Skip to content

Commit

Permalink
Comment wip package manager
Browse files Browse the repository at this point in the history
Signed-off-by: George Lemon <[email protected]>
  • Loading branch information
georgelemon committed Oct 10, 2024
1 parent 109c679 commit 2d27820
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 28 deletions.
8 changes: 4 additions & 4 deletions src/timpkg/engine/meta.nim
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import pkg/importer/resolver
export getProjectPath

from ./ast import Ast
from ./package/manager import Packager, loadPackages
# from ./package/manager import Packager, loadPackages

var placeholderLocker*: Lock

Expand Down Expand Up @@ -58,7 +58,7 @@ type
policy: TimPolicy
globals: JsonNode = newJObject()
importsHandle*: Resolver
packager*: Packager
# packager*: Packager

TimEngineSnippets* = TableRef[string, seq[Ast]]
TimError* = object of CatchableError
Expand Down Expand Up @@ -375,9 +375,9 @@ proc newTim*(src, output, basepath: string, minify = true,
minify: minify,
indentSize: indent,
htmlErrors: showHtmlError,
packager: Packager()
# packager: Packager()
)
result.packager.loadPackages()
# result.packager.loadPackages()
for sourceDir in [ttLayout, ttView, ttPartial]:
if not dirExists(result.src / $sourceDir):
raise newException(TimError, "Missing $1 directory: \n$2" % [$sourceDir, result.src / $sourceDir])
Expand Down
49 changes: 25 additions & 24 deletions src/timpkg/engine/parser.nim
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
import std/[macros, macrocache, streams, lexbase,
strutils, sequtils, re, tables, os, with, options]

import ./meta, ./tokens, ./ast, ./logging,
./std, ./package/manager
import ./meta, ./tokens, ./ast, ./logging, ./std
# import ./package/manager

import pkg/kapsis/cli
import pkg/importer
Expand Down Expand Up @@ -1117,20 +1117,21 @@ prefixHandle pImport:
p.engine.parseModule(p.curr.value, std(p.curr.value)[1])
p.tree.modules[p.curr.value].src = p.curr.value
elif p.curr.value.startsWith("pkg/"):
if likely(p.engine.packager.hasPackage(p.curr.value[4..^1].split("/")[0])):
# var moduleAst: Ast
# if likely(p.engine.packager.flagNoCache == false):
# moduleAst = p.engine.packager.getCachedModule(p.curr.value)
# if moduleAst != nil:
# p.tree.modules[p.curr.value] = moduleAst
# else:
let moduleCode = p.engine.packager.loadModule(p.curr.value)
let moduleAst = p.engine.parseModule(p.curr.value, SourceCode(moduleCode))
p.tree.modules[p.curr.value] = moduleAst
# if p.engine.packager.flagNoCache == false:
# p.engine.packager.cacheModule(p.curr.value, moduleAst)
else:
errorWithArgs(importError, p.curr, [p.curr.value.addFileExt(".timl")])
discard # todo
# if likely(p.engine.packager.hasPackage(p.curr.value[4..^1].split("/")[0])):
# # var moduleAst: Ast
# # if likely(p.engine.packager.flagNoCache == false):
# # moduleAst = p.engine.packager.getCachedModule(p.curr.value)
# # if moduleAst != nil:
# # p.tree.modules[p.curr.value] = moduleAst
# # else:
# let moduleCode = p.engine.packager.loadModule(p.curr.value)
# let moduleAst = p.engine.parseModule(p.curr.value, SourceCode(moduleCode))
# p.tree.modules[p.curr.value] = moduleAst
# # if p.engine.packager.flagNoCache == false:
# # p.engine.packager.cacheModule(p.curr.value, moduleAst)
# else:
# errorWithArgs(importError, p.curr, [p.curr.value.addFileExt(".timl")])
else:
let path =
(if not isAbsolute(p.curr.value):
Expand Down Expand Up @@ -1896,13 +1897,13 @@ proc parseSnippet*(id, code: string,
logger: Logger(filePath: id),
engine: TimEngine(
`type`: TimEngineRuntime.runtimePassAndExit,
packager: Packager(
flagNoCache: noCache,
flagRecache: reCache
)
# packager: Packager(
# flagNoCache: noCache,
# flagRecache: reCache
# )
),
)
p.engine.packager.loadPackages()
# p.engine.packager.loadPackages()
p.curr = p.lex.getToken()
p.next = p.lex.getToken()
initModuleSystem()
Expand Down Expand Up @@ -1931,9 +1932,9 @@ proc parseSnippet*(snippetPath: string): Parser {.gcsafe.} =
logger: Logger(filePath: snippetPath),
engine: TimEngine(
`type`: TimEngineRuntime.runtimePassAndExit,
packager: Packager(
flagNoCache: true
)
# packager: Packager(
# flagNoCache: true
# )
),
)
p.curr = p.lex.getToken()
Expand Down

0 comments on commit 2d27820

Please sign in to comment.