Author Topic: Nimrod  (Read 48440 times)

kryton9

  • Guest
Re: Nimrod
« Reply #45 on: September 29, 2013, 06:22:04 PM »
Wow you are flying along John, a coding machine!

The bundle post is nice too. Are you thinking of adding all the necessary dll's for the nimrod libraries into the distro folder John?
« Last Edit: September 29, 2013, 06:25:04 PM by kryton9 »

Offline John

  • Forum Support / SB Dev
  • Posts: 3597
    • ScriptBasic Open Source Project
Re: Nimrod
« Reply #46 on: September 29, 2013, 07:33:54 PM »
My effort was a temporary helper until you figure out what direction you're going with Nimrod. I'm an advocate just like you on the Nimrod project and counting on you taking the lead. Feel free to add to whatever you want to help the Nimrod project along. I find the language interesting and hope to pickup some tips from it.


kryton9

  • Guest
Re: Nimrod
« Reply #47 on: October 01, 2013, 12:22:40 AM »
John, I spent some time on the Nimrod site reading more in depth instead of glancing. It seems my bundle idea was really stupid ( about the dlls for the distro folder ). I see that they have many wrappers for various databases, scripting languages and the same for graphics and so forth, so it is not feasible or reasonable to do.

I think it is language worth keeping an eye on, but I don't think ready for prime time just yet. The forums and other learning material are good for introductory work, but for me not enough to do a bigger project.

I did a search for instance on a tutorial for Nimrod using sqlite3 and didn't find anything. With my poor memory, I need good references and tutorials to give me a start. Anyways I will finish the tutorials that they have and play with the examples.

I think I want to work on helping Charles get a front end for Oxygen. So I want to really get into gcc and its front end manuals and see if I can make a start for him.

Offline John

  • Forum Support / SB Dev
  • Posts: 3597
    • ScriptBasic Open Source Project
Re: Nimrod
« Reply #48 on: October 01, 2013, 02:29:03 AM »
Maybe you should start with ScriptBasic first before getting too frustrated with Nimrod.


Offline Charles Pegge

  • BASIC Developer
  • Posts: 69
Re: Nimrod
« Reply #49 on: October 01, 2013, 07:35:33 AM »

I'm quite interested in the idea of multimethods, which seems to aggregate objects to a method, rather than methods to an object, (as in C style OOP).

It sounds like there are a number dependencies, requiring prior expertise to get Nimrod running though.

Offline John

  • Forum Support / SB Dev
  • Posts: 3597
    • ScriptBasic Open Source Project
Re: Nimrod
« Reply #50 on: October 01, 2013, 10:43:21 AM »
The Linux squeeze will continue to disable programmers that ignore the OS. Linux defines cross platform and the framework tools that are used. I highly recommend getting a FREE Cloud9 account and start honing your Linux skills before Windows as a development concept is no longer relevant.

kryton9

  • Guest
off topic slightly
« Reply #51 on: October 01, 2013, 02:25:11 PM »
John, have you tried Arch Linux? I tried to install it but didn't get to far, but in honesty, I tried it without looking at the installation instructions.

What I like about it is, once you install and get it setup, you never have to uninstall and reinstall a next version. It does continuing updates!

I found that Ubuntu does not come with lots of core programming things that are needed. I followed the lazarus free pascal Ubuntu install instructions and although I did each step and got no errors installing everything. When I went to run Lazarus, it gives me an error. 

Also, at least in Ubuntu, things are placed all over the place and many are protected for root and many operations you can't do.

My dream OS would be:
The OS is just an OS that you can get in 3 flavors. 1. Command line only: for servers and embedded devices. 2. Command Line with Ascii GUI: for people running servers and or businesses and want to keep employees from playing games. 3. A full OS with command line, command line and ascii GUI and regular modern GUI.

The system can't be touched by no one. It can only be updated from official servers or from dvd's from os source. It would be in its own partition and no access to anyone but from official OS sources.

Drive C: would be the users directory with each user being a root folder in the c root:

c:/kent
c:/john
c:/charles

When you log on as a user your root directory automatically is your directory. So if I log in as kent when I say cd /
it takes me into c:/kent
as kent I don't see any of the other users folders.

Only a root user can access any users folder. So some one logging in as root would see this when they type cd /
c:/kent
c:/john
c:/charles

Then there would be another partition that is shared data for all users this would be drive d:  for data :)

When I log in as kent, everything I do to the system settings configurations are stored in my folder that I have full access too.
all programs would be self contained in one folder for each program within a folder of the users choice.
Basically you allow the user to control where things are for their tastes and in naming the prefer. And each downloaded and installed packages would be in one folder and not put files all over the place.

Now the big thing. Each library that has a dynamic dll that is for a major project, submits their latest dynamic library and headers to the OS maker. They in turn in updates install these into the OS system.

For a dynamic library a user makes, that would be in their choice of how they want to store dll's and headers.

So basically all major projects and the operating system are taken care of for the end user and always up to date.

The last big things is that the OS can talk to new hardware, download the interface, dll and header to make that device work from the firmware of the hardware. So any OS designed with this interface to query and get stuff from the firmware can support the hardware.

Offline John

  • Forum Support / SB Dev
  • Posts: 3597
    • ScriptBasic Open Source Project
Linux development environments
« Reply #52 on: October 01, 2013, 02:28:27 PM »
Sounds like your talking about Cloud9 IDE. (and it's online and sharable)

kryton9

  • Guest
Re: Nimrod
« Reply #53 on: October 01, 2013, 02:30:51 PM »
Going to check it out tonight John, you got me intrigues with your other impressive posts!

Offline AIR

  • BASIC Developer
  • Posts: 932
  • Coder
Re: off topic slightly
« Reply #54 on: October 04, 2013, 04:35:04 PM »
Responses inline, I couldn't ignore this post... :-*

I found that Ubuntu does not come with lots of core programming things that are needed. I followed the lazarus free pascal Ubuntu install instructions and although I did each step and got no errors installing everything. When I went to run Lazarus, it gives me an error.
 

Most OS distributions are User-centric; if you want to develop on a given platform, you have to add support for it.

Quote
Also, at least in Ubuntu, things are placed all over the place and many are protected for root and many operations you can't do.

This is to protect you from yourself. ;D  It's real easy to destroy a system otherwise.

Quote
My dream OS would be:
The OS is just an OS that you can get in 3 flavors. 1. Command line only: for servers and embedded devices. 2. Command Line with Ascii GUI: for people running servers and or businesses and want to keep employees from playing games. 3. A full OS with command line, command line and ascii GUI and regular modern GUI.

Most Unix-like OS's already provide 1 and 3, while 2 reminds me of Linux in the late 80's.  As an aside, without a modern GUI most end-users would not be inclined to play games.  :)

Quote
The system can't be touched by no one. It can only be updated from official servers or from dvd's from os source. It would be in its own partition and no access to anyone but from official OS sources.

Sounds like you want Debian.


Quote
Drive C: would be the users directory with each user being a root folder in the c root:

c:/kent
c:/john
c:/charles

That would end up being an administrative nightmare, I think.

Quote
When you log on as a user your root directory automatically is your directory. So if I log in as kent when I say cd /
it takes me into c:/kent
as kent I don't see any of the other users folders.

When you log on, or start a terminal from a GUI session, you are already in your home folder. 

