Skip to content

Instantly share code, notes, and snippets.

@CoderPuppy
Last active January 2, 2016 09:49
Show Gist options
  • Save CoderPuppy/8285557 to your computer and use it in GitHub Desktop.
Save CoderPuppy/8285557 to your computer and use it in GitHub Desktop.
/*Base: abstract class {
print: abstract func(foo: Foo)
}
Foo: class extends Base {
name: String
init: func(=name)
print: func(foo: Foo) {
raise(foo name)
}
}
Bar: class {
init: func //(name) { super(name) }
fn: static func(baz: Base, args: ...) {
baz2: Base
baz2 = Baz new()
i := 0
args each(|arg|
match arg {
case foo: Foo => {
baz print(foo)
baz2 print(foo)
}
}
i += 1
)
}
}
Baz: class extends Base {
init: func
print: func(foo: Foo) {
foo name println()
}
}
Bar fn(Baz new(), Foo new("hi"))*/
import structs/ArrayList
PUserData: abstract class {}
PObject: class extends PUserData {
runtime: PRuntime
init: func(=runtime)
receive: func(call: PCall) -> PObject { null }
operator [](name: PUserData) -> PObject { null }
operator []=(name: PUserData, obj: PObject) -> PObject { null }
}
PRuntime: class {}
PMsg: class extends PUserData {
args := ArrayList<PMsgSeq> new()
init: func(id: PUserData)
}
PMsgSeq: class extends PUserData {
init: func(args: ...)
}
PSymbol: class extends PUserData {
val: String
init: func(=val)
}
PCall: class extends PUserData {
runtime: PRuntime
seq: PMsgSeq
msg: PMsg
ground: PObject
receiver: PObject
init: func(=runtime, =ground, =seq, =receiver, =msg)
fromObjects: static func(runtime: PRuntime, receiver: PObject, id: PUserData, args: ...) -> This {
ground := PObject new(runtime)
msg := PMsg new(id)
seq := PMsgSeq new(msg)
i := 1
args each(|arg|
match arg {
case obj: PObject => {
sym := PSymbol new(i toString())
msg args add(PMsgSeq new(PMsg new(sym)))
ground[sym] = obj
i += 1
}
}
)
return This new(runtime, ground, seq, receiver, msg)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment