Integrating my changes, mostly minor/cosmetic fixes; plus a big Windows lib update
This commit is contained in:
parent
227b76c342
commit
286e5958d6
37 changed files with 30552 additions and 30077 deletions
|
|
@ -10,7 +10,7 @@ Advanced options:
|
||||||
--warning[X]:on|off turn specific warning X on|off
|
--warning[X]:on|off turn specific warning X on|off
|
||||||
--hints:on|off turn all hints on|off
|
--hints:on|off turn all hints on|off
|
||||||
--hint[X]:on|off turn specific hint X on|off
|
--hint[X]:on|off turn specific hint X on|off
|
||||||
--lib:PATH set the system library path
|
--lib:PATH set the path to the system.nim library
|
||||||
-c, --compileOnly compile only; do not assemble or link
|
-c, --compileOnly compile only; do not assemble or link
|
||||||
--noLinking compile but do not link
|
--noLinking compile but do not link
|
||||||
--noMain do not generate a main procedure
|
--noMain do not generate a main procedure
|
||||||
|
|
|
||||||
|
|
@ -21,7 +21,7 @@ values is vulnerable to the famous `SQL injection attack`:idx:\:
|
||||||
username: string
|
username: string
|
||||||
|
|
||||||
db.query("SELECT FROM users WHERE name = '$1'" % username)
|
db.query("SELECT FROM users WHERE name = '$1'" % username)
|
||||||
# Horrible security whole, but the compiler does not mind!
|
# Horrible security hole, but the compiler does not mind!
|
||||||
|
|
||||||
This can be avoided by distinguishing strings that contain SQL from strings
|
This can be avoided by distinguishing strings that contain SQL from strings
|
||||||
that don't. Abstract types provide a means to introduce a new string type
|
that don't. Abstract types provide a means to introduce a new string type
|
||||||
|
|
@ -113,7 +113,7 @@ it generates the trivial implementation for us:
|
||||||
proc `*` (x: int, y: TDollar): TDollar {.borrow.}
|
proc `*` (x: int, y: TDollar): TDollar {.borrow.}
|
||||||
proc `div` (x: TDollar, y: int): TDollar {.borrow.}
|
proc `div` (x: TDollar, y: int): TDollar {.borrow.}
|
||||||
|
|
||||||
The ``borrow`` pragma makes the compiler use the same implementation as
|
The ``borrow`` pragma makes the compiler to use the same implementation as
|
||||||
the proc that deals with the abstract type's base type, so no code is
|
the proc that deals with the abstract type's base type, so no code is
|
||||||
generated.
|
generated.
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -29,7 +29,7 @@ No, it really can always be evaluated. The code generator should transform
|
||||||
Raise statement
|
Raise statement
|
||||||
===============
|
===============
|
||||||
|
|
||||||
It is impractical to consider ``raise`` a statement with side effects.
|
It is impractical to consider ``raise`` as a statement with side effects.
|
||||||
|
|
||||||
|
|
||||||
Solution
|
Solution
|
||||||
|
|
|
||||||
|
|
@ -23,7 +23,7 @@ available for the debugger.
|
||||||
|
|
||||||
If you start your program the debugger will immediately show
|
If you start your program the debugger will immediately show
|
||||||
a prompt on the console. You can now enter a command. The next sections
|
a prompt on the console. You can now enter a command. The next sections
|
||||||
deal with the possible commands. As usual for Nimrod for all commands
|
deal with the possible commands. As usual in Nimrod in all commands
|
||||||
underscores and case do not matter. Optional components of a command
|
underscores and case do not matter. Optional components of a command
|
||||||
are listed in brackets ``[...]`` here.
|
are listed in brackets ``[...]`` here.
|
||||||
|
|
||||||
|
|
|
||||||
12
doc/lib.txt
12
doc/lib.txt
|
|
@ -39,8 +39,8 @@ String handling
|
||||||
---------------
|
---------------
|
||||||
|
|
||||||
* `strutils <strutils.html>`_
|
* `strutils <strutils.html>`_
|
||||||
This module contains common string handling operations like converting a
|
This module contains common string handling operations like changing
|
||||||
string into uppercase, splitting a string into substrings, searching for
|
case of a string, splitting a string into substrings, searching for
|
||||||
substrings, replacing substrings.
|
substrings, replacing substrings.
|
||||||
|
|
||||||
* `parseutils <parseutils.html>`_
|
* `parseutils <parseutils.html>`_
|
||||||
|
|
@ -152,7 +152,7 @@ Parsers
|
||||||
The ``parsexml`` module implements a simple high performance XML/HTML parser.
|
The ``parsexml`` module implements a simple high performance XML/HTML parser.
|
||||||
The only encoding that is supported is UTF-8. The parser has been designed
|
The only encoding that is supported is UTF-8. The parser has been designed
|
||||||
to be somewhat error correcting, so that even some "wild HTML" found on the
|
to be somewhat error correcting, so that even some "wild HTML" found on the
|
||||||
web can be parsed with it.
|
Web can be parsed with it.
|
||||||
|
|
||||||
* `parsecsv <parsecsv.html>`_
|
* `parsecsv <parsecsv.html>`_
|
||||||
The ``parsecsv`` module implements a simple high performance CSV parser.
|
The ``parsecsv`` module implements a simple high performance CSV parser.
|
||||||
|
|
@ -223,7 +223,7 @@ Impure libraries
|
||||||
|
|
||||||
* `web <web.html>`_
|
* `web <web.html>`_
|
||||||
This module contains simple high-level procedures for dealing with the
|
This module contains simple high-level procedures for dealing with the
|
||||||
web like loading the contents of a web page from an URL.
|
Web like loading the contents of a Web page from an URL.
|
||||||
|
|
||||||
|
|
||||||
Database support
|
Database support
|
||||||
|
|
@ -234,11 +234,11 @@ Database support
|
||||||
for other databases too.
|
for other databases too.
|
||||||
|
|
||||||
* `db_mysql <db_mysql.html>`_
|
* `db_mysql <db_mysql.html>`_
|
||||||
A higher level mySQL database wrapper. The same interface is implemented
|
A higher level MySQL database wrapper. The same interface is implemented
|
||||||
for other databases too.
|
for other databases too.
|
||||||
|
|
||||||
* `db_sqlite <db_sqlite.html>`_
|
* `db_sqlite <db_sqlite.html>`_
|
||||||
A higher level mySQL database wrapper. The same interface is implemented
|
A higher level SQLite database wrapper. The same interface is implemented
|
||||||
for other databases too.
|
for other databases too.
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1755,14 +1755,13 @@ value that is used if the caller does not provide a value for this parameter.
|
||||||
The syntax is::
|
The syntax is::
|
||||||
|
|
||||||
param ::= symbol (comma symbol)* (':' typeDesc ['=' expr] | '=' expr)
|
param ::= symbol (comma symbol)* (':' typeDesc ['=' expr] | '=' expr)
|
||||||
paramList ::= ['(' [param (comma param)*] optPar ')'] [':' typeDesc]
|
paramList ::= ['(' [param (comma param)*] [SAD] ')'] [':' typeDesc]
|
||||||
|
|
||||||
genericParam ::= symbol [':' typeDesc] ['=' expr]
|
genericParam ::= symbol [':' typeDesc] ['=' expr]
|
||||||
genericParams ::= '[' genericParam (comma genericParam)* optPar ']'
|
genericParams ::= '[' genericParam (comma genericParam)* [SAD] ']'
|
||||||
|
|
||||||
routineDecl := symbol ['*'] [genericParams] paramList [pragma] ['=' stmt]
|
|
||||||
procDecl ::= 'proc' routineDecl
|
|
||||||
|
|
||||||
|
procDecl ::= 'proc' symbol ['*'] [genericParams] paramList [pragma]
|
||||||
|
['=' stmt]
|
||||||
|
|
||||||
If the ``= stmt`` part is missing, it is a `forward`:idx: declaration. If
|
If the ``= stmt`` part is missing, it is a `forward`:idx: declaration. If
|
||||||
the proc returns a value, the procedure body can access an implicitly declared
|
the proc returns a value, the procedure body can access an implicitly declared
|
||||||
|
|
@ -2460,7 +2459,7 @@ Syntax::
|
||||||
|
|
||||||
pragma ::= '{.' optInd (colonExpr [comma])* [SAD] ('.}' | '}')
|
pragma ::= '{.' optInd (colonExpr [comma])* [SAD] ('.}' | '}')
|
||||||
|
|
||||||
Pragmas are Nimrod's method to give the compiler additional information/
|
Pragmas are Nimrod's method to give the compiler additional information /
|
||||||
commands without introducing a massive number of new keywords. Pragmas are
|
commands without introducing a massive number of new keywords. Pragmas are
|
||||||
processed on the fly during semantic checking. Pragmas are enclosed in the
|
processed on the fly during semantic checking. Pragmas are enclosed in the
|
||||||
special ``{.`` and ``.}`` curly brackets. Pragmas are also often used as a
|
special ``{.`` and ``.}`` curly brackets. Pragmas are also often used as a
|
||||||
|
|
|
||||||
|
|
@ -43,7 +43,7 @@ The default configuration file is ``nimrod.cfg``. The ``nimrod`` executable
|
||||||
looks for it in the following directories (in this order):
|
looks for it in the following directories (in this order):
|
||||||
|
|
||||||
1. ``/home/$user/.config/nimrod.cfg`` (UNIX) or ``%APPDATA%/nimrod.cfg`` (Windows)
|
1. ``/home/$user/.config/nimrod.cfg`` (UNIX) or ``%APPDATA%/nimrod.cfg`` (Windows)
|
||||||
2. ``$nimrod/config/nimrod.cfg`` (UNIX, Windows)
|
2. ``$nimrod/config/nimrod.cfg`` (UNIX), ``%NIMROD%/config/nimrod.cfg`` (Windows)
|
||||||
3. ``/etc/nimrod.cfg`` (UNIX)
|
3. ``/etc/nimrod.cfg`` (UNIX)
|
||||||
|
|
||||||
The search stops as soon as a configuration file has been found. The reading
|
The search stops as soon as a configuration file has been found. The reading
|
||||||
|
|
@ -52,7 +52,7 @@ of ``nimrod.cfg`` can be suppressed by the ``--skipCfg`` command line option.
|
||||||
**Note:** The *project file name* is the name of the ``.nim`` file that is
|
**Note:** The *project file name* is the name of the ``.nim`` file that is
|
||||||
passed as a command line argument to the compiler.
|
passed as a command line argument to the compiler.
|
||||||
|
|
||||||
Configuration settings can be overwritten in a project specific
|
Configuration settings can be overwritten individually in a project specific
|
||||||
configuration file that is read automatically. This specific file has to
|
configuration file that is read automatically. This specific file has to
|
||||||
be in the same directory as the project and be of the same name, except
|
be in the same directory as the project and be of the same name, except
|
||||||
that its extension should be ``.cfg``.
|
that its extension should be ``.cfg``.
|
||||||
|
|
|
||||||
|
|
@ -60,8 +60,8 @@ Enumerated lists
|
||||||
*Enumerated lists*
|
*Enumerated lists*
|
||||||
|
|
||||||
|
|
||||||
Defintion lists
|
Definition lists
|
||||||
===============
|
================
|
||||||
|
|
||||||
Save this code to the file "greeting.nim". Now compile and run it:
|
Save this code to the file "greeting.nim". Now compile and run it:
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,3 @@
|
||||||
# Hallo world program
|
# Hello world program
|
||||||
|
|
||||||
echo "Hallo world!"
|
echo "Hello world!"
|
||||||
|
|
|
||||||
|
|
@ -29,7 +29,7 @@ Iup.SetAttribute(box, "GAP", "10")
|
||||||
|
|
||||||
var dlg = Iup.Dialog(box)
|
var dlg = Iup.Dialog(box)
|
||||||
Iup.SetAttribute(dlg, "TITLE", "IupTabs")
|
Iup.SetAttribute(dlg, "TITLE", "IupTabs")
|
||||||
Iup.SetAttribute(dlg, "SIZE", "200x80")
|
Iup.SetAttribute(dlg, "SIZE", "200x100")
|
||||||
|
|
||||||
discard ShowXY(dlg, IUP_CENTER, IUP_CENTER)
|
discard ShowXY(dlg, IUP_CENTER, IUP_CENTER)
|
||||||
discard MainLoop()
|
discard MainLoop()
|
||||||
|
|
|
||||||
|
|
@ -6,4 +6,4 @@ import
|
||||||
#proc MessageBox(hWnd: int, lpText, lpCaption: CString, uType: uint): int
|
#proc MessageBox(hWnd: int, lpText, lpCaption: CString, uType: uint): int
|
||||||
# {stdcall, import: "MessageBox", header: "<windows.h>"}
|
# {stdcall, import: "MessageBox", header: "<windows.h>"}
|
||||||
|
|
||||||
discard MessageBox(0, "Hallo World!", "Nimrod GUI application", 0)
|
discard MessageBox(0, "Hello World!", "Nimrod GUI Application", 0)
|
||||||
|
|
|
||||||
|
|
@ -26,10 +26,10 @@ type
|
||||||
proc on_about_menu_item_activate(menuItem: PGtkMenuItem,
|
proc on_about_menu_item_activate(menuItem: PGtkMenuItem,
|
||||||
e: var TMyTextEditor) {.cdecl.} =
|
e: var TMyTextEditor) {.cdecl.} =
|
||||||
gtk_show_about_dialog(e.window,
|
gtk_show_about_dialog(e.window,
|
||||||
"comments", "A fast and leight-weight IDE for Nimrod",
|
"comments", "A fast and lightweight IDE for Nimrod",
|
||||||
"copyright", "Copyright \xc2\xa9 2008 Andreas Rumpf",
|
"copyright", "Copyright \xc2\xa9 2010 Andreas Rumpf",
|
||||||
"version", "0.1",
|
"version", "0.1",
|
||||||
"website", "http://nimrod.ethexor.com",
|
"website", "http://force7.de/nimrod/",
|
||||||
"program-name", "Nimrod IDE",
|
"program-name", "Nimrod IDE",
|
||||||
nil)
|
nil)
|
||||||
|
|
||||||
|
|
@ -70,7 +70,7 @@ proc write_file(e: var TMyTextEditor, filename: string) =
|
||||||
buffer: PGtkTextBuffer
|
buffer: PGtkTextBuffer
|
||||||
start, ende: TGtkTextIter
|
start, ende: TGtkTextIter
|
||||||
# add Saving message to status bar and ensure GUI is current
|
# add Saving message to status bar and ensure GUI is current
|
||||||
gtk_statusbar_push(e.statusbar, e.statusbar_context_id, "Saving....")
|
gtk_statusbar_push(e.statusbar, e.statusbar_context_id, "Saving...")
|
||||||
while gtk_events_pending(): gtk_main_iteration()
|
while gtk_events_pending(): gtk_main_iteration()
|
||||||
|
|
||||||
# disable text view and get contents of buffer
|
# disable text view and get contents of buffer
|
||||||
|
|
|
||||||
|
|
@ -32,10 +32,10 @@ proc onWindowDestroy(obj: PGtkObject, event: PGdkEvent,
|
||||||
|
|
||||||
proc onAboutMenuItemActivate(menuItem: PGtkMenuItem, e: PEditor) {.cdecl.} =
|
proc onAboutMenuItemActivate(menuItem: PGtkMenuItem, e: PEditor) {.cdecl.} =
|
||||||
gtkShowAboutDialog(e.window,
|
gtkShowAboutDialog(e.window,
|
||||||
"comments", "A fast and leight-weight IDE for Nimrod",
|
"comments", "A fast and lightweight IDE for Nimrod",
|
||||||
"copyright", "Copyright \xc2\xa9 2009 Andreas Rumpf",
|
"copyright", "Copyright \xc2\xa9 2010 Andreas Rumpf",
|
||||||
"version", "0.1",
|
"version", "0.1",
|
||||||
"website", "http://nimrod.ethexor.com",
|
"website", "http://force7.de/nimrod/",
|
||||||
"program-name", "Nimrod IDE",
|
"program-name", "Nimrod IDE",
|
||||||
nil)
|
nil)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,7 @@
|
||||||
## var counter = 0
|
## var counter = 0
|
||||||
## proc handleRequest(client: TSocket, path, query: string): bool {.procvar.} =
|
## proc handleRequest(client: TSocket, path, query: string): bool {.procvar.} =
|
||||||
## inc(counter)
|
## inc(counter)
|
||||||
## client.send("Hallo for the $#th time." % $counter & wwwNL)
|
## client.send("Hello for the $#th time." % $counter & wwwNL)
|
||||||
## return false # do not stop processing
|
## return false # do not stop processing
|
||||||
##
|
##
|
||||||
## run(handleRequest, TPort(80))
|
## run(handleRequest, TPort(80))
|
||||||
|
|
@ -60,7 +60,7 @@ proc notFound(client: TSocket) =
|
||||||
send(client, "<html><title>Not Found</title>" & wwwNL)
|
send(client, "<html><title>Not Found</title>" & wwwNL)
|
||||||
send(client, "<body><p>The server could not fulfill" & wwwNL)
|
send(client, "<body><p>The server could not fulfill" & wwwNL)
|
||||||
send(client, "your request because the resource specified" & wwwNL)
|
send(client, "your request because the resource specified" & wwwNL)
|
||||||
send(client, "is unavailable or nonexistent." & wwwNL)
|
send(client, "is unavailable or nonexistent.</p>" & wwwNL)
|
||||||
send(client, "</body></html>" & wwwNL)
|
send(client, "</body></html>" & wwwNL)
|
||||||
|
|
||||||
proc unimplemented(client: TSocket) =
|
proc unimplemented(client: TSocket) =
|
||||||
|
|
@ -69,7 +69,7 @@ proc unimplemented(client: TSocket) =
|
||||||
sendTextContentType(client)
|
sendTextContentType(client)
|
||||||
send(client, "<html><head><title>Method Not Implemented" &
|
send(client, "<html><head><title>Method Not Implemented" &
|
||||||
"</title></head>" &
|
"</title></head>" &
|
||||||
"<body><p>HTTP request method not supported." &
|
"<body><p>HTTP request method not supported.</p>" &
|
||||||
"</body></HTML>" & wwwNL)
|
"</body></HTML>" & wwwNL)
|
||||||
|
|
||||||
# ----------------- file serving ---------------------------------------------
|
# ----------------- file serving ---------------------------------------------
|
||||||
|
|
@ -196,7 +196,7 @@ type
|
||||||
|
|
||||||
proc open*(s: var TServer, port = TPort(80)) =
|
proc open*(s: var TServer, port = TPort(80)) =
|
||||||
## creates a new server at port `port`. If ``port == 0`` a free port is
|
## creates a new server at port `port`. If ``port == 0`` a free port is
|
||||||
## aquired that can be accessed later by the ``port`` proc.
|
## acquired that can be accessed later by the ``port`` proc.
|
||||||
s.socket = socket(AF_INET)
|
s.socket = socket(AF_INET)
|
||||||
if s.socket == InvalidSocket: OSError()
|
if s.socket == InvalidSocket: OSError()
|
||||||
bindAddr(s.socket, port)
|
bindAddr(s.socket, port)
|
||||||
|
|
@ -211,7 +211,7 @@ proc open*(s: var TServer, port = TPort(80)) =
|
||||||
s.query = ""
|
s.query = ""
|
||||||
|
|
||||||
proc port*(s: var TServer): TPort =
|
proc port*(s: var TServer): TPort =
|
||||||
## get the port number the server has aquired.
|
## get the port number the server has acquired.
|
||||||
result = s.port
|
result = s.port
|
||||||
|
|
||||||
proc next*(s: var TServer) =
|
proc next*(s: var TServer) =
|
||||||
|
|
@ -252,7 +252,7 @@ when isMainModule:
|
||||||
var counter = 0
|
var counter = 0
|
||||||
proc handleRequest(client: TSocket, path, query: string): bool {.procvar.} =
|
proc handleRequest(client: TSocket, path, query: string): bool {.procvar.} =
|
||||||
inc(counter)
|
inc(counter)
|
||||||
client.send("Hallo, Andreas for the $#th time." % $counter & wwwNL)
|
client.send("Hello, Andreas, for the $#th time." % $counter & wwwNL)
|
||||||
return false # do not stop processing
|
return false # do not stop processing
|
||||||
|
|
||||||
run(handleRequest, TPort(80))
|
run(handleRequest, TPort(80))
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,7 @@
|
||||||
|
|
||||||
## This module contains various string utility routines.
|
## This module contains various string utility routines.
|
||||||
## See the module `regexprs` for regular expression support.
|
## See the module `regexprs` for regular expression support.
|
||||||
|
## See the module `pegs` for PEG support.
|
||||||
|
|
||||||
import parseutils
|
import parseutils
|
||||||
|
|
||||||
|
|
@ -30,6 +31,9 @@ const
|
||||||
Digits* = {'0'..'9'}
|
Digits* = {'0'..'9'}
|
||||||
## the set of digits
|
## the set of digits
|
||||||
|
|
||||||
|
HexDigits* = {'0'..'9', 'A'..'F', 'a'..'f'}
|
||||||
|
## the set of hexadecimal digits
|
||||||
|
|
||||||
IdentChars* = {'a'..'z', 'A'..'Z', '0'..'9', '_'}
|
IdentChars* = {'a'..'z', 'A'..'Z', '0'..'9', '_'}
|
||||||
## the set of characters an identifier can consist of
|
## the set of characters an identifier can consist of
|
||||||
|
|
||||||
|
|
@ -432,7 +436,7 @@ proc findNormalized(x: string, inArray: openarray[string]): int =
|
||||||
while i < high(inArray):
|
while i < high(inArray):
|
||||||
if cmpIgnoreStyle(x, inArray[i]) == 0: return i
|
if cmpIgnoreStyle(x, inArray[i]) == 0: return i
|
||||||
inc(i, 2) # incrementing by 1 would probably result in a
|
inc(i, 2) # incrementing by 1 would probably result in a
|
||||||
# security hole ...
|
# security hole...
|
||||||
return -1
|
return -1
|
||||||
|
|
||||||
proc addf(s: var string, formatstr: string, a: openarray[string]) =
|
proc addf(s: var string, formatstr: string, a: openarray[string]) =
|
||||||
|
|
@ -453,7 +457,7 @@ proc addf(s: var string, formatstr: string, a: openarray[string]) =
|
||||||
of '1'..'9':
|
of '1'..'9':
|
||||||
var j = 0
|
var j = 0
|
||||||
inc(i) # skip $
|
inc(i) # skip $
|
||||||
while formatstr[i] in {'0'..'9'}:
|
while formatstr[i] in Digits:
|
||||||
j = j * 10 + ord(formatstr[i]) - ord('0')
|
j = j * 10 + ord(formatstr[i]) - ord('0')
|
||||||
inc(i)
|
inc(i)
|
||||||
num = j
|
num = j
|
||||||
|
|
|
||||||
|
|
@ -74,7 +74,7 @@ proc `?`* [T: object](x: T): TVariant {.magic: "ToVariant".}
|
||||||
|
|
||||||
proc `><`*[T](v: TVariant, typ: T): T {.magic: "FromVariant".}
|
proc `><`*[T](v: TVariant, typ: T): T {.magic: "FromVariant".}
|
||||||
|
|
||||||
?[?5, ?67, ?"hallo"]
|
?[?5, ?67, ?"hello"]
|
||||||
myVar?int
|
myVar?int
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,7 @@
|
||||||
## The compiler depends on the System module to work properly and the System
|
## The compiler depends on the System module to work properly and the System
|
||||||
## module depends on the compiler. Most of the routines listed here use
|
## module depends on the compiler. Most of the routines listed here use
|
||||||
## special compiler magic.
|
## special compiler magic.
|
||||||
## Each module implicitly imports the System module; it may not be listed
|
## Each module implicitly imports the System module; it must not be listed
|
||||||
## explicitly. Because of this there cannot be a user-defined module named
|
## explicitly. Because of this there cannot be a user-defined module named
|
||||||
## ``system``.
|
## ``system``.
|
||||||
|
|
||||||
|
|
@ -45,7 +45,7 @@ type
|
||||||
## a type description (for templates)
|
## a type description (for templates)
|
||||||
|
|
||||||
proc defined*[T](x: T): bool {.magic: "Defined", noSideEffect.}
|
proc defined*[T](x: T): bool {.magic: "Defined", noSideEffect.}
|
||||||
## Special comile-time procedure that checks whether `x` is
|
## Special compile-time procedure that checks whether `x` is
|
||||||
## defined. `x` has to be an identifier or a qualified identifier.
|
## defined. `x` has to be an identifier or a qualified identifier.
|
||||||
## This can be used to check whether a library provides a certain
|
## This can be used to check whether a library provides a certain
|
||||||
## feature or not:
|
## feature or not:
|
||||||
|
|
@ -57,7 +57,7 @@ proc defined*[T](x: T): bool {.magic: "Defined", noSideEffect.}
|
||||||
|
|
||||||
proc definedInScope*[T](x: T): bool {.
|
proc definedInScope*[T](x: T): bool {.
|
||||||
magic: "DefinedInScope", noSideEffect.}
|
magic: "DefinedInScope", noSideEffect.}
|
||||||
## Special comile-time procedure that checks whether `x` is
|
## Special compile-time procedure that checks whether `x` is
|
||||||
## defined in the current scope. `x` has to be an identifier.
|
## defined in the current scope. `x` has to be an identifier.
|
||||||
|
|
||||||
proc `not` *(x: bool): bool {.magic: "Not", noSideEffect.}
|
proc `not` *(x: bool): bool {.magic: "Not", noSideEffect.}
|
||||||
|
|
@ -65,11 +65,11 @@ proc `not` *(x: bool): bool {.magic: "Not", noSideEffect.}
|
||||||
|
|
||||||
proc `and`*(x, y: bool): bool {.magic: "And", noSideEffect.}
|
proc `and`*(x, y: bool): bool {.magic: "And", noSideEffect.}
|
||||||
## Boolean ``and``; returns true iff ``x == y == true``.
|
## Boolean ``and``; returns true iff ``x == y == true``.
|
||||||
## Evaluation is short-circuited: This means that if ``x`` is false,
|
## Evaluation is short-circuited: this means that if ``x`` is false,
|
||||||
## ``y`` will not even be evaluated.
|
## ``y`` will not even be evaluated.
|
||||||
proc `or`*(x, y: bool): bool {.magic: "Or", noSideEffect.}
|
proc `or`*(x, y: bool): bool {.magic: "Or", noSideEffect.}
|
||||||
## Boolean ``or``; returns true iff ``not (not x and not y)``.
|
## Boolean ``or``; returns true iff ``not (not x and not y)``.
|
||||||
## Evaluation is short-circuited: This means that if ``x`` is true,
|
## Evaluation is short-circuited: this means that if ``x`` is true,
|
||||||
## ``y`` will not even be evaluated.
|
## ``y`` will not even be evaluated.
|
||||||
proc `xor`*(x, y: bool): bool {.magic: "Xor", noSideEffect.}
|
proc `xor`*(x, y: bool): bool {.magic: "Xor", noSideEffect.}
|
||||||
## Boolean `exclusive or`; returns true iff ``x != y``.
|
## Boolean `exclusive or`; returns true iff ``x != y``.
|
||||||
|
|
@ -165,7 +165,7 @@ type
|
||||||
EOS* = object of ESystem ## raised if an operating system service failed.
|
EOS* = object of ESystem ## raised if an operating system service failed.
|
||||||
EInvalidLibrary* = object of EOS ## raised if a dynamic library
|
EInvalidLibrary* = object of EOS ## raised if a dynamic library
|
||||||
## could not be loaded.
|
## could not be loaded.
|
||||||
ERessourceExhausted* = object of ESystem ## raised if a ressource request
|
EResourceExhausted* = object of ESystem ## raised if a resource request
|
||||||
## could not be fullfilled.
|
## could not be fullfilled.
|
||||||
EArithmetic* = object of ESynch ## raised if any kind of arithmetic
|
EArithmetic* = object of ESynch ## raised if any kind of arithmetic
|
||||||
## error occured.
|
## error occured.
|
||||||
|
|
@ -1188,6 +1188,11 @@ proc each*[T, S](data: openArray[T], op: proc (x: T): S): seq[S] {.
|
||||||
newSeq(result, data.len)
|
newSeq(result, data.len)
|
||||||
for i in 0..data.len-1: result[i] = op(data[i])
|
for i in 0..data.len-1: result[i] = op(data[i])
|
||||||
|
|
||||||
|
proc each*[T](data: openArray[T], op: proc (x: T)) =
|
||||||
|
## The well-known ``map`` operation from functional programming. Applies
|
||||||
|
## `op` to every item in `data`.
|
||||||
|
for i in 0..data.len-1: op(data[i])
|
||||||
|
|
||||||
|
|
||||||
# ----------------- FPU ------------------------------------------------------
|
# ----------------- FPU ------------------------------------------------------
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -104,7 +104,7 @@ proc addChar(s: NimString, c: char): NimString {.compilerProc.} =
|
||||||
|
|
||||||
# These routines should be used like following:
|
# These routines should be used like following:
|
||||||
# <Nimrod code>
|
# <Nimrod code>
|
||||||
# s &= "hallo " & name & " how do you feel?"
|
# s &= "Hello " & name & ", how do you feel?"
|
||||||
#
|
#
|
||||||
# <generated C code>
|
# <generated C code>
|
||||||
# {
|
# {
|
||||||
|
|
@ -115,7 +115,7 @@ proc addChar(s: NimString, c: char): NimString {.compilerProc.} =
|
||||||
# }
|
# }
|
||||||
#
|
#
|
||||||
# <Nimrod code>
|
# <Nimrod code>
|
||||||
# s = "hallo " & name & " how do you feel?"
|
# s = "Hello " & name & ", how do you feel?"
|
||||||
#
|
#
|
||||||
# <generated C code>
|
# <generated C code>
|
||||||
# {
|
# {
|
||||||
|
|
|
||||||
197
lib/windows/psapi.nim
Normal file
197
lib/windows/psapi.nim
Normal file
|
|
@ -0,0 +1,197 @@
|
||||||
|
#
|
||||||
|
#
|
||||||
|
# Nimrod's Runtime Library
|
||||||
|
# (c) Copyright 2009 Andreas Rumpf
|
||||||
|
#
|
||||||
|
# See the file "copying.txt", included in this
|
||||||
|
# distribution, for details about the copyright.
|
||||||
|
#
|
||||||
|
# PSAPI interface unit
|
||||||
|
|
||||||
|
# Contains the definitions for the APIs provided by PSAPI.DLL
|
||||||
|
|
||||||
|
import # Data structure templates
|
||||||
|
Windows
|
||||||
|
|
||||||
|
proc EnumProcesses*(lpidProcess: ptr DWORD, cb: DWORD, cbNeeded: ptr DWORD): WINBOOL {.stdcall,
|
||||||
|
dynlib: "psapi.dll", importc: "EnumProcesses".}
|
||||||
|
proc EnumProcessModules*(hProcess: HANDLE, lphModule: ptr HMODULE, cb: DWORD, lpcbNeeded: LPDWORD): WINBOOL {.stdcall,
|
||||||
|
dynlib: "psapi.dll", importc: "EnumProcessModules".}
|
||||||
|
|
||||||
|
proc GetModuleBaseNameA*(hProcess: HANDLE, hModule: HMODULE, lpBaseName: LPSTR, nSize: DWORD): DWORD {.stdcall,
|
||||||
|
dynlib: "psapi.dll", importc: "GetModuleBaseNameA".}
|
||||||
|
proc GetModuleBaseNameW*(hProcess: HANDLE, hModule: HMODULE, lpBaseName: LPWSTR, nSize: DWORD): DWORD {.stdcall,
|
||||||
|
dynlib: "psapi.dll", importc: "GetModuleBaseNameW".}
|
||||||
|
when defined(winUnicode):
|
||||||
|
proc GetModuleBaseName*(hProcess: HANDLE, hModule: HMODULE, lpBaseName: LPWSTR, nSize: DWORD): DWORD {.stdcall,
|
||||||
|
dynlib: "psapi.dll", importc: "GetModuleBaseNameW".}
|
||||||
|
else:
|
||||||
|
proc GetModuleBaseName*(hProcess: HANDLE, hModule: HMODULE, lpBaseName: LPSTR, nSize: DWORD): DWORD {.stdcall,
|
||||||
|
dynlib: "psapi.dll", importc: "GetModuleBaseNameA".}
|
||||||
|
|
||||||
|
proc GetModuleFileNameExA*(hProcess: HANDLE, hModule: HMODULE, lpFileNameEx: LPSTR, nSize: DWORD): DWORD {.stdcall,
|
||||||
|
dynlib: "psapi.dll", importc: "GetModuleFileNameExA".}
|
||||||
|
proc GetModuleFileNameExW*(hProcess: HANDLE, hModule: HMODULE, lpFileNameEx: LPWSTR, nSize: DWORD): DWORD {.stdcall,
|
||||||
|
dynlib: "psapi.dll", importc: "GetModuleFileNameExW".}
|
||||||
|
when defined(winUnicode):
|
||||||
|
proc GetModuleFileNameEx*(hProcess: HANDLE, hModule: HMODULE, lpFileNameEx: LPWSTR, nSize: DWORD): DWORD {.stdcall,
|
||||||
|
dynlib: "psapi.dll", importc: "GetModuleFileNameExW".}
|
||||||
|
else:
|
||||||
|
proc GetModuleFileNameEx*(hProcess: HANDLE, hModule: HMODULE, lpFileNameEx: LPSTR, nSize: DWORD): DWORD {.stdcall,
|
||||||
|
dynlib: "psapi.dll", importc: "GetModuleFileNameExA".}
|
||||||
|
|
||||||
|
type
|
||||||
|
MODULEINFO* {.final.} = object
|
||||||
|
lpBaseOfDll*: LPVOID
|
||||||
|
SizeOfImage*: DWORD
|
||||||
|
EntryPoint*: LPVOID
|
||||||
|
LPMODULEINFO* = ptr MODULEINFO
|
||||||
|
|
||||||
|
proc GetModuleInformation*(hProcess: HANDLE, hModule: HMODULE, lpmodinfo: LPMODULEINFO, cb: DWORD): WINBOOL {.stdcall,
|
||||||
|
dynlib: "psapi.dll", importc: "GetModuleInformation".}
|
||||||
|
proc EmptyWorkingSet*(hProcess: HANDLE): WINBOOL {.stdcall,
|
||||||
|
dynlib: "psapi.dll", importc: "EmptyWorkingSet".}
|
||||||
|
proc QueryWorkingSet*(hProcess: HANDLE, pv: PVOID, cb: DWORD): WINBOOL {.stdcall,
|
||||||
|
dynlib: "psapi.dll", importc: "QueryWorkingSet".}
|
||||||
|
proc QueryWorkingSetEx*(hProcess: HANDLE, pv: PVOID, cb: DWORD): WINBOOL {.stdcall,
|
||||||
|
dynlib: "psapi.dll", importc: "QueryWorkingSetEx".}
|
||||||
|
proc InitializeProcessForWsWatch*(hProcess: HANDLE): WINBOOL {.stdcall,
|
||||||
|
dynlib: "psapi.dll", importc: "InitializeProcessForWsWatch".}
|
||||||
|
|
||||||
|
type
|
||||||
|
PSAPI_WS_WATCH_INFORMATION* {.final.} = object
|
||||||
|
FaultingPc*: LPVOID
|
||||||
|
FaultingVa*: LPVOID
|
||||||
|
PPSAPI_WS_WATCH_INFORMATION* = ptr PSAPI_WS_WATCH_INFORMATION
|
||||||
|
|
||||||
|
proc GetWsChanges*(hProcess: HANDLE, lpWatchInfo: PPSAPI_WS_WATCH_INFORMATION, cb: DWORD): WINBOOL {.stdcall,
|
||||||
|
dynlib: "psapi.dll", importc: "GetWsChanges".}
|
||||||
|
|
||||||
|
proc GetMappedFileNameA*(hProcess: HANDLE, lpv: LPVOID, lpFilename: LPSTR, nSize: DWORD): DWORD {.stdcall,
|
||||||
|
dynlib: "psapi.dll", importc: "GetMappedFileNameA".}
|
||||||
|
proc GetMappedFileNameW*(hProcess: HANDLE, lpv: LPVOID, lpFilename: LPWSTR, nSize: DWORD): DWORD {.stdcall,
|
||||||
|
dynlib: "psapi.dll", importc: "GetMappedFileNameW".}
|
||||||
|
when defined(winUnicode):
|
||||||
|
proc GetMappedFileName*(hProcess: HANDLE, lpv: LPVOID, lpFilename: LPWSTR, nSize: DWORD): DWORD {.stdcall,
|
||||||
|
dynlib: "psapi.dll", importc: "GetMappedFileNameW".}
|
||||||
|
else:
|
||||||
|
proc GetMappedFileName*(hProcess: HANDLE, lpv: LPVOID, lpFilename: LPSTR, nSize: DWORD): DWORD {.stdcall,
|
||||||
|
dynlib: "psapi.dll", importc: "GetMappedFileNameA".}
|
||||||
|
|
||||||
|
proc EnumDeviceDrivers*(lpImageBase: LPVOID, cb: DWORD, lpcbNeeded: LPDWORD): WINBOOL {.stdcall,
|
||||||
|
dynlib: "psapi.dll", importc: "EnumDeviceDrivers".}
|
||||||
|
|
||||||
|
proc GetDeviceDriverBaseNameA*(ImageBase: LPVOID, lpBaseName: LPSTR, nSize: DWORD): DWORD {.stdcall,
|
||||||
|
dynlib: "psapi.dll", importc: "GetDeviceDriverBaseNameA".}
|
||||||
|
proc GetDeviceDriverBaseNameW*(ImageBase: LPVOID, lpBaseName: LPWSTR, nSize: DWORD): DWORD {.stdcall,
|
||||||
|
dynlib: "psapi.dll", importc: "GetDeviceDriverBaseNameW".}
|
||||||
|
when defined(winUnicode):
|
||||||
|
proc GetDeviceDriverBaseName*(ImageBase: LPVOID, lpBaseName: LPWSTR, nSize: DWORD): DWORD {.stdcall,
|
||||||
|
dynlib: "psapi.dll", importc: "GetDeviceDriverBaseNameW".}
|
||||||
|
else:
|
||||||
|
proc GetDeviceDriverBaseName*(ImageBase: LPVOID, lpBaseName: LPSTR, nSize: DWORD): DWORD {.stdcall,
|
||||||
|
dynlib: "psapi.dll", importc: "GetDeviceDriverBaseNameA".}
|
||||||
|
|
||||||
|
proc GetDeviceDriverFileNameA*(ImageBase: LPVOID, lpFileName: LPSTR, nSize: DWORD): DWORD {.stdcall,
|
||||||
|
dynlib: "psapi.dll", importc: "GetDeviceDriverFileNameA".}
|
||||||
|
proc GetDeviceDriverFileNameW*(ImageBase: LPVOID, lpFileName: LPWSTR, nSize: DWORD): DWORD {.stdcall,
|
||||||
|
dynlib: "psapi.dll", importc: "GetDeviceDriverFileNameW".}
|
||||||
|
when defined(winUnicode):
|
||||||
|
proc GetDeviceDriverFileName*(ImageBase: LPVOID, lpFileName: LPWSTR, nSize: DWORD): DWORD {.stdcall,
|
||||||
|
dynlib: "psapi.dll", importc: "GetDeviceDriverFileNameW".}
|
||||||
|
else:
|
||||||
|
proc GetDeviceDriverFileName*(ImageBase: LPVOID, lpFileName: LPSTR, nSize: DWORD): DWORD {.stdcall,
|
||||||
|
dynlib: "psapi.dll", importc: "GetDeviceDriverFileNameA".}
|
||||||
|
|
||||||
|
type
|
||||||
|
PROCESS_MEMORY_COUNTERS* {.final.} = object
|
||||||
|
cb*: DWORD
|
||||||
|
PageFaultCount*: DWORD
|
||||||
|
PeakWorkingSetSize: SIZE_T
|
||||||
|
WorkingSetSize: SIZE_T
|
||||||
|
QuotaPeakPagedPoolUsage: SIZE_T
|
||||||
|
QuotaPagedPoolUsage: SIZE_T
|
||||||
|
QuotaPeakNonPagedPoolUsage: SIZE_T
|
||||||
|
QuotaNonPagedPoolUsage: SIZE_T
|
||||||
|
PagefileUsage: SIZE_T
|
||||||
|
PeakPagefileUsage: SIZE_T
|
||||||
|
PPROCESS_MEMORY_COUNTERS* = ptr PROCESS_MEMORY_COUNTERS
|
||||||
|
|
||||||
|
type
|
||||||
|
PROCESS_MEMORY_COUNTERS_EX* {.final.} = object
|
||||||
|
cb*: DWORD
|
||||||
|
PageFaultCount*: DWORD
|
||||||
|
PeakWorkingSetSize: SIZE_T
|
||||||
|
WorkingSetSize: SIZE_T
|
||||||
|
QuotaPeakPagedPoolUsage: SIZE_T
|
||||||
|
QuotaPagedPoolUsage: SIZE_T
|
||||||
|
QuotaPeakNonPagedPoolUsage: SIZE_T
|
||||||
|
QuotaNonPagedPoolUsage: SIZE_T
|
||||||
|
PagefileUsage: SIZE_T
|
||||||
|
PeakPagefileUsage: SIZE_T
|
||||||
|
PrivateUsage: SIZE_T
|
||||||
|
PPROCESS_MEMORY_COUNTERS_EX* = ptr PROCESS_MEMORY_COUNTERS_EX
|
||||||
|
|
||||||
|
proc GetProcessMemoryInfo*(hProcess: HANDLE, ppsmemCounters: PPROCESS_MEMORY_COUNTERS, cb: DWORD): WINBOOL {.stdcall,
|
||||||
|
dynlib: "psapi.dll", importc: "GetProcessMemoryInfo".}
|
||||||
|
|
||||||
|
type
|
||||||
|
PERFORMANCE_INFORMATION* {.final.} = object
|
||||||
|
cb*: DWORD
|
||||||
|
CommitTotal: SIZE_T
|
||||||
|
CommitLimit: SIZE_T
|
||||||
|
CommitPeak: SIZE_T
|
||||||
|
PhysicalTotal: SIZE_T
|
||||||
|
PhysicalAvailable: SIZE_T
|
||||||
|
SystemCache: SIZE_T
|
||||||
|
KernelTotal: SIZE_T
|
||||||
|
KernelPaged: SIZE_T
|
||||||
|
KernelNonpaged: SIZE_T
|
||||||
|
PageSize: SIZE_T
|
||||||
|
HandleCount*: DWORD
|
||||||
|
ProcessCount*: DWORD
|
||||||
|
ThreadCount*: DWORD
|
||||||
|
PPERFORMANCE_INFORMATION* = ptr PERFORMANCE_INFORMATION
|
||||||
|
# Skip definition of PERFORMACE_INFORMATION...
|
||||||
|
|
||||||
|
proc GetPerformanceInfo*(pPerformanceInformation: PPERFORMANCE_INFORMATION, cb: DWORD): WINBOOL {.stdcall,
|
||||||
|
dynlib: "psapi.dll", importc: "GetPerformanceInfo".}
|
||||||
|
|
||||||
|
type
|
||||||
|
ENUM_PAGE_FILE_INFORMATION* {.final.} = object
|
||||||
|
cb*: DWORD
|
||||||
|
Reserved*: DWORD
|
||||||
|
TotalSize: SIZE_T
|
||||||
|
TotalInUse: SIZE_T
|
||||||
|
PeakUsage: SIZE_T
|
||||||
|
PENUM_PAGE_FILE_INFORMATION* = ptr ENUM_PAGE_FILE_INFORMATION
|
||||||
|
|
||||||
|
# Callback procedure
|
||||||
|
type
|
||||||
|
PENUM_PAGE_FILE_CALLBACKW* = proc (pContext: LPVOID, pPageFileInfo: PENUM_PAGE_FILE_INFORMATION, lpFilename: LPCWSTR): WINBOOL{.stdcall.}
|
||||||
|
PENUM_PAGE_FILE_CALLBACKA* = proc (pContext: LPVOID, pPageFileInfo: PENUM_PAGE_FILE_INFORMATION, lpFilename: LPCSTR): WINBOOL{.stdcall.}
|
||||||
|
|
||||||
|
#TODO
|
||||||
|
proc EnumPageFilesA*(pCallBackRoutine: PENUM_PAGE_FILE_CALLBACKA, pContext: LPVOID): WINBOOL {.stdcall,
|
||||||
|
dynlib: "psapi.dll", importc: "EnumPageFilesA".}
|
||||||
|
proc EnumPageFilesW*(pCallBackRoutine: PENUM_PAGE_FILE_CALLBACKW, pContext: LPVOID): WINBOOL {.stdcall,
|
||||||
|
dynlib: "psapi.dll", importc: "EnumPageFilesW".}
|
||||||
|
when defined(winUnicode):
|
||||||
|
proc EnumPageFiles*(pCallBackRoutine: PENUM_PAGE_FILE_CALLBACKW, pContext: LPVOID): WINBOOL {.stdcall,
|
||||||
|
dynlib: "psapi.dll", importc: "EnumPageFilesW".}
|
||||||
|
type PENUM_PAGE_FILE_CALLBACK* = proc (pContext: LPVOID, pPageFileInfo: PENUM_PAGE_FILE_INFORMATION, lpFilename: LPCWSTR): WINBOOL{.stdcall.}
|
||||||
|
else:
|
||||||
|
proc EnumPageFiles*(pCallBackRoutine: PENUM_PAGE_FILE_CALLBACKA, pContext: LPVOID): WINBOOL {.stdcall,
|
||||||
|
dynlib: "psapi.dll", importc: "EnumPageFilesA".}
|
||||||
|
type PENUM_PAGE_FILE_CALLBACK* = proc (pContext: LPVOID, pPageFileInfo: PENUM_PAGE_FILE_INFORMATION, lpFilename: LPCSTR): WINBOOL{.stdcall.}
|
||||||
|
|
||||||
|
proc GetProcessImageFileNameA*(hProcess: HANDLE, lpImageFileName: LPSTR, nSize: DWORD): DWORD {.stdcall,
|
||||||
|
dynlib: "psapi.dll", importc: "GetProcessImageFileNameA".}
|
||||||
|
proc GetProcessImageFileNameW*(hProcess: HANDLE, lpImageFileName: LPWSTR, nSize: DWORD): DWORD {.stdcall,
|
||||||
|
dynlib: "psapi.dll", importc: "GetProcessImageFileNameW".}
|
||||||
|
when defined(winUnicode):
|
||||||
|
proc GetProcessImageFileName*(hProcess: HANDLE, lpImageFileName: LPWSTR, nSize: DWORD): DWORD {.stdcall,
|
||||||
|
dynlib: "psapi.dll", importc: "GetProcessImageFileNameW".}
|
||||||
|
else:
|
||||||
|
proc GetProcessImageFileName*(hProcess: HANDLE, lpImageFileName: LPSTR, nSize: DWORD): DWORD {.stdcall,
|
||||||
|
dynlib: "psapi.dll", importc: "GetProcessImageFileNameA".}
|
||||||
File diff suppressed because it is too large
Load diff
|
|
@ -74,7 +74,7 @@ proc `<>`* [T: object](x: T): TVariant {.magic: "ToVariant".}
|
||||||
|
|
||||||
proc `><`*[T](v: TVariant, typ: T): T {.magic: "FromVariant".}
|
proc `><`*[T](v: TVariant, typ: T): T {.magic: "FromVariant".}
|
||||||
|
|
||||||
[<>5, <>67, <>"hallo"]
|
[<>5, <>67, <>"hello"]
|
||||||
myVar><int
|
myVar><int
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -104,7 +104,7 @@ proc addChar(s: NimString, c: char): NimString {.compilerProc.} =
|
||||||
|
|
||||||
# These routines should be used like following:
|
# These routines should be used like following:
|
||||||
# <Nimrod code>
|
# <Nimrod code>
|
||||||
# s &= "hallo " & name & " how do you feel?"
|
# s &= "Hello " & name & ", how do you feel?"
|
||||||
#
|
#
|
||||||
# <generated C code>
|
# <generated C code>
|
||||||
# {
|
# {
|
||||||
|
|
@ -115,7 +115,7 @@ proc addChar(s: NimString, c: char): NimString {.compilerProc.} =
|
||||||
# }
|
# }
|
||||||
#
|
#
|
||||||
# <Nimrod code>
|
# <Nimrod code>
|
||||||
# s = "hallo " & name & " how do you feel?"
|
# s = "Hello " & name & ", how do you feel?"
|
||||||
#
|
#
|
||||||
# <generated C code>
|
# <generated C code>
|
||||||
# {
|
# {
|
||||||
|
|
|
||||||
|
|
@ -863,7 +863,7 @@ proc genCall(p: BProc, t: PNode, d: var TLoc) =
|
||||||
|
|
||||||
proc genStrConcat(p: BProc, e: PNode, d: var TLoc) =
|
proc genStrConcat(p: BProc, e: PNode, d: var TLoc) =
|
||||||
# <Nimrod code>
|
# <Nimrod code>
|
||||||
# s = 'hallo ' & name & ' how do you feel?' & 'z'
|
# s = 'Hello ' & name & ', how do you feel?' & 'z'
|
||||||
#
|
#
|
||||||
# <generated C code>
|
# <generated C code>
|
||||||
# {
|
# {
|
||||||
|
|
@ -907,7 +907,7 @@ proc genStrConcat(p: BProc, e: PNode, d: var TLoc) =
|
||||||
|
|
||||||
proc genStrAppend(p: BProc, e: PNode, d: var TLoc) =
|
proc genStrAppend(p: BProc, e: PNode, d: var TLoc) =
|
||||||
# <Nimrod code>
|
# <Nimrod code>
|
||||||
# s &= 'hallo ' & name & ' how do you feel?' & 'z'
|
# s &= 'Hello ' & name & ', how do you feel?' & 'z'
|
||||||
# // BUG: what if s is on the left side too?
|
# // BUG: what if s is on the left side too?
|
||||||
# <generated C code>
|
# <generated C code>
|
||||||
# {
|
# {
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,3 @@
|
||||||
# Simplest Nimrod program
|
# Simplest Nimrod program
|
||||||
|
|
||||||
echo "Hallo, World!"
|
echo "Hello, World!"
|
||||||
|
|
|
||||||
|
|
@ -36,7 +36,7 @@ macrotest(stdout)
|
||||||
#GC_disable()
|
#GC_disable()
|
||||||
|
|
||||||
echo("This was compiled by Nimrod version " & system.nimrodVersion)
|
echo("This was compiled by Nimrod version " & system.nimrodVersion)
|
||||||
writeln(stdout, "Hallo", " World", "!")
|
writeln(stdout, "Hello", " World", "!")
|
||||||
|
|
||||||
echo(["a", "b", "c", "d"].len)
|
echo(["a", "b", "c", "d"].len)
|
||||||
for x in items(["What's", "your", "name", "?", ]):
|
for x in items(["What's", "your", "name", "?", ]):
|
||||||
|
|
@ -51,7 +51,7 @@ var testseq: seq[string] = @[
|
||||||
]
|
]
|
||||||
echo(repr(testseq))
|
echo(repr(testseq))
|
||||||
|
|
||||||
var dummy = "hallo"
|
var dummy = "hello"
|
||||||
echo(copy(dummy, 2, 3))
|
echo(copy(dummy, 2, 3))
|
||||||
|
|
||||||
echo($meC)
|
echo($meC)
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
# test the file-IO
|
# test the file-IO
|
||||||
|
|
||||||
proc main() =
|
proc main() =
|
||||||
for line in lines("thallo.nim"):
|
for line in lines("thello.nim"):
|
||||||
writeln(stdout, line)
|
writeln(stdout, line)
|
||||||
|
|
||||||
main()
|
main()
|
||||||
|
|
|
||||||
|
|
@ -57,7 +57,7 @@ proc Foo(n: int): int =
|
||||||
while b:
|
while b:
|
||||||
a = a + 3
|
a = a + 3
|
||||||
a = a + 5
|
a = a + 5
|
||||||
write(stdout, "Hallo!")
|
write(stdout, "Hello!")
|
||||||
|
|
||||||
|
|
||||||
# We should come till here :-)
|
# We should come till here :-)
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,6 @@ import streams
|
||||||
|
|
||||||
var outp = newFileStream(stdout)
|
var outp = newFileStream(stdout)
|
||||||
var inp = newFileStream(stdin)
|
var inp = newFileStream(stdin)
|
||||||
write(outp, "Hallo! What is your name?")
|
write(outp, "Hello! What is your name?")
|
||||||
var line = readLine(inp)
|
var line = readLine(inp)
|
||||||
write(outp, "nice name: " & line)
|
write(outp, "Nice name: " & line)
|
||||||
|
|
|
||||||
|
|
@ -1,2 +1,2 @@
|
||||||
# Test the new initialization for modules
|
# Test the new initialization for modules
|
||||||
write(stdout, "Hallo from module! ")
|
write(stdout, "Hello from module! ")
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@ import tbintree
|
||||||
|
|
||||||
var
|
var
|
||||||
root: PBinaryTree[string]
|
root: PBinaryTree[string]
|
||||||
x = newNode("hallo")
|
x = newNode("hello")
|
||||||
add(root, x)
|
add(root, x)
|
||||||
add(root, "world")
|
add(root, "world")
|
||||||
if find(root, "world"):
|
if find(root, "world"):
|
||||||
|
|
@ -21,5 +21,5 @@ add(r2, 99)
|
||||||
for y in items(r2):
|
for y in items(r2):
|
||||||
stdout.write(y)
|
stdout.write(y)
|
||||||
|
|
||||||
#OUT halloworld99110223
|
#OUT helloworld99110223
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -81,7 +81,7 @@ proc debug[T](a: PBinaryTree[T]) =
|
||||||
when isMainModule:
|
when isMainModule:
|
||||||
var
|
var
|
||||||
root: PBinaryTree[string]
|
root: PBinaryTree[string]
|
||||||
x = newNode("hallo")
|
x = newNode("hello")
|
||||||
add(root, x)
|
add(root, x)
|
||||||
add(root, "world")
|
add(root, "world")
|
||||||
if find(root, "world"):
|
if find(root, "world"):
|
||||||
|
|
@ -98,4 +98,4 @@ when isMainModule:
|
||||||
for y in items(r2):
|
for y in items(r2):
|
||||||
stdout.write(y)
|
stdout.write(y)
|
||||||
|
|
||||||
#OUT halloworld99110223
|
#OUT helloworld99110223
|
||||||
|
|
|
||||||
|
|
@ -2,5 +2,5 @@
|
||||||
|
|
||||||
import minit
|
import minit
|
||||||
|
|
||||||
write(stdout, "Hallo from main module!\n")
|
write(stdout, "Hello from main module!\n")
|
||||||
#OUT Hallo from module! Hallo from main module!
|
#OUT Hello from module! Hello from main module!
|
||||||
|
|
|
||||||
|
|
@ -3,5 +3,5 @@
|
||||||
proc write(t: TFile, s: string) =
|
proc write(t: TFile, s: string) =
|
||||||
nil # a nop
|
nil # a nop
|
||||||
|
|
||||||
system.write(stdout, "hallo")
|
system.write(stdout, "hello")
|
||||||
#OUT hallo
|
#OUT hello
|
||||||
|
|
|
||||||
|
|
@ -23,7 +23,7 @@ proc mypos(sub, s: string, start: int = 0): int =
|
||||||
else:
|
else:
|
||||||
result = -1
|
result = -1
|
||||||
|
|
||||||
var sub = "hallo"
|
var sub = "hello"
|
||||||
var s = "world hallo"
|
var s = "world hello"
|
||||||
write(stdout, mypos(sub, s))
|
write(stdout, mypos(sub, s))
|
||||||
#OUT 6
|
#OUT 6
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
import strutils
|
import strutils
|
||||||
|
|
||||||
var x = "hallo world!".toLower.toUpper
|
var x = "hello world!".toLower.toUpper
|
||||||
x.echo()
|
x.echo()
|
||||||
#OUT HALLO WORLD!
|
#OUT HELLO WORLD!
|
||||||
|
|
||||||
|
|
|
||||||
10
tests/tenuminh.nim
Normal file
10
tests/tenuminh.nim
Normal file
|
|
@ -0,0 +1,10 @@
|
||||||
|
type
|
||||||
|
TCardPts = enum
|
||||||
|
North, West, South, East
|
||||||
|
|
||||||
|
TCardPts2 = enum of TCardPts
|
||||||
|
N, W, S, E
|
||||||
|
|
||||||
|
# If I do:
|
||||||
|
var y = W
|
||||||
|
echo($y & "=" & $ord(y)) #OUT W=5
|
||||||
Loading…
Add table
Add a link
Reference in a new issue