bugfix: readline wrapper; bugfix: evaluation of type conversions
This commit is contained in:
parent
55c4074647
commit
5c7e3efbc3
10 changed files with 57 additions and 40 deletions
11
doc/lib.txt
11
doc/lib.txt
|
|
@ -271,6 +271,10 @@ Other
|
||||||
This module provides an easy to use sockets-style
|
This module provides an easy to use sockets-style
|
||||||
Nimrod interface to the OpenSSL library.
|
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
|
Wrappers
|
||||||
========
|
========
|
||||||
|
|
@ -339,6 +343,13 @@ UNIX specific
|
||||||
* `xvlib <xvlib.html>`_
|
* `xvlib <xvlib.html>`_
|
||||||
Part of the wrapper for X11.
|
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
|
Regular expressions
|
||||||
-------------------
|
-------------------
|
||||||
|
|
|
||||||
|
|
@ -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
|
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
|
``-d:useGnuReadline`` switch, it uses the GNU readline library for terminal
|
||||||
input management. To start Nimrod in interactive mode use the command
|
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:
|
line is an incomplete statement to be continued these rules are used:
|
||||||
|
|
||||||
1. The line ends with ``[-+*/\\<>!\?\|%&$@~,;:=#^]\s*$``.
|
1. The line ends with ``[-+*/\\<>!\?\|%&$@~,;:=#^]\s*$``.
|
||||||
|
|
|
||||||
|
|
@ -34,4 +34,3 @@ else:
|
||||||
# disable auto-complete:
|
# disable auto-complete:
|
||||||
discard readline.bind_key('\t'.ord, readline.abort)
|
discard readline.bind_key('\t'.ord, readline.abort)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -19,15 +19,11 @@
|
||||||
#
|
#
|
||||||
|
|
||||||
{.deadCodeElim: on.}
|
{.deadCodeElim: on.}
|
||||||
when defined(windows):
|
|
||||||
const
|
import readline
|
||||||
historyDll = "history.dll"
|
|
||||||
elif defined(macosx):
|
const
|
||||||
const
|
historyDll = readlineDll
|
||||||
historyDll = "libhistory.dynlib"
|
|
||||||
else:
|
|
||||||
const
|
|
||||||
historyDll = "libhistory.so.6(|.0)"
|
|
||||||
|
|
||||||
import times, rltypedefs
|
import times, rltypedefs
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -21,13 +21,14 @@
|
||||||
{.deadCodeElim: on.}
|
{.deadCodeElim: on.}
|
||||||
when defined(windows):
|
when defined(windows):
|
||||||
const
|
const
|
||||||
readlineDll = "readline.dll"
|
readlineDll* = "readline.dll"
|
||||||
elif defined(macosx):
|
elif defined(macosx):
|
||||||
|
# Mac OS X ships with 'libedit'
|
||||||
const
|
const
|
||||||
readlineDll = "libreadline.dynlib"
|
readlineDll* = "libedit(.2|.1|).dylib"
|
||||||
else:
|
else:
|
||||||
const
|
const
|
||||||
readlineDll = "libreadline.so.6(|.0)"
|
readlineDll* = "libreadline.so.6(|.0)"
|
||||||
## mangle "'TCommandFunc'" TCommandFunc
|
## mangle "'TCommandFunc'" TCommandFunc
|
||||||
## mangle TvcpFunc TvcpFunc
|
## mangle TvcpFunc TvcpFunc
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -462,9 +462,13 @@ proc evalAddr(c: PEvalContext, n: PNode, flags: TEvalFlags): PNode =
|
||||||
addSon(result, a)
|
addSon(result, a)
|
||||||
|
|
||||||
proc evalConv(c: PEvalContext, n: PNode): PNode =
|
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], {efLValue})
|
||||||
result = evalAux(c, n.sons[1], {})
|
if isSpecial(result): return
|
||||||
result.typ = n.typ
|
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,
|
proc evalCheckedFieldAccess(c: PEvalContext, n: PNode,
|
||||||
flags: TEvalFlags): PNode =
|
flags: TEvalFlags): PNode =
|
||||||
|
|
|
||||||
|
|
@ -293,6 +293,28 @@ proc getAppType(n: PNode): PNode =
|
||||||
else:
|
else:
|
||||||
result = newStrNodeT("console", n)
|
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 =
|
proc getConstExpr(m: PSym, n: PNode): PNode =
|
||||||
result = nil
|
result = nil
|
||||||
case n.kind
|
case n.kind
|
||||||
|
|
@ -422,27 +444,6 @@ proc getConstExpr(m: PSym, n: PNode): PNode =
|
||||||
of nkHiddenStdConv, nkHiddenSubConv, nkConv, nkCast:
|
of nkHiddenStdConv, nkHiddenSubConv, nkConv, nkCast:
|
||||||
var a = getConstExpr(m, n.sons[1])
|
var a = getConstExpr(m, n.sons[1])
|
||||||
if a == nil: return
|
if a == nil: return
|
||||||
case skipTypes(n.typ, abstractRange).kind
|
result = foldConv(n, a)
|
||||||
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
|
|
||||||
else:
|
else:
|
||||||
nil
|
nil
|
||||||
|
|
|
||||||
|
|
@ -720,7 +720,7 @@ proc transform(c: PTransf, n: PNode): PTransNode =
|
||||||
result = transformSons(c, n)
|
result = transformSons(c, n)
|
||||||
var cnst = getConstExpr(c.module, PNode(result))
|
var cnst = getConstExpr(c.module, PNode(result))
|
||||||
if cnst != nil:
|
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 =
|
proc processTransf(context: PPassContext, n: PNode): PNode =
|
||||||
# Note: For interactive mode we cannot call 'passes.skipCodegen' and skip
|
# Note: For interactive mode we cannot call 'passes.skipCodegen' and skip
|
||||||
|
|
|
||||||
1
todo.txt
1
todo.txt
|
|
@ -1,4 +1,5 @@
|
||||||
- 'suggest'
|
- 'suggest'
|
||||||
|
- Bug: var x = 89; float(x)
|
||||||
|
|
||||||
- thread support: threadvar on Windows seems broken;
|
- thread support: threadvar on Windows seems broken;
|
||||||
add --deadlock_prevention:on|off switch
|
add --deadlock_prevention:on|off switch
|
||||||
|
|
|
||||||
|
|
@ -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/ropes;pure/unidecode/unidecode;pure/xmldom;pure/xmldomparser"
|
||||||
srcdoc: "pure/xmlparser;pure/htmlparser;pure/xmltree;pure/colors"
|
srcdoc: "pure/xmlparser;pure/htmlparser;pure/xmltree;pure/colors"
|
||||||
srcdoc: "pure/json;pure/base64;pure/scgi;impure/graphics"
|
srcdoc: "pure/json;pure/base64;pure/scgi;impure/graphics"
|
||||||
|
srcdoc: "impure/rdstdin"
|
||||||
|
|
||||||
webdoc: "wrappers/libcurl;pure/md5;wrappers/mysql;wrappers/iup"
|
webdoc: "wrappers/libcurl;pure/md5;wrappers/mysql;wrappers/iup"
|
||||||
webdoc: "wrappers/sqlite3;wrappers/postgres;wrappers/tinyc"
|
webdoc: "wrappers/sqlite3;wrappers/postgres;wrappers/tinyc"
|
||||||
|
|
@ -49,4 +50,7 @@ webdoc: "wrappers/cairo"
|
||||||
webdoc: "wrappers/gtk"
|
webdoc: "wrappers/gtk"
|
||||||
webdoc: "windows"
|
webdoc: "windows"
|
||||||
webdoc: "wrappers/x11;wrappers/opengl;wrappers/sdl;wrappers/lua"
|
webdoc: "wrappers/x11;wrappers/opengl;wrappers/sdl;wrappers/lua"
|
||||||
|
webdoc: "wrappers/readline/readline;wrappers/readline/history"
|
||||||
|
webdoc: "wrappers/readline/rltypedefs"
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue