summary refs log tree commit diff stats
path: root/rod
diff options
context:
space:
mode:
Diffstat (limited to 'rod')
-rwxr-xr-xrod/c2nim/cparse.nim2
-rwxr-xr-xrod/msgs.nim9
-rwxr-xr-xrod/pas2nim/pasparse.nim2
-rwxr-xr-xrod/semexprs.nim29
-rwxr-xr-xrod/transf.nim2
5 files changed, 28 insertions, 16 deletions
diff --git a/rod/c2nim/cparse.nim b/rod/c2nim/cparse.nim
index 704e132f0..3f788c691 100755
--- a/rod/c2nim/cparse.nim
+++ b/rod/c2nim/cparse.nim
@@ -1204,7 +1204,7 @@ proc unaryExpression(p: var TParser): PNode =
   of pxPlusPlus: result = incdec(p, "inc")
   of pxMinusMinus: result = incdec(p, "dec")
   of pxAmp: result = unaryOp(p, nkAddr)
-  of pxStar: result = unaryOp(p, nkDerefExpr)
+  of pxStar: result = unaryOp(p, nkBracketExpr)
   of pxPlus: result = prefixCall(p, "+")
   of pxMinus: result = prefixCall(p, "-")
   of pxTilde: result = prefixCall(p, "not")
diff --git a/rod/msgs.nim b/rod/msgs.nim
index 96ad42923..97d4179da 100755
--- a/rod/msgs.nim
+++ b/rod/msgs.nim
@@ -90,7 +90,9 @@ type
     warnCannotWriteMO2, warnCannotReadMO2, warnDeprecated, 
     warnSmallLshouldNotBeUsed, warnUnknownMagic, warnRedefinitionOfLabel, 
     warnUnknownSubstitutionX, warnLanguageXNotSupported, warnCommentXIgnored, 
-    warnXisPassedToProcVar, warnUser, hintSuccess, hintSuccessX, 
+    warnXisPassedToProcVar, warnDerefDeprecated,
+    warnUser, 
+    hintSuccess, hintSuccessX, 
     hintLineTooLong, hintXDeclaredButNotUsed, hintConvToBaseNotNeeded, 
     hintConvFromXtoItselfNotNeeded, hintExprAlwaysX, hintQuitCalled, 
     hintProcessing, hintCodeBegin, hintCodeEnd, hintConf, hintPath, hintUser
@@ -319,6 +321,7 @@ const
     warnLanguageXNotSupported: "language \'$1\' not supported [LanguageXNotSupported]", 
     warnCommentXIgnored: "comment \'$1\' ignored [CommentXIgnored]", 
     warnXisPassedToProcVar: "\'$1\' is passed to a procvar; deprecated [XisPassedToProcVar]", 
+    warnDerefDeprecated: "p^ is deprecated; use p[] instead [DerefDeprecated]",
     warnUser: "$1 [User]", 
     hintSuccess: "operation successful [Success]", 
     hintSuccessX: "operation successful ($1 lines compiled; $2 sec total) [SuccessX]", 
@@ -336,11 +339,11 @@ const
     hintUser: "$1 [User]"]
 
 const 
