summary refs log tree commit diff stats
path: root/rod
diff options
context:
space:
mode:
authorAraq <rumpf_a@web.de>2011-01-29 14:18:43 +0100
committerAraq <rumpf_a@web.de>2011-01-29 14:18:43 +0100
commit36accda8aaef4bd8daaf23e3eb369c2ca540f224 (patch)
tree39a28c97a100ce26d2bb6a9329811fcc83306a72 /rod
parentf46870fe1ce3a28ab44417effd1c684522568a8d (diff)
downloadNim-36accda8aaef4bd8daaf23e3eb369c2ca540f224.tar.gz
unary <; countup two type parameters; --recursivePath should work now
Diffstat (limited to 'rod')
-rwxr-xr-xrod/ast.nim3
-rwxr-xr-xrod/ccgexprs.nim3
-rwxr-xr-xrod/commands.nim17
-rwxr-xr-xrod/ecmasgen.nim4
-rwxr-xr-xrod/msgs.nim48
-rwxr-xr-xrod/semfold.nim1
6 files changed, 31 insertions, 45 deletions
diff --git a/rod/ast.nim b/rod/ast.nim
index 1d689deb9..50bd00444 100755
--- a/rod/ast.nim
+++ b/rod/ast.nim
@@ -300,7 +300,8 @@ type
   TSymKinds* = set[TSymKind]
 
   TMagic* = enum # symbols that require compiler magic:
-    mNone, mDefined, mDefinedInScope, mLow, mHigh, mSizeOf, mIs, mEcho, mSucc, 
+    mNone, mDefined, mDefinedInScope, mLow, mHigh, mSizeOf, mIs, mEcho, 
+    mUnaryLt, mSucc, 
     mPred, mInc, mDec, mOrd, mNew, mNewFinalize, mNewSeq, mLengthOpenArray, 
     mLengthStr, mLengthArray, mLengthSeq, mIncl, mExcl, mCard, mChr, mGCref, 
     mGCunref, mAddI, mSubI, mMulI, mDivI, mModI, mAddI64, mSubI64, mMulI64, 
diff --git a/rod/ccgexprs.nim b/rod/ccgexprs.nim
index 294b3e510..634dea886 100755
--- a/rod/ccgexprs.nim
+++ b/rod/ccgexprs.nim
@@ -1369,6 +1369,9 @@ proc genMagicExpr(p: BProc, e: PNode, d: var TLoc, op: TMagic) =
   of mAddi..mModi64: binaryArithOverflow(p, e, d, op)
   of mRepr: genRepr(p, e, d)
   of mSwap: genSwap(p, e, d)
+  of mUnaryLt: 
+    if not (optOverflowCheck in p.Options): unaryExpr(p, e, d, "$1 - 1")
+    else: unaryExpr(p, e, d, "#subInt($1, 1)")
   of mPred:
     # XXX: range checking?
     if not (optOverflowCheck in p.Options): binaryExpr(p, e, d, "$1 - $2")
diff --git a/rod/commands.nim b/rod/commands.nim
index 7a74cac7f..177b647d9 100755
--- a/rod/commands.nim
+++ b/rod/commands.nim
@@ -274,10 +274,18 @@ proc processPath(path: string): string =
   result = UnixToNativePath(path % ["nimrod", getPrefixDir(), "lib", libpath,
     "home", removeTrailingDirSep(os.getHomeDir())])
 
-proc addPath(path: string) = 
+proc addPath(path: string, info: TLineInfo) = 
   if not contains(options.searchPaths, path): 
     lists.PrependStr(options.searchPaths, path)
 
+proc addPathRec(dir: string, info: TLineInfo) =
+  for k,p in os.walkDir(dir):
+    if k == pcDir and '.' notin p:
+      addPathRec(p, info)
+      if not contains(options.searchPaths, p): 
+        liMessage(info, hintPath, p)
+        lists.PrependStr(options.searchPaths, p)
+
 proc processSwitch(switch, arg: string, pass: TCmdlinePass, info: TLineInfo) = 
   var 
     theOS: TSystemOS
@@ -286,13 +294,12 @@ proc processSwitch(switch, arg: string, pass: TCmdlinePass, info: TLineInfo) =
   case whichKeyword(switch)
   of wPath, wP: 
     expectArg(switch, arg, pass, info)
-    addPath(processPath(arg))
-    #discard lists.IncludeStr(options.searchPaths, path)
+    addPath(processPath(arg), info)
   of wRecursivePath:
     expectArg(switch, arg, pass, info)
     var path = processPath(arg)
-    for p in os.walkDirRec(path, {pcDir}): addPath(p)
-    addPath(path)
+    addPathRec(path, info)
+    addPath(path, info)
   of wOut, wO: 
     expectArg(switch, arg, pass, info)
     options.outFile = arg
diff --git a/rod/ecmasgen.nim b/rod/ecmasgen.nim
index ca3ab8ddb..b86b5dd59 100755
--- a/rod/ecmasgen.nim
+++ b/rod/ecmasgen.nim
@@ -1074,6 +1074,10 @@ proc genMagic(p: var TProc, n: PNode, r: var TCompRes) =
   of mAnd: genAnd(p, n.sons[1], n.sons[2], r)
   of mAddi..mStrToStr: arith(p, n, r, op)        #mRepr: genRepr(p, n, r);
   of mSwap: genSwap(p, n, r)