If you're somewhere else in the file system, "cd" by itself takes you back to your home folder.

Quote
Only a root user can access any users folder. So some one logging in as root would see this when they type cd /
c:/kent
c:/john
c:/charles

Not sure what the advantage to this would be over doing "cd /Users" (if supported) or "cd /home".  In your example, you would also see all of the folders/files that are at the root:  /bin /sbin /home /usr /etc

Quote
Then there would be another partition that is shared data for all users this would be drive d:  for data :)

Very easy to do if your partition your drives and edit /etc/fstab

Quote
When I log in as kent, everything I do to the system settings configurations are stored in my folder that I have full access too.

In Linux, a user's home folder generally has a hidden folder called ".config"

In it, you can over-ride most system-wide settings.

Quote
all programs would be self contained in one folder for each program within a folder of the users choice.
Basically you allow the user to control where things are for their tastes and in naming the prefer. And each downloaded and installed packages would be in one folder and not put files all over the place.

This would lead to tremendous duplication on a multi-user system.  For example, say you and I use the system.  We both want to use OpenOffice.  In your scenario, we each would have our own copy in our home folders.  Come update time, if it's automated, the system would have to upgrade each copy.  If it's not automated, each user is responsible, which now involves downloading the update twice.  Pretty soon, we'd be fighting a drive-space issue.

Quote
Now the big thing. Each library that has a dynamic dll that is for a major project, submits their latest dynamic library and headers to the OS maker. They in turn in updates install these into the OS system.

That's sort of what happens now, if you think about it.  Keep in mind, thought, that all sorts of regression testing has to take place, which is why all distro's may not have the latest and greatest SW/Libraries available.

Quote
For a dynamic library a user makes, that would be in their choice of how they want to store dll's and headers.

Then you would have to contend with additional compiler and linker switches, so that your software can find the libraries and headers.

Quote
The last big things is that the OS can talk to new hardware, download the interface, dll and header to make that device work from the firmware of the hardware. So any OS designed with this interface to query and get stuff from the firmware can support the hardware.

Hardware is proprietary; it falls to the hardware producer to create the drivers for a given OS.  How would you even begin to manage that, since most Linux distributions aren't heavily funded?

Even Microsoft can't do this 100%; it's a logistical and monetary nightmare.  Sure, you can go with reference drivers released by the manufacturer, but you would probably want to go with what the Vendor provides instead.

Take Graphic cards, for example.  A Vendor may have added an enhancement that the reference drivers don't support.  So now, using ATI as an example, you have to provide drivers for just about every conceivable Vendor implementation. 

All in all, your ideas are interesting, but (just my opinion) they aren't practical.

AIR.

Offline John

  • Forum Support / SB Dev
  • Posts: 3597
    • ScriptBasic Open Source Project
Nimrod - C9 Red Hat Project
« Reply #55 on: October 07, 2013, 10:13:18 PM »
I created a Nimrod Red Hat 64 bit project on Cloud9 IDE. I built Nimrod from scratch using git.

Nimrod git build log

Babel
Code: [Select]
scriptbasic@nimrod:~/639761/Nimrod/babel-master (master) $ ls -l
total 72
-rw-r--r--. 1 525387a75973caafd40003a0 525387a75973caafd40003a0   207 Oct  5 14:14 babel.babel
-rw-r--r--. 1 525387a75973caafd40003a0 525387a75973caafd40003a0 12080 Oct  5 14:14 babel.nim
-rw-r--r--. 1 525387a75973caafd40003a0 525387a75973caafd40003a0     7 Oct  5 14:14 babel.nimrod.cfg
-rw-r--r--. 1 525387a75973caafd40003a0 525387a75973caafd40003a0   314 Oct  5 14:14 common.nim
-rw-r--r--. 1 525387a75973caafd40003a0 525387a75973caafd40003a0  4031 Oct  5 14:14 download.nim
-rw-r--r--. 1 525387a75973caafd40003a0 525387a75973caafd40003a0  1624 Oct  5 14:14 license.txt
-rw-r--r--. 1 525387a75973caafd40003a0 525387a75973caafd40003a0  8680 Oct  5 14:14 packageinfo.nim
-rw-r--r--. 1 525387a75973caafd40003a0 525387a75973caafd40003a0  8949 Oct  5 14:14 readme.markdown
-rw-r--r--. 1 525387a75973caafd40003a0 525387a75973caafd40003a0   603 Oct  5 14:14 todo.markdown
-rw-r--r--. 1 525387a75973caafd40003a0 525387a75973caafd40003a0  1681 Oct  5 14:14 tools.nim
-rw-r--r--. 1 525387a75973caafd40003a0 525387a75973caafd40003a0  6503 Oct  5 14:14 version.nim
scriptbasic@nimrod:~/639761/Nimrod/babel-master (master) $ nimrod c -d:release babel.nim
config/nimrod.cfg(36, 2) Hint: added path: '/var/lib/stickshift/525387a75973caafd40003a0/app-root/data/.babel/pkgs/' [Path]
Hint: used config file '/var/lib/stickshift/525387a75973caafd40003a0/app-root/data/639761/Nimrod/config/nimrod.cfg' [Conf]
Hint: used config file '/var/lib/stickshift/525387a75973caafd40003a0/app-root/data/639761/Nimrod/babel-master/babel.nimrod.cfg' [Conf]
Hint: system [Processing]
Hint: babel [Processing]
Hint: httpclient [Processing]
Hint: sockets [Processing]
Hint: os [Processing]
Hint: strutils [Processing]
Hint: parseutils [Processing]
Hint: times [Processing]
Hint: posix [Processing]
Hint: openssl [Processing]
Hint: parseurl [Processing]
Hint: strtabs [Processing]
Hint: hashes [Processing]
Hint: base64 [Processing]
Hint: parseopt [Processing]
Hint: osproc [Processing]
Hint: streams [Processing]
Hint: pegs [Processing]
Hint: unicode [Processing]
Hint: tables [Processing]
Hint: math [Processing]
Hint: packageinfo [Processing]
Hint: parsecfg [Processing]
Hint: lexbase [Processing]
Hint: json [Processing]
Hint: version [Processing]
Hint: common [Processing]
babel-master/packageinfo.nim(141, 5) Warning: 'existsKey' is deprecated [Deprecated]
babel-master/packageinfo.nim(149, 5) Warning: 'existsKey' is deprecated [Deprecated]
Hint: tools [Processing]
Hint: download [Processing]
gcc -c -w -O3 -fno-strict-aliasing -I/var/lib/stickshift/525387a75973caafd40003a0/app-root/data/639761/Nimrod/lib -o babel-master/nimcache/babel-master_babel.o babel-master/nimcache/babel-master_babel.c
gcc -c -w -O3 -fno-strict-aliasing -I/var/lib/stickshift/525387a75973caafd40003a0/app-root/data/639761/Nimrod/lib -o babel-master/nimcache/Nimrod_system.o babel-master/nimcache/Nimrod_system.c
gcc -c -w -O3 -fno-strict-aliasing -I/var/lib/stickshift/525387a75973caafd40003a0/app-root/data/639761/Nimrod/lib -o babel-master/nimcache/pure_httpclient.o babel-master/nimcache/pure_httpclient.c
gcc -c -w -O3 -fno-strict-aliasing -I/var/lib/stickshift/525387a75973caafd40003a0/app-root/data/639761/Nimrod/lib -o babel-master/nimcache/pure_sockets.o babel-master/nimcache/pure_sockets.c
gcc -c -w -O3 -fno-strict-aliasing -I/var/lib/stickshift/525387a75973caafd40003a0/app-root/data/639761/Nimrod/lib -o babel-master/nimcache/pure_os.o babel-master/nimcache/pure_os.c
gcc -c -w -O3 -fno-strict-aliasing -I/var/lib/stickshift/525387a75973caafd40003a0/app-root/data/639761/Nimrod/lib -o babel-master/nimcache/pure_strutils.o babel-master/nimcache/pure_strutils.c
gcc -c -w -O3 -fno-strict-aliasing -I/var/lib/stickshift/525387a75973caafd40003a0/app-root/data/639761/Nimrod/lib -o babel-master/nimcache/pure_parseutils.o babel-master/nimcache/pure_parseutils.c
gcc -c -w -O3 -fno-strict-aliasing -I/var/lib/stickshift/525387a75973caafd40003a0/app-root/data/639761/Nimrod/lib -o babel-master/nimcache/pure_times.o babel-master/nimcache/pure_times.c
gcc -c -w -O3 -fno-strict-aliasing -I/var/lib/stickshift/525387a75973caafd40003a0/app-root/data/639761/Nimrod/lib -o babel-master/nimcache/posix_posix.o babel-master/nimcache/posix_posix.c
gcc -c -w -O3 -fno-strict-aliasing -I/var/lib/stickshift/525387a75973caafd40003a0/app-root/data/639761/Nimrod/lib -o babel-master/nimcache/wrappers_openssl.o babel-master/nimcache/wrappers_openssl.c
gcc -c -w -O3 -fno-strict-aliasing -I/var/lib/stickshift/525387a75973caafd40003a0/app-root/data/639761/Nimrod/lib -o babel-master/nimcache/pure_parseurl.o babel-master/nimcache/pure_parseurl.c
gcc -c -w -O3 -fno-strict-aliasing -I/var/lib/stickshift/525387a75973caafd40003a0/app-root/data/639761/Nimrod/lib -o babel-master/nimcache/pure_strtabs.o babel-master/nimcache/pure_strtabs.c
gcc -c -w -O3 -fno-strict-aliasing -I/var/lib/stickshift/525387a75973caafd40003a0/app-root/data/639761/Nimrod/lib -o babel-master/nimcache/pure_hashes.o babel-master/nimcache/pure_hashes.c
gcc -c -w -O3 -fno-strict-aliasing -I/var/lib/stickshift/525387a75973caafd40003a0/app-root/data/639761/Nimrod/lib -o babel-master/nimcache/pure_base64.o babel-master/nimcache/pure_base64.c
gcc -c -w -O3 -fno-strict-aliasing -I/var/lib/stickshift/525387a75973caafd40003a0/app-root/data/639761/Nimrod/lib -o babel-master/nimcache/pure_parseopt.o babel-master/nimcache/pure_parseopt.c
gcc -c -w -O3 -fno-strict-aliasing -I/var/lib/stickshift/525387a75973caafd40003a0/app-root/data/639761/Nimrod/lib -o babel-master/nimcache/pure_osproc.o babel-master/nimcache/pure_osproc.c
gcc -c -w -O3 -fno-strict-aliasing -I/var/lib/stickshift/525387a75973caafd40003a0/app-root/data/639761/Nimrod/lib -o babel-master/nimcache/pure_streams.o babel-master/nimcache/pure_streams.c
gcc -c -w -O3 -fno-strict-aliasing -I/var/lib/stickshift/525387a75973caafd40003a0/app-root/data/639761/Nimrod/lib -o babel-master/nimcache/pure_pegs.o babel-master/nimcache/pure_pegs.c
gcc -c -w -O3 -fno-strict-aliasing -I/var/lib/stickshift/525387a75973caafd40003a0/app-root/data/639761/Nimrod/lib -o babel-master/nimcache/pure_unicode.o babel-master/nimcache/pure_unicode.c
gcc -c -w -O3 -fno-strict-aliasing -I/var/lib/stickshift/525387a75973caafd40003a0/app-root/data/639761/Nimrod/lib -o babel-master/nimcache/collections_tables.o babel-master/nimcache/collections_tables.c
gcc -c -w -O3 -fno-strict-aliasing -I/var/lib/stickshift/525387a75973caafd40003a0/app-root/data/639761/Nimrod/lib -o babel-master/nimcache/pure_math.o babel-master/nimcache/pure_math.c
gcc -c -w -O3 -fno-strict-aliasing -I/var/lib/stickshift/525387a75973caafd40003a0/app-root/data/639761/Nimrod/lib -o babel-master/nimcache/babel-master_packageinfo.o babel-master/nimcache/babel-master_packageinfo.c
gcc -c -w -O3 -fno-strict-aliasing -I/var/lib/stickshift/525387a75973caafd40003a0/app-root/data/639761/Nimrod/lib -o babel-master/nimcache/pure_parsecfg.o babel-master/nimcache/pure_parsecfg.c
gcc -c -w -O3 -fno-strict-aliasing -I/var/lib/stickshift/525387a75973caafd40003a0/app-root/data/639761/Nimrod/lib -o babel-master/nimcache/pure_lexbase.o babel-master/nimcache/pure_lexbase.c
gcc -c -w -O3 -fno-strict-aliasing -I/var/lib/stickshift/525387a75973caafd40003a0/app-root/data/639761/Nimrod/lib -o babel-master/nimcache/pure_json.o babel-master/nimcache/pure_json.c
gcc -c -w -O3 -fno-strict-aliasing -I/var/lib/stickshift/525387a75973caafd40003a0/app-root/data/639761/Nimrod/lib -o babel-master/nimcache/babel-master_version.o babel-master/nimcache/babel-master_version.c
gcc -c -w -O3 -fno-strict-aliasing -I/var/lib/stickshift/525387a75973caafd40003a0/app-root/data/639761/Nimrod/lib -o babel-master/nimcache/babel-master_common.o babel-master/nimcache/babel-master_common.c
gcc -c -w -O3 -fno-strict-aliasing -I/var/lib/stickshift/525387a75973caafd40003a0/app-root/data/639761/Nimrod/lib -o babel-master/nimcache/babel-master_tools.o babel-master/nimcache/babel-master_tools.c
gcc -c -w -O3 -fno-strict-aliasing -I/var/lib/stickshift/525387a75973caafd40003a0/app-root/data/639761/Nimrod/lib -o babel-master/nimcache/babel-master_download.o babel-master/nimcache/babel-master_download.c
gcc   -o /var/lib/stickshift/525387a75973caafd40003a0/app-root/data/639761/Nimrod/babel-master/babel  babel-master/nimcache/babel-master_download.o babel-master/nimcache/babel-master_tools.o babel-master/nimcache/babel-master_common.o babel-master/nimcache/babel-master_version.o babel-master/nimcache/pure_json.o babel-master/nimcache/pure_lexbase.o babel-master/nimcache/pure_parsecfg.o babel-master/nimcache/babel-master_packageinfo.o babel-master/nimcache/pure_math.o babel-master/nimcache/collections_tables.o babel-master/nimcache/pure_unicode.o babel-master/nimcache/pure_pegs.o babel-master/nimcache/pure_streams.o babel-master/nimcache/pure_osproc.o babel-master/nimcache/pure_parseopt.o babel-master/nimcache/pure_base64.o babel-master/nimcache/pure_hashes.o babel-master/nimcache/pure_strtabs.o babel-master/nimcache/pure_parseurl.o babel-master/nimcache/wrappers_openssl.o babel-master/nimcache/posix_posix.o babel-master/nimcache/pure_times.o babel-master/nimcache/pure_parseutils.o babel-master/nimcache/pure_strutils.o babel-master/nimcache/pure_os.o babel-master/nimcache/pure_sockets.o babel-master/nimcache/pure_httpclient.o babel-master/nimcache/Nimrod_system.o babel-master/nimcache/babel-master_babel.o  -ldl -lm
Hint: operation successful (25622 lines compiled; 10.480 sec total; 44.455MB) [SuccessX]
scriptbasic@nimrod:~/639761/Nimrod/babel-master (master) $ ./babel install
Installing babel-0.1.0
Building babel/babel using c backend...
config/nimrod.cfg(36, 2) Hint: added path: '/var/lib/stickshift/525387a75973caafd40003a0/app-root/data/.babel/pkgs/' [Path]
Hint: used config file '/var/lib/stickshift/525387a75973caafd40003a0/app-root/data/639761/Nimrod/config/nimrod.cfg' [Conf]
Hint: used config file '/var/lib/stickshift/525387a75973caafd40003a0/app-root/data/639761/Nimrod/babel-master/babel.nimrod.cfg' [Conf]
Hint: system [Processing]
Hint: babel [Processing]
Hint: httpclient [Processing]
Hint: sockets [Processing]
Hint: os [Processing]
Hint: strutils [Processing]
Hint: parseutils [Processing]
Hint: times [Processing]
Hint: posix [Processing]
Hint: openssl [Processing]
Hint: parseurl [Processing]
Hint: strtabs [Processing]
Hint: hashes [Processing]
Hint: base64 [Processing]
Hint: parseopt [Processing]
Hint: osproc [Processing]
Hint: streams [Processing]
Hint: pegs [Processing]
Hint: unicode [Processing]
Hint: tables [Processing]
Hint: math [Processing]
Hint: packageinfo [Processing]
Hint: parsecfg [Processing]
Hint: lexbase [Processing]
Hint: json [Processing]
Hint: version [Processing]
Hint: common [Processing]
babel-master/packageinfo.nim(141, 5) Warning: 'existsKey' is deprecated [Deprecated]
babel-master/packageinfo.nim(149, 5) Warning: 'existsKey' is deprecated [Deprecated]
Hint: tools [Processing]
Hint: download [Processing]
gcc -c -w -O3 -fno-strict-aliasing -I/var/lib/stickshift/525387a75973caafd40003a0/app-root/data/639761/Nimrod/lib -o babel-master/nimcache/babel-master_babel.o babel-master/nimcache/babel-master_babel.c
gcc   -o /var/lib/stickshift/525387a75973caafd40003a0/app-root/data/639761/Nimrod/babel-master/babel  babel-master/nimcache/babel-master_download.o babel-master/nimcache/babel-master_tools.o babel-master/nimcache/babel-master_common.o babel-master/nimcache/babel-master_version.o babel-master/nimcache/pure_json.o babel-master/nimcache/pure_lexbase.o babel-master/nimcache/pure_parsecfg.o babel-master/nimcache/babel-master_packageinfo.o babel-master/nimcache/pure_math.o babel-master/nimcache/collections_tables.o babel-master/nimcache/pure_unicode.o babel-master/nimcache/pure_pegs.o babel-master/nimcache/pure_streams.o babel-master/nimcache/pure_osproc.o babel-master/nimcache/pure_parseopt.o babel-master/nimcache/pure_base64.o babel-master/nimcache/pure_hashes.o babel-master/nimcache/pure_strtabs.o babel-master/nimcache/pure_parseurl.o babel-master/nimcache/wrappers_openssl.o babel-master/nimcache/posix_posix.o babel-master/nimcache/pure_times.o babel-master/nimcache/pure_parseutils.o babel-master/nimcache/pure_strutils.o babel-master/nimcache/pure_os.o babel-master/nimcache/pure_sockets.o babel-master/nimcache/pure_httpclient.o babel-master/nimcache/Nimrod_system.o babel-master/nimcache/babel-master_babel.o  -ldl -lm
Hint: operation successful (25622 lines compiled; 1.524 sec total; 44.455MB) [SuccessX]
/var/lib/stickshift/525387a75973caafd40003a0/app-root/data/639761/Nimrod/babel-master/license.txt -> /var/lib/stickshift/525387a75973caafd40003a0/app-root/data/.babel/pkgs/babel-0.1.0/license.txt
/var/lib/stickshift/525387a75973caafd40003a0/app-root/data/639761/Nimrod/babel-master/download.nim -> /var/lib/stickshift/525387a75973caafd40003a0/app-root/data/.babel/pkgs/babel-0.1.0/download.nim
/var/lib/stickshift/525387a75973caafd40003a0/app-root/data/639761/Nimrod/babel-master/common.nim -> /var/lib/stickshift/525387a75973caafd40003a0/app-root/data/.babel/pkgs/babel-0.1.0/common.nim
/var/lib/stickshift/525387a75973caafd40003a0/app-root/data/639761/Nimrod/babel-master/babel.babel -> /var/lib/stickshift/525387a75973caafd40003a0/app-root/data/.babel/pkgs/babel-0.1.0/babel.babel
/var/lib/stickshift/525387a75973caafd40003a0/app-root/data/639761/Nimrod/babel-master/babel.nimrod.cfg -> /var/lib/stickshift/525387a75973caafd40003a0/app-root/data/.babel/pkgs/babel-0.1.0/babel.nimrod.cfg
/var/lib/stickshift/525387a75973caafd40003a0/app-root/data/639761/Nimrod/babel-master/babel.babel -> /var/lib/stickshift/525387a75973caafd40003a0/app-root/data/.babel/pkgs/babel-0.1.0/babel.babel
/var/lib/stickshift/525387a75973caafd40003a0/app-root/data/639761/Nimrod/babel-master/tools.nim -> /var/lib/stickshift/525387a75973caafd40003a0/app-root/data/.babel/pkgs/babel-0.1.0/tools.nim
/var/lib/stickshift/525387a75973caafd40003a0/app-root/data/639761/Nimrod/babel-master/babel.nim -> /var/lib/stickshift/525387a75973caafd40003a0/app-root/data/.babel/pkgs/babel-0.1.0/babel.nim
/var/lib/stickshift/525387a75973caafd40003a0/app-root/data/639761/Nimrod/babel-master/packageinfo.nim -> /var/lib/stickshift/525387a75973caafd40003a0/app-root/data/.babel/pkgs/babel-0.1.0/packageinfo.nim
/var/lib/stickshift/525387a75973caafd40003a0/app-root/data/639761/Nimrod/babel-master/babel -> /var/lib/stickshift/525387a75973caafd40003a0/app-root/data/.babel/pkgs/babel-0.1.0/babel
/var/lib/stickshift/525387a75973caafd40003a0/app-root/data/639761/Nimrod/babel-master/todo.markdown -> /var/lib/stickshift/525387a75973caafd40003a0/app-root/data/.babel/pkgs/babel-0.1.0/todo.markdown
/var/lib/stickshift/525387a75973caafd40003a0/app-root/data/639761/Nimrod/babel-master/version.nim -> /var/lib/stickshift/525387a75973caafd40003a0/app-root/data/.babel/pkgs/babel-0.1.0/version.nim
/var/lib/stickshift/525387a75973caafd40003a0/app-root/data/639761/Nimrod/babel-master/readme.markdown -> /var/lib/stickshift/525387a75973caafd40003a0/app-root/data/.babel/pkgs/babel-0.1.0/readme.markdown
/var/lib/stickshift/525387a75973caafd40003a0/app-root/data/639761/Nimrod/babel-master/babel.babel -> /var/lib/stickshift/525387a75973caafd40003a0/app-root/data/.babel/pkgs/babel-0.1.0/babel.babel
Creating symlink: /var/lib/stickshift/525387a75973caafd40003a0/app-root/data/.babel/pkgs/babel-0.1.0/babel -> /var/lib/stickshift/525387a75973caafd40003a0/app-root/data/.babel/bin/babel
babel installed successfully.
scriptbasic@nimrod:~/639761/Nimrod/babel-master (master) $ ./babel -h
Usage: babel COMMAND [opts]

Commands:
  install      [pkgname, ...] Installs a list of packages.
  build                       Builds a package.
  update       [url]          Updates package list. A package list URL can be optionally specified.
  search       pkg/tag        Searches for a specified package. Search is performed by tag and by name.
  list                        Lists all packages.

Options:
  -h                          Print this help message.
  -v                          Print version information.

scriptbasic@nimrod:~/639761/Nimrod/babel-master (master) $ ./babel update
Downloading package list from https://github.com/nimrod-code/packages/raw/master/packages.json
Done.
scriptbasic@nimrod:~/639761/Nimrod/babel-master (master) $ ./babel build
Building babel/babel using c backend...
config/nimrod.cfg(36, 2) Hint: added path: '/var/lib/stickshift/525387a75973caafd40003a0/app-root/data/.babel/pkgs/babel-0.1.0' [Path]
config/nimrod.cfg(36, 2) Hint: added path: '/var/lib/stickshift/525387a75973caafd40003a0/app-root/data/.babel/pkgs/' [Path]
Hint: used config file '/var/lib/stickshift/525387a75973caafd40003a0/app-root/data/639761/Nimrod/config/nimrod.cfg' [Conf]
Hint: used config file '/var/lib/stickshift/525387a75973caafd40003a0/app-root/data/639761/Nimrod/babel-master/babel.nimrod.cfg' [Conf]
Hint: system [Processing]
Hint: babel [Processing]
Hint: httpclient [Processing]
Hint: sockets [Processing]
Hint: os [Processing]
Hint: strutils [Processing]
Hint: parseutils [Processing]
Hint: times [Processing]
Hint: posix [Processing]
Hint: openssl [Processing]
Hint: parseurl [Processing]
Hint: strtabs [Processing]
Hint: hashes [Processing]
Hint: base64 [Processing]
Hint: parseopt [Processing]
Hint: osproc [Processing]
Hint: streams [Processing]
Hint: pegs [Processing]
Hint: unicode [Processing]
Hint: tables [Processing]
Hint: math [Processing]
Hint: packageinfo [Processing]
Hint: parsecfg [Processing]
Hint: lexbase [Processing]
Hint: json [Processing]
Hint: version [Processing]
Hint: common [Processing]
babel-master/packageinfo.nim(141, 5) Warning: 'existsKey' is deprecated [Deprecated]
babel-master/packageinfo.nim(149, 5) Warning: 'existsKey' is deprecated [Deprecated]
Hint: tools [Processing]
Hint: download [Processing]
gcc -c -w -O3 -fno-strict-aliasing -I/var/lib/stickshift/525387a75973caafd40003a0/app-root/data/639761/Nimrod/lib -o babel-master/nimcache/babel-master_babel.o babel-master/nimcache/babel-master_babel.c
gcc   -o /var/lib/stickshift/525387a75973caafd40003a0/app-root/data/639761/Nimrod/babel-master/babel  babel-master/nimcache/babel-master_download.o babel-master/nimcache/babel-master_tools.o babel-master/nimcache/babel-master_common.o babel-master/nimcache/babel-master_version.o babel-master/nimcache/pure_json.o babel-master/nimcache/pure_lexbase.o babel-master/nimcache/pure_parsecfg.o babel-master/nimcache/babel-master_packageinfo.o babel-master/nimcache/pure_math.o babel-master/nimcache/collections_tables.o babel-master/nimcache/pure_unicode.o babel-master/nimcache/pure_pegs.o babel-master/nimcache/pure_streams.o babel-master/nimcache/pure_osproc.o babel-master/nimcache/pure_parseopt.o babel-master/nimcache/pure_base64.o babel-master/nimcache/pure_hashes.o babel-master/nimcache/pure_strtabs.o babel-master/nimcache/pure_parseurl.o babel-master/nimcache/wrappers_openssl.o babel-master/nimcache/posix_posix.o babel-master/nimcache/pure_times.o babel-master/nimcache/pure_parseutils.o babel-master/nimcache/pure_strutils.o babel-master/nimcache/pure_os.o babel-master/nimcache/pure_sockets.o babel-master/nimcache/pure_httpclient.o babel-master/nimcache/Nimrod_system.o babel-master/nimcache/babel-master_babel.o  -ldl -lm
Hint: operation successful (25622 lines compiled; 1.530 sec total; 44.455MB) [SuccessX]
scriptbasic@nimrod:~/639761/Nimrod/babel-master (master) $ ./babel list
argument_parser:
  url:         git://github.com/gradha/argument_parser/ (git)
  tags:        library, commandline, arguments, switches, parsing
  description: Provides a complex commandline parser
  license:     MIT
 
genieos:
  url:         git://github.com/gradha/genieos/ (git)
  tags:        library, commandline, sound, recycle, os
  description: Too awesome procs to be included in nimrod.os module
  license:     MIT
 
jester:
  url:         git://github.com/dom96/jester/ (git)
  tags:        web, http, framework, dsl
  description: A sinatra-like web framework for Nimrod.
  license:     MIT
 
libtcod-nim:
  url:         git://github.com/Vladar4/libtcod-nim/ (git)
  tags:        roguelike, game, library, engine, sdl, opengl, glsl
  description: Wrapper of the libtcod library for the Nimrod language.
  license:     MIT
 
nimepak:
  url:         git://github.com/gradha/epak/ (git)
  tags:        library, serialization, file, compression
  description: File compression routines in C for iOS and Nimrod
  license:     Allegro 4 Giftware
 
nimgame:
  url:         git://github.com/Vladar4/nimgame/ (git)
  tags:        game, engine, sdl
  description: Simple 2D game engine for Nimrod language.
  license:     MIT
 
sfml:
  url:         git://github.com/fowlmouth/nimrod-sfml/ (git)
  tags:        game, library, opengl
  description: High level OpenGL-based Game Library
  license:     MIT
 
enet:
  url:         git://github.com/fowlmouth/nimrod-enet/ (git)
  tags:        game, networking, udp
  description: Wrapper for ENet UDP networking library
  license:     MIT
 
nim-locale:
  url:         git://github.com/Amrykid/nim-locale/ (git)
  tags:        library, locale, i18n, localization, localisation, globalization
  description: A simple library for localizing Nimrod applications.
  license:     MIT
 
fowltek:
  url:         git://github.com/fowlmouth/nimlibs/ (git)
  tags:        game, opengl, wrappers, library, assorted
  description: A collection of reusable modules and wrappers.
  license:     MIT
 
nake:
  url:         git://github.com/fowlmouth/nake/ (git)
  tags:        build, automation, sortof
  description: make-like for Nimrod. Describe your builds as tasks!
  license:     DATWPL
 
nimrod-glfw:
  url:         git://github.com/rafaelvasco/nimrod-glfw/ (git)
  tags:        library, glfw, opengl, windowing, game
  description: Nimrod bindings for GLFW library.
  license:     MIT
 
chipmunk:
  url:         git://github.com/fowlmouth/nimrod-chipmunk/ (git)
  tags:        library, physics, game
  description: Binding for Chipmunk 6.1
  license:     MIT
 
nim-glfw3:
  url:         git://github.com/EXetoC/nim-glfw3/ (git)
  tags:        library, glfw, opengl, windowing, game
  description: A High-level GLFW 3 wrapper for the Nimrod programming language
  license:     MIT
 
nim-ao:
  url:         git://github.com/EXetoC/nim-ao/ (git)
  tags:        library, audio
  description: A libao wrapper for the Nimrod programming language
  license:     MIT
 
termbox:
  url:         git://github.com/fowlmouth/nim-termbox (git)
  tags:        library, terminal, io
  description: Termbox wrapper.
  license:     MIT
 
linagl:
  url:         https://bitbucket.org/TheLonelyByte/linagl (hg)
  tags:        library, opengl, math, game
  description: OpenGL math library
  license:     CC0
 
kwin:
  url:         git://github.com/reactormonk/nim-kwin (git)
  tags:        library, javascript, kde
  description: KWin JavaScript API wrapper
  license:     MIT
 
opencv:
  url:         git://github.com/dom96/nim-opencv (git)
  tags:        library, wrapper, opencv, image, processing
  description: OpenCV wrapper
  license:     MIT
 
babel:
  url:         git://github.com/nimrod-code/babel (git)
  tags:        app, binary, package, manager
  description: Babel package manager
  license:     BSD
 
aporia:
  url:         git://github.com/nimrod-code/Aporia (git)
  tags:        app, binary, ide, gtk, nimrod
  description: A Nimrod IDE.
  license:     GPLv2
 
ipsumgenera:
  url:         git://github.com/dom96/ipsumgenera (git)
  tags:        app, binary, blog, static, generator
  description: Static blog generator ala Jekyll.
  license:     MIT
 
pastebin:
  url:         git://github.com/achesak/nimrod-pastebin (git)
  tags:        library, wrapper, pastebin
  description: Pastebin API wrapper
  license:     MIT
 
yahoo-weather:
  url:         git://github.com/achesak/nimrod-yahoo-weather (git)
  tags:        library, wrapper, weather
  description: Yahoo! Weather API wrapper
  license:     MIT
 
scriptbasic@nimrod:~/639761/Nimrod/babel-master (master) $

cairoex
Code: [Select]
import cairo

var surface = image_surface_create(FORMAT_ARGB32, 240, 80)
var cr = create(surface)

select_font_face(cr, "serif", FONT_SLANT_NORMAL,
                              FONT_WEIGHT_BOLD)
set_font_size(cr, 32.0)
set_source_rgb(cr, 0.0, 0.0, 1.0)
move_to(cr, 10.0, 50.0)
show_text(cr, "Hello, world")
destroy(cr)
discard write_to_png(surface, "hello.png")
destroy(surface)


criptbasic@nimrod:~/639761/Nimrod/examples (master) $ nimrod c -d:release cairoex.nim
config/nimrod.cfg(36, 2) Hint: added path: '/var/lib/stickshift/525387a75973caafd40003a0/app-root/data/.babel/pkgs/babel-0.1.0' [Path]
config/nimrod.cfg(36, 2) Hint: added path: '/var/lib/stickshift/525387a75973caafd40003a0/app-root/data/.babel/pkgs/' [Path]
Hint: used config file '/var/lib/stickshift/525387a75973caafd40003a0/app-root/data/639761/Nimrod/config/nimrod.cfg' [Conf]
Hint: system [Processing]
Hint: cairoex [Processing]
Hint: cairo [Processing]
gcc -c -w -O3 -fno-strict-aliasing -I/var/lib/stickshift/525387a75973caafd40003a0/app-root/data/639761/Nimrod/lib -o examples/nimcache/examples_cairoex.o examples/nimcac
gcc -c -w -O3 -fno-strict-aliasing -I/var/lib/stickshift/525387a75973caafd40003a0/app-root/data/639761/Nimrod/lib -o examples/nimcache/Nimrod_system.o examples/nimcache/
gcc -c -w -O3 -fno-strict-aliasing -I/var/lib/stickshift/525387a75973caafd40003a0/app-root/data/639761/Nimrod/lib -o examples/nimcache/cairo_cairo.o examples/nimcache/ca
gcc   -o /var/lib/stickshift/525387a75973caafd40003a0/app-root/data/639761/Nimrod/examples/cairoex  examples/nimcache/cairo_cairo.o examples/nimcache/Nimrod_system.o exa
Hint: operation successful (8439 lines compiled; 6.252 sec total; 9.922MB) [SuccessX]
scriptbasic@nimrod:~/639761/Nimrod/examples (master) $


« Last Edit: October 07, 2013, 11:11:36 PM by John »

Offline John

  • Forum Support / SB Dev
  • Posts: 3597
    • ScriptBasic Open Source Project
Nimrod - nimgame
« Reply #56 on: October 08, 2013, 12:08:51 AM »
nimgame

Simple 2D game engine for Nimrod language.

This is a Babel installed library. I have posted the API docs HERE.

UFO Attack nimgame API Windows example.



Code: [Select]
import
  sdl, math, common, state, entity, image, imageex, sprite, text, input, engine, collider,
  ufoattack_player, ufoattack_ufo, ufoattack_stars

type
  PGameState* = ref TGameState
  TGameState* = object of TState
    player: PPlayer
    score: PEntity
    addStarCounter, addStarInterval: int
    addStarIntervalMin, addStarIntervalMax, addStarNum: int
    addUfoCounter, addUfoInterval: int


proc free*(obj: PGameState) =
  PState(obj).free()


proc init*(obj: PGameState) =
  obj.player = newPlayer(obj)
  obj.add(obj.player)
  obj.score = newEntity(newText("fnt/DejaVuSans.ttf", text="0",
                                size=18, color=color(250, 250, 0)),
                        2, 580)
  obj.add(obj.score)
  # stars
  initStars()
  obj.addStarCounter = 0
  obj.addStarIntervalMin = 10
  obj.addStarIntervalMax = 30
  obj.addStarInterval = random(obj.addStarIntervalMax - obj.addStarIntervalMin) + obj.addStarIntervalMin
  obj.addStarNum = 3
  for i in 0..50:
    addStar(random(screen().h))
  # ufo
  obj.addUfoCounter = 0
  obj.addUfoInterval = 50

proc newGameState*(): PGameState =
  new(result, free)
  init(PState(result))
  init(result)


# Update

proc updateGameState*(obj: PGameState) =
  obj.updateState()
  # Stars
  if obj.addStarCounter >= obj.addStarInterval:
    for i in 0..random(obj.addStarNum):
      addStar()
    obj.addStarCounter = 0
    obj.addStarInterval = random(obj.addStarIntervalMax - obj.addStarIntervalMin) + obj.addStarIntervalMin
  else:
    obj.addStarCounter += 1
  updateStars()
  # Ufo
  if obj.addUfoCounter >= obj.addUfoInterval:
    obj.add(newUfo(4))
    obj.addUfoCounter = 0
  else:
    obj.addUfoCounter += 1
  # Collide
  if obj.collideWith(obj.player, "ufo") != nil:
    obj.player.delete()
  let collisions = obj.collideList("shot", "ufo")
  for pair in collisions.items():
    pair.a.delete()
    pair.b.delete()
    obj.player.score += 10
  # Update score
  PText(obj.score.graphic).text = obj.player.score.repr
  # Toggle FPS
  if isKeyDown(K_f):
    if game.fps:
      game.fps = false
    else:
      game.fps = true

method update*(obj: PGameState) {.inline.} =
  obj.updateGameState()

# Render

proc renderGameState*(obj: PGameState) =
  blitStars()
  obj.renderState()

method render*(obj: PGameState) {.inline.} =
  obj.renderGameState()
« Last Edit: October 08, 2013, 05:14:01 PM by John »

Offline John

  • Forum Support / SB Dev
  • Posts: 3597
    • ScriptBasic Open Source Project
Nimrod - Inline ASM
« Reply #57 on: October 08, 2013, 02:01:31 AM »
Assembler statement

The direct embedding of assembler code into Nimrod code is supported by the unsafe asm statement. Identifiers in the assembler code that refer to Nimrod identifiers shall be enclosed in a special character which can be specified in the statement's pragmas. The default special character is '`':

Code: [Select]
proc addInt(a, b: int): int {.noStackFrame.} =
  # a in eax, and b in edx
  asm """
      mov eax, `a`
      add eax, `b`
      jno theEnd
      call `raiseOverflow`
    theEnd:
  """

I would think that Nimrod would be a much better language for Charles to use for OxygenBasic. He could use Nimrod to handle the platform specifics while he gets cross platform ASM code stable. The C emitter is already done for him.

arithm.nim (std lib)
Code: [Select]
#
#
#            Nimrod's Runtime Library
#        (c) Copyright 2012 Andreas Rumpf
#
#    See the file "copying.txt", included in this
#    distribution, for details about the copyright.
#


# simple integer arithmetic with overflow checking

proc raiseOverflow {.compilerproc, noinline, noreturn.} =
  # a single proc to reduce code size to a minimum
  sysFatal(EOverflow, "over- or underflow")

proc raiseDivByZero {.compilerproc, noinline, noreturn.} =
  sysFatal(EDivByZero, "divison by zero")

proc addInt64(a, b: int64): int64 {.compilerProc, inline.} =
  result = a +% b
  if (result xor a) >= int64(0) or (result xor b) >= int64(0):
    return result
  raiseOverflow()

proc subInt64(a, b: int64): int64 {.compilerProc, inline.} =
  result = a -% b
  if (result xor a) >= int64(0) or (result xor not b) >= int64(0):
    return result
  raiseOverflow()

proc negInt64(a: int64): int64 {.compilerProc, inline.} =
  if a != low(int64): return -a
  raiseOverflow()

proc absInt64(a: int64): int64 {.compilerProc, inline.} =
  if a != low(int64):
    if a >= 0: return a
    else: return -a
  raiseOverflow()

proc divInt64(a, b: int64): int64 {.compilerProc, inline.} =
  if b == int64(0):
    raiseDivByZero()
  if a == low(int64) and b == int64(-1):
    raiseOverflow()
  return a div b

proc modInt64(a, b: int64): int64 {.compilerProc, inline.} =
  if b == int64(0):
    raiseDivByZero()
  return a mod b

#
# This code has been inspired by Python's source code.
# The native int product x*y is either exactly right or *way* off, being
# just the last n bits of the true product, where n is the number of bits
# in an int (the delivered product is the true product plus i*2**n for
# some integer i).
#
# The native float64 product x*y is subject to three
# rounding errors: on a sizeof(int)==8 box, each cast to double can lose
# info, and even on a sizeof(int)==4 box, the multiplication can lose info.
# But, unlike the native int product, it's not in *range* trouble:  even
# if sizeof(int)==32 (256-bit ints), the product easily fits in the
# dynamic range of a float64. So the leading 50 (or so) bits of the float64
# product are correct.
#
# We check these two ways against each other, and declare victory if they're
# approximately the same. Else, because the native int product is the only
# one that can lose catastrophic amounts of information, it's the native int
# product that must have overflowed.
#
proc mulInt64(a, b: int64): int64 {.compilerproc.} =
  var
    resAsFloat, floatProd: float64
  result = a *% b
  floatProd = toBiggestFloat(a) # conversion
  floatProd = floatProd * toBiggestFloat(b)
  resAsFloat = toBiggestFloat(result)

  # Fast path for normal case: small multiplicands, and no info
  # is lost in either method.
  if resAsFloat == floatProd: return result

  # Somebody somewhere lost info. Close enough, or way off? Note
  # that a != 0 and b != 0 (else resAsFloat == floatProd == 0).
  # The difference either is or isn't significant compared to the
  # true value (of which floatProd is a good approximation).

  # abs(diff)/abs(prod) <= 1/32 iff
  #   32 * abs(diff) <= abs(prod) -- 5 good bits is "close enough"
  if 32.0 * abs(resAsFloat - floatProd) <= abs(floatProd):
    return result
  raiseOverflow()


proc absInt(a: int): int {.compilerProc, inline.} =
  if a != low(int):
    if a >= 0: return a
    else: return -a
  raiseOverflow()

const
  asmVersion = defined(I386) and (defined(vcc) or defined(wcc) or
               defined(dmc) or defined(gcc) or defined(llvm_gcc))
    # my Version of Borland C++Builder does not have
    # tasm32, which is needed for assembler blocks
    # this is why Borland is not included in the 'when'

when asmVersion and not defined(gcc) and not defined(llvm_gcc):
  # assembler optimized versions for compilers that
  # have an intel syntax assembler:
  proc addInt(a, b: int): int {.compilerProc, noStackFrame.} =
    # a in eax, and b in edx
    asm """
        mov eax, `a`
        add eax, `b`
        jno theEnd
        call `raiseOverflow`
      theEnd:
    """

  proc subInt(a, b: int): int {.compilerProc, noStackFrame.} =
    asm """
        mov eax, `a`
        sub eax, `b`
        jno theEnd
        call `raiseOverflow`
      theEnd:
    """

  proc negInt(a: int): int {.compilerProc, noStackFrame.} =
    asm """
        mov eax, `a`
        neg eax
        jno theEnd
        call `raiseOverflow`
      theEnd:
    """

  proc divInt(a, b: int): int {.compilerProc, noStackFrame.} =
    asm """
        mov eax, `a`
        mov ecx, `b`
        xor edx, edx
        idiv ecx
        jno  theEnd
        call `raiseOverflow`
      theEnd:
    """

  proc modInt(a, b: int): int {.compilerProc, noStackFrame.} =
    asm """
        mov eax, `a`
        mov ecx, `b`
        xor edx, edx
        idiv ecx
        jno theEnd
        call `raiseOverflow`
      theEnd:
        mov eax, edx
    """

  proc mulInt(a, b: int): int {.compilerProc, noStackFrame.} =
    asm """
        mov eax, `a`
        mov ecx, `b`
        xor edx, edx
        imul ecx
        jno theEnd
        call `raiseOverflow`
      theEnd:
    """

elif false: # asmVersion and (defined(gcc) or defined(llvm_gcc)):
  proc addInt(a, b: int): int {.compilerProc, inline.} =
    # don't use a pure proc here!
    asm """
      "addl %%ecx, %%eax\n"
      "jno 1\n"
      "call _raiseOverflow\n"
      "1: \n"
      :"=a"(`result`)
      :"a"(`a`), "c"(`b`)
    """
    #".intel_syntax noprefix"
    #/* Intel syntax here */
    #".att_syntax"

  proc subInt(a, b: int): int {.compilerProc, inline.} =
    asm """ "subl %%ecx,%%eax\n"
            "jno 1\n"
            "call _raiseOverflow\n"
            "1: \n"
           :"=a"(`result`)
           :"a"(`a`), "c"(`b`)
    """

  proc mulInt(a, b: int): int {.compilerProc, inline.} =
    asm """  "xorl %%edx, %%edx\n"
             "imull %%ecx\n"
             "jno 1\n"
             "call _raiseOverflow\n"
             "1: \n"
            :"=a"(`result`)
            :"a"(`a`), "c"(`b`)
            :"%edx"
    """

  proc negInt(a: int): int {.compilerProc, inline.} =
    asm """ "negl %%eax\n"
            "jno 1\n"
            "call _raiseOverflow\n"
            "1: \n"
           :"=a"(`result`)
           :"a"(`a`)
    """

  proc divInt(a, b: int): int {.compilerProc, inline.} =
    asm """  "xorl %%edx, %%edx\n"
             "idivl %%ecx\n"
             "jno 1\n"
             "call _raiseOverflow\n"
             "1: \n"
            :"=a"(`result`)
            :"a"(`a`), "c"(`b`)
            :"%edx"
    """

  proc modInt(a, b: int): int {.compilerProc, inline.} =
    asm """  "xorl %%edx, %%edx\n"
             "idivl %%ecx\n"
             "jno 1\n"
             "call _raiseOverflow\n"
             "1: \n"
             "movl %%edx, %%eax"
            :"=a"(`result`)
            :"a"(`a`), "c"(`b`)
            :"%edx"
    """

# Platform independent versions of the above (slower!)
when not defined(addInt):
  proc addInt(a, b: int): int {.compilerProc, inline.} =
    result = a +% b
    if (result xor a) >= 0 or (result xor b) >= 0:
      return result
    raiseOverflow()

when not defined(subInt):
  proc subInt(a, b: int): int {.compilerProc, inline.} =
    result = a -% b
    if (result xor a) >= 0 or (result xor not b) >= 0:
      return result
    raiseOverflow()

when not defined(negInt):
  proc negInt(a: int): int {.compilerProc, inline.} =
    if a != low(int): return -a
    raiseOverflow()

when not defined(divInt):
  proc divInt(a, b: int): int {.compilerProc, inline.} =
    if b == 0:
      raiseDivByZero()
    if a == low(int) and b == -1:
      raiseOverflow()
    return a div b

when not defined(modInt):
  proc modInt(a, b: int): int {.compilerProc, inline.} =
    if b == 0:
      raiseDivByZero()
    return a mod b

when not defined(mulInt):
  #
  # This code has been inspired by Python's source code.
  # The native int product x*y is either exactly right or *way* off, being
  # just the last n bits of the true product, where n is the number of bits
  # in an int (the delivered product is the true product plus i*2**n for
  # some integer i).
  #
  # The native float64 product x*y is subject to three
  # rounding errors: on a sizeof(int)==8 box, each cast to double can lose
  # info, and even on a sizeof(int)==4 box, the multiplication can lose info.
  # But, unlike the native int product, it's not in *range* trouble:  even
  # if sizeof(int)==32 (256-bit ints), the product easily fits in the
  # dynamic range of a float64. So the leading 50 (or so) bits of the float64
  # product are correct.
  #
  # We check these two ways against each other, and declare victory if
  # they're approximately the same. Else, because the native int product is
  # the only one that can lose catastrophic amounts of information, it's the
  # native int product that must have overflowed.
  #
  proc mulInt(a, b: int): int {.compilerProc.} =
    var
      resAsFloat, floatProd: float

    result = a *% b
    floatProd = toFloat(a) * toFloat(b)
    resAsFloat = toFloat(result)

    # Fast path for normal case: small multiplicands, and no info
    # is lost in either method.
    if resAsFloat == floatProd: return result

    # Somebody somewhere lost info. Close enough, or way off? Note
    # that a != 0 and b != 0 (else resAsFloat == floatProd == 0).
    # The difference either is or isn't significant compared to the
    # true value (of which floatProd is a good approximation).

    # abs(diff)/abs(prod) <= 1/32 iff
    #   32 * abs(diff) <= abs(prod) -- 5 good bits is "close enough"
    if 32.0 * abs(resAsFloat - floatProd) <= abs(floatProd):
      return result
    raiseOverflow()

# We avoid setting the FPU control word here for compatibility with libraries
# written in other languages.

proc raiseFloatInvalidOp {.noinline, noreturn.} =
  sysFatal(EFloatInvalidOp, "FPU operation caused a NaN result")

proc nanCheck(x: float64) {.compilerProc, inline.} =
  if x != x: raiseFloatInvalidOp()

proc raiseFloatOverflow(x: float64) {.noinline, noreturn.} =
  if x > 0.0:
    sysFatal(EFloatOverflow, "FPU operation caused an overflow")
  else:
    sysFatal(EFloatUnderflow, "FPU operations caused an underflow")

proc infCheck(x: float64) {.compilerProc, inline.} =
  if x != 0.0 and x*0.5 == x: raiseFloatOverflow(x)


Those """'s sure look familiar.  :)
« Last Edit: October 08, 2013, 02:17:16 AM by John »

kryton9

  • Guest
Other libraries
« Reply #58 on: October 10, 2013, 07:11:01 PM »
I found today while researching that other libraries(wrappers) do exist for Nimrod that are not listed in their list.
So something to keep in mind, if there is a library you would like to use that is not on the list.
The current list: http://nimrod-code.org/lib.html

Here is one I found today:
https://github.com/fowlmouth/nimrod-sfml




Offline John

  • Forum Support / SB Dev
  • Posts: 3597
    • ScriptBasic Open Source Project
Re: Nimrod
« Reply #59 on: October 10, 2013, 08:25:09 PM »
Here are a couple screen shots from their included demos. I had to install an older version (1.5 / current 1.6) of GLEW to get it to run.

« Last Edit: October 10, 2013, 10:34:10 PM by John »