aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoey Yakimowich-Payne <jyapayne@gmail.com>2020-04-23 20:20:05 -0600
committerJoey Yakimowich-Payne <jyapayne@gmail.com>2020-04-26 09:12:17 -0600
commitcc460b2779fc8b2035c19e0ba8f460cf124d474f (patch)
tree46323ed1cc44004aa061ef4f27adb1952cef29d5
parent073dc5d35a70270c49234842bfbb7f3e608c539e (diff)
downloadnimterop-cc460b2779fc8b2035c19e0ba8f460cf124d474f.tar.gz
nimterop-cc460b2779fc8b2035c19e0ba8f460cf124d474f.zip
Add skippedSymbols for determining if a type has been skipped
-rw-r--r--nimterop/ast2.nim3
-rw-r--r--nimterop/exprparser.nim25
-rw-r--r--nimterop/globals.nim3
3 files changed, 19 insertions, 12 deletions
diff --git a/nimterop/ast2.nim b/nimterop/ast2.nim
index bb41ebe..2ae4a70 100644
--- a/nimterop/ast2.nim
+++ b/nimterop/ast2.nim
@@ -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
diff --git a/nimterop/exprparser.nim b/nimterop/exprparser.nim
index 6e102ea..1f6decc 100644
--- a/nimterop/exprparser.nim
+++ b/nimterop/exprparser.nim
@@ -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)
diff --git a/nimterop/globals.nim b/nimterop/globals.nim
index 0d0b4cd..d433ab5 100644
--- a/nimterop/globals.nim
+++ b/nimterop/globals.nim
@@ -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