Skip to content

Instantly share code, notes, and snippets.

Finished parsing, now tinkering...
=======================================
Tinkerer, round 1, 33 left
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Resolving module test
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
@alexnask
alexnask / test.ooc
Created September 2, 2011 04:58
Is that valid? :D
Foo: class {
f: static func(this: This, a: Int) {
a toString() println()
}
}
foo := Foo new()
foo f(42) // Is dat valid? :O Will test it later
@alexnask
alexnask / ModuleWriter.ooc
Created September 2, 2011 17:08
Possible fix
// We eliminate any generic variable that is passed as a "true" function argument
// E.g. in __va_call: inline func <T> (f: Func <T> (T), T: Class, arg: T)
typeArgs := fDecl typeArgs filter(|arg| !fDecl args contains?(arg))
/* Step 3 : write generic type args */
for(typeArg in typeArgs) {
if(isFirst) isFirst = false
else hw app(", ")
hw app(typeArg getName())
}
@alexnask
alexnask / test.ooc
Created September 3, 2011 13:34
Kew
use tcc
import tcc
program := "int function(int n) \
{\
printf(\"Hello World! (%d)\\n\",n);\
doStuff(42);
return 0;\
}"
@alexnask
alexnask / plugin.ooc
Created September 3, 2011 14:14
Simple plugin system
use tcc
import tcc
import structs/HashMap
Plugin: class {
state: Tcc
name: String
mem: Pointer
size: Int
methods := HashMap<String,Func(This)> new()
@alexnask
alexnask / problem.cpp
Created January 24, 2012 14:49
Solving a simple problem sub-optimally
#include <iostream>
#include <cstdlib>
#include <sstream>
class Table {
private:
int cells[10][10];
int currX, currY;
static int times;
This file has been truncated, but you can view the full file.
Trying path ./test.ooc
Parsing ./test.ooc
Trying path ./lang/String.ooc
Trying path /home/shamanas/Stuff/rock/sdk/lang/String.ooc
Parsing /home/shamanas/Stuff/rock/sdk/lang/String.ooc
Trying path ./lang/BufferIterator.ooc
Trying path /home/shamanas/Stuff/rock/sdk/lang/BufferIterator.ooc
Parsing /home/shamanas/Stuff/rock/sdk/lang/BufferIterator.ooc
Trying path ./lang/String.ooc
Trying path /home/shamanas/Stuff/rock/sdk/lang/String.ooc
@alexnask
alexnask / composition1.ooc
Created May 3, 2012 23:52
Attempt to create a function composition operator in ooc
// This does not work, rock moans that there is not enough info to resolve return type T of function call... BS if you ask me :P
operator => <T,K,V> (l: Func(V)->T, r: Func(K)->V)-> Func(K)->T {
func(arg: K) -> T {
l(r(arg))
}
}
// Haskell: f = g . h
// Equivalent to f x = g (h x)
@alexnask
alexnask / GLib.ooc
Created May 6, 2012 15:32
A portion of the code generated by gooc-gen for Gtk-2.0
/**
NAMESPACE GLib
Generated by gooc-gen
Please report any bugs at http://github.com/shamanas/gooc-gen/issues
**/
ALLOCATOR_LIST : extern(G_ALLOCATOR_LIST) const Int32
ALLOCATOR_NODE : extern(G_ALLOCATOR_NODE) const Int32
ALLOCATOR_SLIST : extern(G_ALLOCATOR_SLIST) const Int32
@alexnask
alexnask / test.ooc
Created May 13, 2012 16:02
testcase
Foo: class {
if(true) "yay" println()
f: func {
}
if(true) "noes" println()
}