Skip to content

Instantly share code, notes, and snippets.

@jimsynz
Last active August 29, 2015 14:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jimsynz/895d1d5eba8471f687b0 to your computer and use it in GitHub Desktop.
Save jimsynz/895d1d5eba8471f687b0 to your computer and use it in GitHub Desktop.
!RBIX
3820501463222725467
0
M
1
n
n
n
i
19
44
46
0
46
1
46
2
7
3
100
57
4
51
5
0
50
6
2
11
I
4
I
0
I
0
I
0
I
0
n
n
I
0
p
7
x
E
8
US-ASCII
4
Huia
x
E
8
US-ASCII
4
Core
x
E
8
US-ASCII
7
Closure
s
E
5
UTF-8
7
create:
M
1
p
2
x
E
8
US-ASCII
9
for_block
t
n
x
E
8
US-ASCII
12
Roger Rabbit
i
87
7
0
44
46
1
46
2
46
3
50
4
0
13
7
5
65
50
6
1
15
44
46
1
46
2
46
7
7
8
100
57
9
51
10
0
50
11
2
11
48
50
11
3
7
0
44
46
1
46
2
46
3
50
4
0
13
7
12
65
50
6
1
15
44
46
1
46
2
46
7
7
8
100
57
13
51
10
0
50
11
2
11
48
50
11
3
11
I
7
I
0
I
0
I
0
I
0
n
n
I
0
p
14
s
E
5
UTF-8
23
definePrivateMethod:as:
x
E
8
US-ASCII
4
Huia
x
E
8
US-ASCII
4
Core
x
E
8
US-ASCII
6
String
x
E
8
US-ASCII
3
new
s
E
5
UTF-8
12
if:then:else
x
E
8
US-ASCII
6
value=
x
E
8
US-ASCII
7
Closure
s
E
5
UTF-8
7
create:
M
1
p
2
x
E
8
US-ASCII
9
for_block
t
n
x
E
8
US-ASCII
12
Roger Rabbit
i
79
44
46
0
46
1
46
2
50
3
0
19
3
44
46
0
46
1
46
4
50
3
0
19
4
7
5
20
0
44
46
0
46
1
46
6
7
7
100
57
8
51
9
0
50
10
2
11
48
50
10
3
7
5
20
4
44
46
0
46
1
46
6
7
7
100
57
11
51
9
0
50
10
2
11
48
50
10
3
11
I
e
I
5
I
0
I
0
I
3
n
n
I
3
p
12
x
E
8
US-ASCII
4
Huia
x
E
8
US-ASCII
4
Core
x
E
8
US-ASCII
3
Nil
x
E
8
US-ASCII
3
new
x
E
8
US-ASCII
5
False
s
E
5
UTF-8
8
if:then:
x
E
8
US-ASCII
7
Closure
s
E
5
UTF-8
7
create:
M
1
p
2
x
E
8
US-ASCII
9
for_block
t
n
x
E
8
US-ASCII
12
Roger Rabbit
i
27
20
0
19
1
20
2
7
0
20
0
48
50
1
2
44
46
2
46
3
46
4
50
5
0
19
3
11
I
9
I
4
I
0
I
0
I
1
n
n
I
1
p
6
s
E
5
UTF-8
12
callWithArg:
x
E
8
US-ASCII
12
__huia__send
x
E
8
US-ASCII
4
Huia
x
E
8
US-ASCII
4
Core
x
E
8
US-ASCII
4
True
x
E
8
US-ASCII
3
new
p
3
I
-1
I
1
I
1b
n
p
4
s
E
5
UTF-8
7
_result
s
E
5
UTF-8
6
result
s
E
5
UTF-8
8
positive
s
E
5
UTF-8
7
wasTrue
x
E
8
US-ASCII
6
lambda
x
E
8
US-ASCII
12
__huia__send
M
1
p
2
x
E
8
US-ASCII
9
for_block
t
n
x
E
8
US-ASCII
12
Roger Rabbit
i
11
20
0
7
0
20
1
48
50
1
2
11
I
6
I
2
I
0
I
0
I
0
n
n
I
0
p
2
s
E
5
UTF-8
12
callWithArg:
x
E
8
US-ASCII
12
__huia__send
p
3
I
-1
I
1
I
b
n
p
2
s
E
5
UTF-8
8
negative
s
E
5
UTF-8
7
_result
p
3
I
-1
I
1
I
4f
n
p
5
s
E
5
UTF-8
4
test
s
E
5
UTF-8
8
positive
s
E
5
UTF-8
8
negative
s
E
5
UTF-8
6
result
s
E
5
UTF-8
7
wasTrue
x
E
8
US-ASCII
6
lambda
x
E
8
US-ASCII
12
__huia__send
s
E
5
UTF-8
12
unless:then:
M
1
p
2
x
E
8
US-ASCII
9
for_block
t
n
x
E
8
US-ASCII
12
Roger Rabbit
i
47
7
0
20
0
44
46
1
46
2
46
3
7
4
100
57
5
51
6
0
50
7
2
11
44
46
1
46
2
46
3
7
4
100
57
8
51
6
0
50
7
2
11
48
50
7
4
11
I
9
I
2
I
0
I
0
I
2
n
n
I
2
p
9
s
E
5
UTF-8
13
if:then:else:
x
E
8
US-ASCII
4
Huia
x
E
8
US-ASCII
4
Core
x
E
8
US-ASCII
7
Closure
s
E
5
UTF-8
7
create:
M
1
p
2
x
E
8
US-ASCII
9
for_block
t
n
x
E
8
US-ASCII
12
Roger Rabbit
i
11
44
46
0
46
1
46
2
50
3
0
11
I
2
I
0
I
0
I
0
I
0
n
n
I
0
p
4
x
E
8
US-ASCII
4
Huia
x
E
8
US-ASCII
4
Core
x
E
8
US-ASCII
3
Nil
x
E
8
US-ASCII
3
new
p
3
I
-1
I
1
I
b
n
p
0
x
E
8
US-ASCII
6
lambda
x
E
8
US-ASCII
12
__huia__send
M
1
p
2
x
E
8
US-ASCII
9
for_block
t
n
x
E
8
US-ASCII
12
Roger Rabbit
i
11
20
1
7
0
20
0
48
50
1
2
11
I
6
I
2
I
0
I
0
I
1
n
n
I
1
p
2
s
E
5
UTF-8
12
callWithArg:
x
E
8
US-ASCII
12
__huia__send
p
3
I
-1
I
1
I
b
n
p
2
s
E
5
UTF-8
6
result
s
E
5
UTF-8
8
positive
p
3
I
-1
I
1
I
2f
n
p
2
s
E
5
UTF-8
4
test
s
E
5
UTF-8
8
positive
p
3
I
-1
I
1
I
57
n
p
0
x
E
8
US-ASCII
6
lambda
x
E
8
US-ASCII
12
__huia__send
p
3
I
0
I
1
I
13
n
n
# These are the basic methods defined on Object.
# There are five magically defined in the runtime:
#
# - `get:` retrieves an instance variable.
# - `set:to:` sets an instance variable to a value.
# - `defineMethod:as:` defines a methods on the receiver.
# - `definePrivateMethod:as` defines a a private method on the receiver.
# - `defaultResponderFor:` finds the requested method and returns it.
# - `sendMessage:withArgs:` calls `defaultResponderFor:` then executes the
# closure in the receiver's scope (after a privacy check).
# - `if:then:` executes the `then` if the `if` argument is truthy.
#
# Note that you can override any of these methods in your subclass.
definePrivateMethod: 'if:then:else' as: |test,positive,negative|
result = nil
wasTrue = false
if: test then: |_result|
result = _result
positive.callWithArg: _result
wasTrue = true
if: wasTrue then:
negative.callWithArg: _result
definePrivateMethod: 'unless:then:' as: |test,positive|
if: test then:
nil
else: |result|
positive.callWithArg: result
[3] pry(main)> Huia.eval File.read('core/object.huia')
0000: push_cpath_top
0001: find_const_fast :Huia
0003: find_const_fast :Core
0005: find_const_fast :Closure
0007: push_literal "create:"
0009: push_rubinius
0010: create_block #<Rubinius::CompiledCode Roger Rabbit file=>
0012: send_stack_with_block :lambda, 0
0015: send_stack :__huia__send, 2
0018: ret
=> #<Huia::Script:0x24538 @compiled_method=#<Rubinius::CompiledCode file=>, @filename="(eval)", @scope=main>
[4] pry(main)> `rm core/object.chuia`
=> ""
[5] pry(main)> Huia.load 'core/object'
Rubinius::InvalidRBC: /Users/jnh/Dev/Huia/huia/core/object
from kernel/delta/code_loader.rb:227:in `load_compiled_file'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment