Add skippedSymbols for determining if a type has been skipped

This commit is contained in:
Joey Yakimowich-Payne 2020-04-23 20:20:05 -06:00
commit eaecf9ebdf
3 changed files with 19 additions and 12 deletions

View file

@ -41,6 +41,7 @@ proc getOverrideOrSkip(gState: State, node: TSNode, origname: string, kind: NimS
result = pnode[0][0]
else:
gecho &"\n# $1'{origname}' skipped" % skind
gState.skippedSyms.incl origname
if gState.debug:
gState.skipStr &= &"\n{gState.getNodeVal(node)}"
@ -99,6 +100,7 @@ proc newConstDef(gState: State, node: TSNode, fname = "", fval = ""): PNode =
fval
else:
gState.getNodeVal(node[1])
var valident = newNode(nkNone)
withCodeAst(val, gState.mode):
@ -151,6 +153,7 @@ proc newConstDef(gState: State, node: TSNode, fname = "", fval = ""): PNode =
gecho &"# const '{origname}' is duplicate, skipped"
else:
gecho &"# const '{origname}' has invalid value '{val}'"
gState.skippedSyms.incl origname
proc addConst(gState: State, node: TSNode) =
# Add a const to the AST

View file

@ -45,16 +45,17 @@ proc getExprIdent*(gState: State, identName: string, kind = nskConst, parent = "
##
## Returns PNode(nkNone) if the identifier is blank
result = newNode(nkNone)
var ident = identName
if ident != "_":
# Process the identifier through cPlugin
ident = gState.getIdentifier(ident, kind, parent)
if kind == nskType:
result = gState.getIdent(ident)
elif ident.nBl and ident in gState.constIdentifiers:
if gState.currentTyCastName.nBl:
ident = ident & "." & gState.currentTyCastName
result = gState.getIdent(ident)
if identName notin gState.skippedSyms:
var ident = identName
if ident != "_":
# Process the identifier through cPlugin
ident = gState.getIdentifier(ident, kind, parent)
if kind == nskType:
result = gState.getIdent(ident)
elif ident.nBl and ident in gState.constIdentifiers:
if gState.currentTyCastName.nBl:
ident = ident & "." & gState.currentTyCastName
result = gState.getIdent(ident)
proc getExprIdent*(gState: State, node: TSNode, kind = nskConst, parent = ""): PNode =
## Gets a cPlugin transformed identifier from `identName`
@ -534,8 +535,8 @@ proc processTSNode(gState: State, node: TSNode, typeofNode: var PNode): PNode =
result = gState.getExprIdent(ty, nskType, parent=node.getName())
else:
result = gState.getExprIdent(node.val, nskType, parent=node.getName())
if result.kind == nkNone:
raise newException(ExprParseError, &"Missing type specifier \"{node.val}\"")
if result.kind == nkNone:
raise newException(ExprParseError, &"Missing type specifier \"{node.val}\"")
of "identifier":
# Input -> IDENT
# Output -> IDENT (if found in sym table, else error)

View file

@ -76,6 +76,9 @@ type
# All const names for enum casting
constIdentifiers*: HashSet[string]
# All symbols that have been skipped
skippedSyms*: HashSet[string]
# Legacy ast fields, remove when ast2 becomes default
constStr*, enumStr*, procStr*, typeStr*: string