summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorAraq <rumpf_a@web.de>2011-02-14 21:20:35 +0100
committerAraq <rumpf_a@web.de>2011-02-14 21:20:35 +0100
commit5c7e3efbc3bfe489d3233309449a43a0fdf51195 (patch)
treebf58507a204f474d9c8a209aa75b00683574308e
parent55c40746474cff452c09fa9c1244e3d0c7b3ad21 (diff)
downloadNim-5c7e3efbc3bfe489d3233309449a43a0fdf51195.tar.gz
bugfix: readline wrapper; bugfix: evaluation of type conversions
-rwxr-xr-xdoc/lib.txt11
-rwxr-xr-xdoc/nimrodc.txt2
-rw-r--r--lib/impure/rdstdin.nim1
-rw-r--r--lib/wrappers/readline/history.nim14
-rw-r--r--lib/wrappers/readline/readline.nim7
-rwxr-xr-xrod/evals.nim10
-rwxr-xr-xrod/semfold.nim45
-rwxr-xr-xrod/transf.nim2
-rwxr-xr-xtodo.txt1
-rwxr-xr-xweb/nimrod.ini4
10 files changed, 57 insertions, 40 deletions
diff --git a/doc/lib.txt b/doc/lib.txt
index cefb1a1fe..a082383da 100755
--- a/doc/lib.txt
+++ b/doc/lib.txt
@@ -271,6 +271,10 @@ Other
   This module provides an easy to use sockets-style 
   Nimrod interface to the OpenSSL library.
 
+* `rdstdin <rdstdin.html>`_
+  This module contains code for reading from `stdin`:idx:. On UNIX the GNU
+  readline library is wrapped and set up.
+
 
 Wrappers
 ========
@@ -339,6 +343,13 @@ UNIX specific
 * `xvlib <xvlib.html>`_
   Part of the wrapper for X11.
 
+* `readline <readline.html>`_
+  Part of the wrapper for the GNU readline library.
+* `history <history.html>`_
+  Part of the wrapper for the GNU readline library.
+* `rltypedefs <rltypedefs.html>`_
+  Part of the wrapper for the GNU readline library.
+
 
 Regular expressions
 -------------------
diff --git a/doc/nimrodc.txt b/doc/nimrodc.txt
index a712d109b..c8cbbaa73 100755
--- a/doc/nimrodc.txt
+++ b/doc/nimrodc.txt
@@ -238,7 +238,7 @@ The Nimrod compiler supports an `interactive mode`:idx:. This is also known as
 a `REPL`:idx: (*read eval print loop*). If Nimrod has been built with the 
 ``-d:useGnuReadline`` switch, it uses the GNU readline library for terminal
 input management. To start Nimrod in interactive mode use the command 
-``nimrod i``. To quit use the ``quit()` command. To determine whether an input
+``nimrod i``. To quit use the ``quit()`` command. To determine whether an input
 line is an incomplete statement to be continued these rules are used:
 
 1. The line ends with ``[-+*/\\<>!\?\|%&$@~,;:=#^]\s*$``.
diff --git a/lib/impure/rdstdin.nim b/lib/impure/rdstdin.nim
index 21e580f73..a1f0291bf 100644
--- a/lib/impure/rdstdin.nim
+++ b/lib/impure/rdstdin.nim
@@ -34,4 +34,3 @@ else:
   # disable auto-complete: 
   discard readline.bind_key('\t'.ord, readline.abort) 
 
-
diff --git a/lib/wrappers/readline/history.nim b/lib/wrappers/readline/history.nim
index 48e71e434..12dfa2707 100644
--- a/lib/wrappers/readline/history.nim
+++ b/lib/wrappers/readline/history.nim
@@ -19,15 +19,11 @@
 #
 
 {.deadCodeElim: on.}
-when defined(windows): 
-  const 
-    historyDll = "history.dll"
-elif defined(macosx): 
-  const 
-    historyDll = "libhistory.dynlib"
-else: 
-  const 
-    historyDll = "libhistory.so.6(|.0)"
+
+import readline
+
+const 
+  historyDll = readlineDll
 
 import times, rltypedefs
 
diff --git a/lib/wrappers/readline/readline.nim b/lib/wrappers/readline/readline.nim
index 96dab2049..d14171c46 100644
--- a/lib/wrappers/readline/readline.nim
+++ b/lib/wrappers/readline/readline.nim
@@ -21,13 +21,14 @@
 {.deadCodeElim: on.}
 when defined(windows): 
   const 
-    readlineDll = "readline.dll"
+    readlineDll* = "readline.dll"
 elif defined(macosx): 
+  # Mac OS X ships with 'libedit'
   const 
-    readlineDll = "libreadline.dynlib"
+    readlineDll* = "libedit(.2|.1|).dylib"
 else: 
   const 
-    readlineDll = "libreadline.so.6(|.0)"
+    readlineDll* = "libreadline.so.6(|.0)"
 ##  mangle "'TCommandFunc'" TCommandFunc
 ##  mangle TvcpFunc TvcpFunc
 
diff --git a/rod/evals.nim b/rod/evals.nim
index 1e2da01c4..bb32804fe 100755
--- a/rod/evals.nim
+++ b/rod/evals.nim
@@ -462,9 +462,13 @@ proc evalAddr(c: PEvalContext, n: PNode, flags: TEvalFlags): PNode =
   addSon(result, a)
 
 proc evalConv(c: PEvalContext, n: PNode): PNode = 
-  # hm, I cannot think of any conversions that need to be handled here...
-  result = evalAux(c, n.sons[1], {})
-  result.typ = n.typ
+  result = evalAux(c, n.sons[1], {efLValue})
+  if isSpecial(result): return
+  var a = result
+  result = foldConv(n, a)
+  if result == nil: 
+    # foldConv() cannot deal with everything that we want to do here:
+    result = a
 
 proc evalCheckedFieldAccess(c: PEvalContext, n: PNode, 
                             flags: TEvalFlags): PNode = 
diff --git a/rod/semfold.nim b/rod/semfold.nim
index 234d656f3..bae2a19bc 100755
--- a/rod/semfold.nim
+++ b/rod/semfold.nim
@@ -293,6 +293,28 @@ proc getAppType(n: PNode): PNode =
   else:
     result = newStrNodeT("console", n)
   
+proc foldConv*(n, a: PNode): PNode = 
+  case skipTypes(n.typ, abstractRange).kind
+  of tyInt..tyInt64: 
+    case skipTypes(a.typ, abstractRange).kind
+    of tyFloat..tyFloat64: result = newIntNodeT(system.toInt(getFloat(a)), n)
+    of tyChar: result = newIntNodeT(getOrdValue(a), n)
+    else: 
+      result = a
+      result.typ = n.typ
+  of tyFloat..tyFloat64: 
+    case skipTypes(a.typ, abstractRange).kind
+    of tyInt..tyInt64, tyEnum, tyBool, tyChar: 
+      result = newFloatNodeT(toFloat(int(getOrdValue(a))), n)
+    else: 
+      result = a
+      result.typ = n.typ
+  of tyOpenArray, tyProc: 
+    nil
+  else: 
+    result = a
+    result.typ = n.typ
+  
 proc getConstExpr(m: PSym, n: PNode): PNode = 
   result = nil
   case n.kind
@@ -422,27 +444,6 @@ proc getConstExpr(m: PSym, n: PNode): PNode =
   of nkHiddenStdConv, nkHiddenSubConv, nkConv, nkCast: 
     var a = getConstExpr(m, n.sons[1])
     if a == nil: return 
-    case skipTypes(n.typ, abstractRange).kind
-    of tyInt..tyInt64: 
-      case skipTypes(a.typ, abstractRange).kind
-      of tyFloat..tyFloat64: result = newIntNodeT(system.toInt(getFloat(a)), n)
-      of tyChar: result = newIntNodeT(getOrdValue(a), n)
-      else: 
-        result = a
-        result.typ = n.typ
-    of tyFloat..tyFloat64: 
-      case skipTypes(a.typ, abstractRange).kind
-      of tyInt..tyInt64, tyEnum, tyBool, tyChar: 
-        result = newFloatNodeT(toFloat(int(getOrdValue(a))), n)
-      else: 
-        result = a
-        result.typ = n.typ
-    of tyOpenArray, tyProc: 
-      nil
-    else: 
-      #n.sons[1] := a;
-      #result := n;
-      result = a
-      result.typ = n.typ
+    result = foldConv(n, a)
   else: 
     nil
diff --git a/rod/transf.nim b/rod/transf.nim
index 49369bb74..5b62c7f16 100755
--- a/rod/transf.nim
+++ b/rod/transf.nim
@@ -720,7 +720,7 @@ proc transform(c: PTransf, n: PNode): PTransNode =
     result = transformSons(c, n)
   var cnst = getConstExpr(c.module, PNode(result))
   if cnst != nil: 
-    result = PTransNode(cnst) # do not miss an optimization
+    result = PTransNode(cnst) # do not miss an optimization  
  
 proc processTransf(context: PPassContext, n: PNode): PNode = 
   # Note: For interactive mode we cannot call 'passes.skipCodegen' and skip
diff --git a/todo.txt b/todo.txt
index 92bf541f3..4dfc05312 100755
--- a/todo.txt
+++ b/todo.txt
@@ -1,4 +1,5 @@
 - 'suggest'
+- Bug: var x = 89; float(x)
 
 - thread support: threadvar on Windows seems broken; 
   add --deadlock_prevention:on|off switch
diff --git a/web/nimrod.ini b/web/nimrod.ini
index fc11c00d0..be650cec2 100755
--- a/web/nimrod.ini
+++ b/web/nimrod.ini
@@ -37,6 +37,7 @@ srcdoc: "pure/httpserver;pure/httpclient;pure/stmp;impure/ssl"
 srcdoc: "pure/ropes;pure/unidecode/unidecode;pure/xmldom;pure/xmldomparser"
 srcdoc: "pure/xmlparser;pure/htmlparser;pure/xmltree;pure/colors"
 srcdoc: "pure/json;pure/base64;pure/scgi;impure/graphics"
+srcdoc: "impure/rdstdin"
 
 webdoc: "wrappers/libcurl;pure/md5;wrappers/mysql;wrappers/iup"
 webdoc: "wrappers/sqlite3;wrappers/postgres;wrappers/tinyc"
@@ -49,4 +50,7 @@ webdoc: "wrappers/cairo"
 webdoc: "wrappers/gtk"
 webdoc: "windows"
 webdoc: "wrappers/x11;wrappers/opengl;wrappers/sdl;wrappers/lua"
+webdoc: "wrappers/readline/readline;wrappers/readline/history"
+webdoc: "wrappers/readline/rltypedefs"
+