Add skippedSymbols for determining if a type has been skipped
This commit is contained in:
parent
9ef3182d7a
commit
eaecf9ebdf
3 changed files with 19 additions and 12 deletions
|
|
@ -41,6 +41,7 @@ proc getOverrideOrSkip(gState: State, node: TSNode, origname: string, kind: NimS
|
||||||
result = pnode[0][0]
|
result = pnode[0][0]
|
||||||
else:
|
else:
|
||||||
gecho &"\n# $1'{origname}' skipped" % skind
|
gecho &"\n# $1'{origname}' skipped" % skind
|
||||||
|
gState.skippedSyms.incl origname
|
||||||
if gState.debug:
|
if gState.debug:
|
||||||
gState.skipStr &= &"\n{gState.getNodeVal(node)}"
|
gState.skipStr &= &"\n{gState.getNodeVal(node)}"
|
||||||
|
|
||||||
|
|
@ -99,6 +100,7 @@ proc newConstDef(gState: State, node: TSNode, fname = "", fval = ""): PNode =
|
||||||
fval
|
fval
|
||||||
else:
|
else:
|
||||||
gState.getNodeVal(node[1])
|
gState.getNodeVal(node[1])
|
||||||
|
|
||||||
var valident = newNode(nkNone)
|
var valident = newNode(nkNone)
|
||||||
|
|
||||||
withCodeAst(val, gState.mode):
|
withCodeAst(val, gState.mode):
|
||||||
|
|
@ -151,6 +153,7 @@ proc newConstDef(gState: State, node: TSNode, fname = "", fval = ""): PNode =
|
||||||
gecho &"# const '{origname}' is duplicate, skipped"
|
gecho &"# const '{origname}' is duplicate, skipped"
|
||||||
else:
|
else:
|
||||||
gecho &"# const '{origname}' has invalid value '{val}'"
|
gecho &"# const '{origname}' has invalid value '{val}'"
|
||||||
|
gState.skippedSyms.incl origname
|
||||||
|
|
||||||
proc addConst(gState: State, node: TSNode) =
|
proc addConst(gState: State, node: TSNode) =
|
||||||
# Add a const to the AST
|
# Add a const to the AST
|
||||||
|
|
|
||||||
|
|
@ -45,16 +45,17 @@ proc getExprIdent*(gState: State, identName: string, kind = nskConst, parent = "
|
||||||
##
|
##
|
||||||
## Returns PNode(nkNone) if the identifier is blank
|
## Returns PNode(nkNone) if the identifier is blank
|
||||||
result = newNode(nkNone)
|
result = newNode(nkNone)
|
||||||
var ident = identName
|
if identName notin gState.skippedSyms:
|
||||||
if ident != "_":
|
var ident = identName
|
||||||
# Process the identifier through cPlugin
|
if ident != "_":
|
||||||
ident = gState.getIdentifier(ident, kind, parent)
|
# Process the identifier through cPlugin
|
||||||
if kind == nskType:
|
ident = gState.getIdentifier(ident, kind, parent)
|
||||||
result = gState.getIdent(ident)
|
if kind == nskType:
|
||||||
elif ident.nBl and ident in gState.constIdentifiers:
|
result = gState.getIdent(ident)
|
||||||
if gState.currentTyCastName.nBl:
|
elif ident.nBl and ident in gState.constIdentifiers:
|
||||||
ident = ident & "." & gState.currentTyCastName
|
if gState.currentTyCastName.nBl:
|
||||||
result = gState.getIdent(ident)
|
ident = ident & "." & gState.currentTyCastName
|
||||||
|
result = gState.getIdent(ident)
|
||||||
|
|
||||||
proc getExprIdent*(gState: State, node: TSNode, kind = nskConst, parent = ""): PNode =
|
proc getExprIdent*(gState: State, node: TSNode, kind = nskConst, parent = ""): PNode =
|
||||||
## Gets a cPlugin transformed identifier from `identName`
|
## 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())
|
result = gState.getExprIdent(ty, nskType, parent=node.getName())
|
||||||
else:
|
else:
|
||||||
result = gState.getExprIdent(node.val, nskType, parent=node.getName())
|
result = gState.getExprIdent(node.val, nskType, parent=node.getName())
|
||||||
if result.kind == nkNone:
|
if result.kind == nkNone:
|
||||||
raise newException(ExprParseError, &"Missing type specifier \"{node.val}\"")
|
raise newException(ExprParseError, &"Missing type specifier \"{node.val}\"")
|
||||||
of "identifier":
|
of "identifier":
|
||||||
# Input -> IDENT
|
# Input -> IDENT
|
||||||
# Output -> IDENT (if found in sym table, else error)
|
# Output -> IDENT (if found in sym table, else error)
|
||||||
|
|
|
||||||
|
|
@ -76,6 +76,9 @@ type
|
||||||
# All const names for enum casting
|
# All const names for enum casting
|
||||||
constIdentifiers*: HashSet[string]
|
constIdentifiers*: HashSet[string]
|
||||||
|
|
||||||
|
# All symbols that have been skipped
|
||||||
|
skippedSyms*: HashSet[string]
|
||||||
|
|
||||||
# Legacy ast fields, remove when ast2 becomes default
|
# Legacy ast fields, remove when ast2 becomes default
|
||||||
constStr*, enumStr*, procStr*, typeStr*: string
|
constStr*, enumStr*, procStr*, typeStr*: string
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue