This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import io/[Writer, Reader] | |
/** | |
Multi-Purpose Buffer class. | |
This is a String, with guaranteed mutability. | |
All operations will be done on the Buffer itself, instead of a clone. | |
Other difference from String: the constructor will set capacity, not size. | |
*/ | |
Buffer: class extends String{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
XString: class { | |
data : Char* | |
size : SizeT | |
init: func (src: Char*, =size) { | |
data = gc_malloc(size) | |
memcpy (data, src, size) | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using Posix; | |
[Compact] | |
public class Test { | |
public void test() { | |
stdout.puts ("foo\n"); | |
} | |
} | |
static int main(){ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
opening file nagtest.ooc for read... | |
full name nagtest | |
myst name . | |
/home/rofl/dev/rock/sdk/lang/Exception.ooc | |
/home/rofl/dev/rock/sdk/lang/System.ooc | |
/home/rofl/dev/rock/sdk/lang/Memory.ooc | |
/home/rofl/dev/rock/sdk/lang/types.ooc~ | |
/home/rofl/dev/rock/sdk/lang/types.ooc | |
/home/rofl/dev/rock/sdk/lang/Numbers.ooc | |
/home/rofl/dev/rock/sdk/lang/Buffer.ooc |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
OOC: Changes to String | |
String is now a class, which wraps a Buffer in a immutable way. | |
this means every method that can change the string, like trim, is executed on a clone of the internal buffer, then a new String including that buffer is returned. | |
the other difference between string and buffer is, that methods for the buffer are mostly of void return type, while String always returns a new instance. so you can do something like | |
// s infers to String here | |
s := " /tmp/aaa/bbb " trim() replaceAll("/", "\\") reverse() | |
here a new string is created, then each time a clone created and the method applied on the clones buffer | |
so this makes for at least 4 memory allocations and complete memcpy, which isnt very efficient. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
main: func (argc: Int, argv: Char**) { | |
for (i in 1..argc) printf (argv[i]) | |
} | |
$ rm -rf .libs/ rock_tmp/ && rock plain.ooc -gc=dynamic +-Os -dce | |
$ ls -lat plain | |
-rwxr-xr-x 1 rofl users 133283 31. Aug 18:50 plain | |
$ objdump -t plain |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.PHONY: all clean mrproper prepare_bootstrap bootstrap install rescue backup | |
PARSER_GEN=greg | |
NQ_PATH=source/rock/frontend/NagaQueen.c | |
DATE=$(shell date +%Y-%m-%d) | |
TIME=$(shell date +%H:%M) | |
OOC_WARN_FLAGS?=+-w | |
OOC_OWN_FLAGS=-sourcepath=source -v +-O0 -g +-rdynamic -ignoredefine=ROCK_BUILD_ ${OOC_WARN_FLAGS} | |
PREFIX?=/usr | |
MAN_INSTALL_PATH?=/usr/local/man/man1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function Execute(const Cmd: string): Integer; | |
var | |
ProcessInfo: TProcessInformation; | |
StartupInfo: TStartupInfo; | |
begin | |
StartupInfo.cb := SizeOf(StartupInfo); | |
GetStartupInfo(StartupInfo); | |
if CreateProcess(nil, PChar(Cmd), nil, nil, True, 0, nil, | |
PChar(ExtractFilepath(ParamStr(0))), StartupInfo, ProcessInfo) then | |
begin |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import text/BufferFile | |
import structs/ArrayList | |
main: func(args: ArrayList<String>) { | |
for (x in 1..args size) { | |
b := Buffer new() | |
if (!(b fromFile(args get(x)))) Exception new("file not found") throw() | |
("filesize is " + b size toString()) println() | |
openB := 0 | |
closeB := 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import text/Opts | |
import structs/ArrayList | |
main: func(args : ArrayList<String>) { | |
opts := Opts new(args) | |
if (opts set?("g")) println("g set") | |
if (opts set?("v")) println("v set") | |
if (opts set?("vv")) println("vv set") | |
if (opts set?("dce")) println("dce set") | |
if (opts set?("gc")) println("gc set to " + opts get("gc")) |
OlderNewer