[NTLK] newt/0: new features

From: matthiasm <mm_at_matthiasm.com>
Date: Thu Feb 19 2009 - 11:13:51 EST

Hi programmers,

I added a few bts of functionality to Makoto Nukui's NewtonScript
compiler.

For those of you who do not know Newt/0. This is a compiler and
interpreter for NewtonScript programs that runs on Mac OS X, Linux,
and a few other platforms. This is great if you want to learn the
first few steps of NewtonScript without haveing to set up NTK and
friends, but is somewhat limited because most of the functionality of
NOS is missing.

Anyway, here we go (svn revision 138):

new function:
- LoadBinary(filename) creates a binary object from a file on the host
disk
- SaveBinary(binary, filename) writes a file to disk as a copy of
binary object
- MakeBinaryFromHex(hex, klass) creat a binary object from a string of
hexadecimal characters

new variables:
- printIndent: if positive, indent printout by n tabs, if negative,
use spaces
- printBinaries: print binary objects as 'MakeBinaryFromHex(...)'

What gives:

You can load any pkg file:
   pkg := LoadBinary("some.pkg");
then unpack it
   prog := ReadPkg(pkg);
maybe print it
   printIndent := 1; printDepth := 999; printLength := 999;
   printBinaries := 1;
   print(prog);
then change stuff inside the program (or even inside the printout!)
   prog.name := "NewName:SIG";
then pack it again
   newPkg = MakePkg(prog);
and write it back to disk
   writeBinary(newPkg, "someNew.pkg");

The resulting package will be larger because it does not optimize for
duplicate data structures, however there is a good chance that the new
program will behave quite like to original one.

Matthias

PS: functions are only shown as binary blocks at this point.

----
http://robowerk.com/
==================================================================== 
The NewtonTalk Mailing List - http://www.newtontalk.net/
The Official Newton FAQ     - http://www.splorp.com/newton/faq/
The Newton Glossary         - http://www.splorp.com/newton/glossary/
WikiWikiNewt                - http://tools.unna.org/wikiwikinewt/
====================================================================
Received on Thu Feb 19 11:14:01 2009

This archive was generated by hypermail 2.1.8 : Thu Feb 19 2009 - 22:30:01 EST