Skip to content

Commit

Permalink
fixed some isues
Browse files Browse the repository at this point in the history
  • Loading branch information
Nimaoth committed Feb 25, 2024
1 parent 532b43a commit 98bcc67
Show file tree
Hide file tree
Showing 7 changed files with 47 additions and 15 deletions.
25 changes: 20 additions & 5 deletions config.nims
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,35 @@ switch("d", "allowConsoleLogger")

switch("d", "wasm3HasWasi")
switch("d", "wasm3VerboseErrorMessages")

# switches for debugging
# switch("d", "wasm3EnableStrace2")
# switch("d", "wasm3RecordBacktraces")

# switch("d", "wasm3LogModule")
# switch("d", "wasm3LogCompile")
# switch("d", "wasm3LogParse")
# switch("d", "wasm3LogRuntime")
# switch("d", "uiNodeDebugData")
# switch("d", "futureLogging")
# switch("d", "nimBurnFree")
# switch("d", "nimArcIds")
# switch("d", "traceArc")
# switch("d", "nimTypeNames")

# checks
# --objChecks:off
# --fieldChecks:off
# --rangeChecks:off
# --boundChecks:off
# --overflowChecks:off
# --floatChecks:off
# --nanChecks:off
# --infChecks:off

# switch("cc", "vcc")
# switch("nimcache", "D:\\nc")

let mode = 0
case mode
case 0
of 0:
switch("d", "release")
of 1:
Expand All @@ -39,11 +54,11 @@ of 2:
switch("cc", "vcc")
switch("d", "debug")
switch("debuginfo", "on")
switch("nimcache", "nimcache")
of 3:
switch("d", "release")
switch("debuginfo", "on")
switch("cc", "vcc")
switch("stackTrace", "on")
switch("lineTrace", "on")
switch("nimcache", "D:\\nc")
else:
discard
Expand Down
16 changes: 15 additions & 1 deletion src/absytree_dynlib.nim
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ else:
static:
echo "Compiling for unknown"

import std/[parseopt, options, macros]
import std/[parseopt, options, macros, tables]
import misc/[custom_logger]
import compilation_config, scripting_api, app_options

Expand Down Expand Up @@ -85,10 +85,12 @@ proc shutdown() =
if gApp.isNotNil:
log lvlInfo, "Shutting down editor"
gApp.shutdown()
gApp = nil

if rend.isNotNil:
log lvlInfo, "Shutting down platform"
rend.deinit()
rend = nil

proc NimMain() {.cdecl, importc.}

Expand All @@ -108,6 +110,18 @@ proc absytree_poll(timeoutMs: int32) {.exportc, dynlib, cdecl.} =
proc absytree_shutdown() {.exportc, dynlib, cdecl.} =
echo "Shutting down Absytree..."
shutdown()

when isFutureLoggingEnabled:
while hasPendingOperations():
debugf"Futures in progress:"
debugf"----------------------------"
for (info, x) in getFuturesInProgress().pairs:
debugf"{info.fromProc}: {info.stackTrace}"
debugf"----------------------------"
drain(100)

else:
drain(10000)
GC_FullCollect()

proc absytree_input_keys*(self: ptr AppObject, input: cstring) {.exportc, dynlib, cdecl.} =
Expand Down
2 changes: 1 addition & 1 deletion src/ast/lang/cell_language.nim
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ proc createCellLanguage*(): Future[Language] {.async.} =
log lvlError, "createCellLanguage: Failed to load cell builder model"
return Language nil

var language = createLanguageFromModel(model).await
var language = createLanguageFromModel(model, createBuilder = false).await
language.name = "Cells"
language.scopeComputers = scopeComputers
return language
Expand Down
4 changes: 2 additions & 2 deletions src/ast/lang/lang_builder.nim
Original file line number Diff line number Diff line change
Expand Up @@ -462,12 +462,12 @@ proc updateLanguageFromModel*(language: Language, model: Model, updateBuilder: b

return true

proc createLanguageFromModel*(model: Model, ctx = ModelComputationContextBase.none): Future[Language] {.async.} =
proc createLanguageFromModel*(model: Model, ctx = ModelComputationContextBase.none, createBuilder: bool = true): Future[Language] {.async.} =
log lvlInfo, fmt"createLanguageFromModel {model.path} ({model.id})"

let name = model.path.splitFile.name
let language = newLanguage(model.id.LanguageId, name)
if not language.updateLanguageFromModel(model, ctx = ctx).await:
if not language.updateLanguageFromModel(model, ctx = ctx, updateBuilder = createBuilder).await:
return Language nil
return language

Expand Down
8 changes: 4 additions & 4 deletions src/ast/model.nim
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ type
role*: string
class*: ClassId

NodeClass* = ref object
NodeClass* {.acyclic.} = ref object
id {.getter.}: ClassId
name {.getter.}: string
alias {.getter.}: string
Expand All @@ -78,13 +78,13 @@ type
canBeRoot {.getter.}: bool
registryIndex: int32 # Index in the global node registry (0 if not registered)

AstNode* = ref object
AstNode* {.acyclic.} = ref object
id*: NodeId
class*: ClassId

registryIndex: int32 # Index in the global node registry (0 if not registered)
model*: Model # gets set when inserted into a parent node which is in a model, or when inserted into a model
parent*: AstNode # gets set when inserted into a parent node
parent* {.cursor.}: AstNode # gets set when inserted into a parent node
role*: RoleId # gets set when inserted into a parent node

properties*: seq[tuple[role: RoleId, value: PropertyValue]]
Expand All @@ -111,7 +111,7 @@ type

ModelComputationContextBase* = ref object of RootObj

Language* = ref object
Language* {.acyclic.} = ref object
name* : string
id {.getter.}: LanguageId
version {.getter.}: int
Expand Down
5 changes: 4 additions & 1 deletion src/ast/project.nim
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,10 @@ proc loadModelAsync*(project: Project, path: string): Future[Option[Model]] {.as

let ws = getProjectWorkspace().await
let jsonText = ws.loadFile(path).await
let json = jsonText.parseJson

let json = jsonText.parseJson.catch:
log lvlError, &"project.loadModelAsync: Failed to parse json: {getCurrentExceptionMsg()}\n{getCurrentException().getStackTrace()}"
return Model.none

var model = newModel()
if not model.loadFromJsonAsync(project, ws, path, json, resolveLanguage, resolveModel).await:
Expand Down
2 changes: 1 addition & 1 deletion src/text/language/lsp_client.nim
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ proc parseResponse(client: LSPClient): Future[JsonNode] {.async.} =

if client.connection.isNil:
log(lvlError, "[parseResponse] Connection is nil")
return nil
return JsonNode(nil)

var success = true
var lines = @[line]
Expand Down

0 comments on commit 98bcc67

Please sign in to comment.