-  WarningsToStr*: array[0..14, string] = ["CannotOpenFile", "OctalEscape", 
+  WarningsToStr*: array[0..15, string] = ["CannotOpenFile", "OctalEscape", 
     "XIsNeverRead", "XmightNotBeenInit", "CannotWriteMO2", "CannotReadMO2", 
     "Deprecated", "SmallLshouldNotBeUsed", "UnknownMagic", 
     "RedefinitionOfLabel", "UnknownSubstitutionX", "LanguageXNotSupported", 
-    "CommentXIgnored", "XisPassedToProcVar", "User"]
+    "CommentXIgnored", "XisPassedToProcVar", "DerefDeprecated", "User"]
 
   HintsToStr*: array[0..13, string] = ["Success", "SuccessX", "LineTooLong", 
     "XDeclaredButNotUsed", "ConvToBaseNotNeeded", "ConvFromXtoItselfNotNeeded", 
diff --git a/rod/pas2nim/pasparse.nim b/rod/pas2nim/pasparse.nim
index a84acc100..1db582f4e 100755
--- a/rod/pas2nim/pasparse.nim
+++ b/rod/pas2nim/pasparse.nim
@@ -436,7 +436,7 @@ proc primary(p: var TParser): PNode =
         parMessage(p, errIdentifierExpected, $p.tok)
     of pxHat: 
       var a = result
-      result = newNodeP(nkDerefExpr, p)
+      result = newNodeP(nkBracketExpr, p)
       addSon(result, a)
       getTok(p)
     of pxBracketLe: 
diff --git a/rod/semexprs.nim b/rod/semexprs.nim
index 5bd9bd2b8..8f8a1dc17 100755
--- a/rod/semexprs.nim
+++ b/rod/semexprs.nim
@@ -629,7 +629,7 @@ proc makeDeref(n: PNode): PNode =
     t = skipTypes(t.sons[0], {tyGenericInst})
   if t.kind in {tyPtr, tyRef}: 
     var a = result
-    result = newNodeIT(nkDerefExpr, n.info, t.sons[0])
+    result = newNodeIT(nkHiddenDeref, n.info, t.sons[0])
     addSon(result, a)
 
 proc builtinFieldAccess(c: PContext, n: PNode, flags: TExprFlags): PNode =
@@ -745,8 +745,23 @@ proc buildOverloadedSubscripts(n: PNode, inAsgn: bool): PNode =
   # now we know the operator
   result.sons[0] = newIdentNode(getIdent(opr), n.info)
   
+proc semDeref(c: PContext, n: PNode): PNode =
+  checkSonsLen(n, 1)
+  n.sons[0] = semExprWithType(c, n.sons[0])
+  result = n
+  var t = skipTypes(n.sons[0].typ, {tyGenericInst, tyVar})
+  case t.kind
+  of tyRef, tyPtr: n.typ = t.sons[0]
+  else: GlobalError(n.sons[0].info, errCircumNeedsPointer)
+  result = n
+  
 proc semSubscript(c: PContext, n: PNode, flags: TExprFlags): PNode =
   ## returns nil if not a built-in subscript operator;
+  if sonsLen(n) == 1: 
+    var x = semDeref(c, n)
+    result = newNodeIT(nkDerefExpr, x.info, x.typ)
+    result.add(x[0])
+    return
   checkMinSonsLen(n, 2)
   n.sons[0] = semExprWithType(c, n.sons[0], flags - {efAllowType})
   var arr = skipTypes(n.sons[0].typ, {tyGenericInst, tyVar, tyPtr, tyRef})
@@ -1041,14 +1056,8 @@ proc semExpr(c: PContext, n: PNode, flags: TExprFlags = {}): PNode =
   of nkBracket: result = semArrayConstr(c, n)
   of nkLambda: result = semLambda(c, n)
   of nkDerefExpr: 
-    checkSonsLen(n, 1)
-    n.sons[0] = semExprWithType(c, n.sons[0])
-    result = n
-    var t = skipTypes(n.sons[0].typ, {tyGenericInst, tyVar})
-    case t.kind
-    of tyRef, tyPtr: n.typ = t.sons[0]
-    else: GlobalError(n.sons[0].info, errCircumNeedsPointer)
-    result = n
+    Message(n.info, warnDerefDeprecated)
+    result = semDeref(c, n)
   of nkAddr: 
     result = n
     checkSonsLen(n, 1)
@@ -1056,7 +1065,7 @@ proc semExpr(c: PContext, n: PNode, flags: TExprFlags = {}): PNode =
     if isAssignable(n.sons[0]) != arLValue: 
       GlobalError(n.info, errExprHasNoAddress)
     n.typ = makePtrType(c, n.sons[0].typ)
-  of nkHiddenAddr, nkHiddenDeref: 
+  of nkHiddenAddr, nkHiddenDeref:
     checkSonsLen(n, 1)
     n.sons[0] = semExpr(c, n.sons[0], flags)
   of nkCast: result = semCast(c, n)
diff --git a/rod/transf.nim b/rod/transf.nim
index d2e6f8c69..db5146bb5 100755
--- a/rod/transf.nim
+++ b/rod/transf.nim
@@ -535,7 +535,7 @@ proc indirectAccess(a, b: PSym): PNode =
   # returns a^ .b as a node
   var x = newSymNode(a)
   var y = newSymNode(b)
-  var deref = newNodeI(nkDerefExpr, x.info)
+  var deref = newNodeI(nkHiddenDeref, x.info)
   deref.typ = x.typ.sons[0]
   addSon(deref, x)
   result = newNodeI(nkDotExpr, x.info)