+  of mUnaryLt: 
+    # XXX: range checking?
+    if not (optOverflowCheck in p.Options): unaryExpr(p, n, r, "", "$1 - 1")
+    else: unaryExpr(p, n, r, "subInt", "subInt($1, 1)")
   of mPred: 
     # XXX: range checking?
     if not (optOverflowCheck in p.Options): binaryExpr(p, n, r, "", "$1 - $2")
diff --git a/rod/msgs.nim b/rod/msgs.nim
index e34631c90..9e826e127 100755
--- a/rod/msgs.nim
+++ b/rod/msgs.nim
@@ -1,46 +1,13 @@
 #
 #
 #           The Nimrod Compiler
-#        (c) Copyright 2010 Andreas Rumpf
+#        (c) Copyright 2011 Andreas Rumpf
 #
 #    See the file "copying.txt", included in this
 #    distribution, for details about the copyright.
 #
 
-import #[[[cog
-       #from string import replace
-       #enum = "type\n  TMsgKind = (\n"
-       #msgs = "const\n  MsgKindToStr: array [TMsgKind] of string = (\n"
-       #warns = "const\n  WarningsToStr: array [0..%d] of string = (\n"
-       #hints = "const\n  HintsToStr: array [0..%d] of string = (\n"
-       #w = 0 # counts the warnings
-       #h = 0 # counts the hints
-       #
-       #for elem in eval(open('data/messages.yml').read()):
-       #  for key, val in elem.items():
-       #    enum = enum + '    %s,\n' % key
-       #    v = replace(val, "'", "''")
-       #    if key[0:4] == 'warn':
-       #      msgs = msgs +  "    '%s [%s]',\n" % (v, key[4:])
-       #      warns = warns + "    '%s',\n" % key[4:]
-       #      w = w + 1
-       #    elif key[0:4] == 'hint':
-       #      msgs = msgs + "    '%s [%s]',\n" % (v, key[4:])
-       #      hints = hints + "    '%s',\n" % key[4:]
-       #      h = h + 1
-       #    else:
-       #      msgs = msgs + "    '%s',\n" % v
-       #
-       #enum = enum[:-2] + ');\n\n'
-       #msgs = msgs[:-2] + '\n  );\n'
-       #warns = (warns[:-2] + '\n  );\n') % (w-1)
-       #hints = (hints[:-2] + '\n  );\n') % (h-1)
-       #
-       #cog.out(enum)
-       #cog.out(msgs)
-       #cog.out(warns)
-       #cog.out(hints)
-       #]]]
+import
   options, strutils, os
 
 type 
@@ -126,7 +93,7 @@ type
     warnXisPassedToProcVar, warnUser, hintSuccess, hintSuccessX, 
     hintLineTooLong, hintXDeclaredButNotUsed, hintConvToBaseNotNeeded, 
     hintConvFromXtoItselfNotNeeded, hintExprAlwaysX, hintQuitCalled, 
-    hintProcessing, hintCodeBegin, hintCodeEnd, hintConf, hintUser
+    hintProcessing, hintCodeBegin, hintCodeEnd, hintConf, hintPath, hintUser
 
 const 
   MsgKindToStr*: array[TMsgKind, string] = ["unknown error", 
@@ -274,7 +241,9 @@ const
     "expression evaluates always to \'$1\' [ExprAlwaysX]", 
     "quit() called [QuitCalled]", "$1 [Processing]", 
     "generated code listing: [CodeBegin]", "end of listing [CodeEnd]", 
-    "used config file \'$1\' [Conf]", "$1 [User]"]
+    "used config file \'$1\' [Conf]", 
+    "added path: '$1' [Path]",
+    "$1 [User]"]
 
 const 
   WarningsToStr*: array[0..14, string] = ["CannotOpenFile", "OctalEscape", 
@@ -284,10 +253,11 @@ const
     "CommentXIgnored", "XisPassedToProcVar", "User"]
 
 const 
-  HintsToStr*: array[0..12, string] = ["Success", "SuccessX", "LineTooLong", 
+  HintsToStr*: array[0..13, string] = ["Success", "SuccessX", "LineTooLong", 
     "XDeclaredButNotUsed", "ConvToBaseNotNeeded", "ConvFromXtoItselfNotNeeded", 
     "ExprAlwaysX", "QuitCalled", "Processing", "CodeBegin", "CodeEnd", "Conf", 
-    "User"]                   #[[[end]]]
+    "Path",
+    "User"]
 
 const 
   fatalMin* = errUnknown
diff --git a/rod/semfold.nim b/rod/semfold.nim
index 91d6ea3bc..a61ad0f8e 100755
--- a/rod/semfold.nim
+++ b/rod/semfold.nim
@@ -95,6 +95,7 @@ proc evalOp(m: TMagic, n, a, b, c: PNode): PNode =
   of mToU8: result = newIntNodeT(getInt(a) and 0x000000FF, n)
   of mToU16: result = newIntNodeT(getInt(a) and 0x0000FFFF, n)
   of mToU32: result = newIntNodeT(getInt(a) and 0x00000000FFFFFFFF'i64, n)
+  of mUnaryLt: result = newIntNodeT(getOrdValue(a) - 1, n)
   of mSucc: result = newIntNodeT(getOrdValue(a) + getInt(b), n)
   of mPred: result = newIntNodeT(getOrdValue(a) - getInt(b), n)
   of mAddI, mAddI64: result = newIntNodeT(getInt(a) + getInt(b), n)