Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Eggman Scheme Bytecode Examples
function (+ a b) entry=bb0
bb0:
v0 = lookup 'assert
v1 = typeof v0
v2 = Binop.SYM_EQ v1 'function
brn v2 non_function
v3 = arity v0
v4 = Binop.NUM_EQ v3 1
brn v4 wrong_arity
v5 = lookup 'number?
v6 = typeof v5
v7 = Binop.SYM_EQ v6 'function
brn v7 non_function
v8 = arity v5
v9 = Binop.NUM_EQ v8 1
brn v9 wrong_arity
v10 = call v5 (a)
v11 = call v0 (v10)
v12 = lookup 'assert
v13 = typeof v12
v14 = Binop.SYM_EQ v13 'function
brn v14 non_function
v15 = arity v12
v16 = Binop.NUM_EQ v15 1
brn v16 wrong_arity
v17 = lookup 'number?
v18 = typeof v17
v19 = Binop.SYM_EQ v18 'function
brn v19 non_function
v20 = arity v17
v21 = Binop.NUM_EQ v20 1
brn v21 wrong_arity
v22 = call v17 (b)
v23 = call v12 (v22)
v24 = lookup 'inst/+
v25 = typeof v24
v26 = Binop.SYM_EQ v25 'function
brn v26 non_function
v27 = arity v24
v28 = Binop.NUM_EQ v27 2
brn v28 wrong_arity
v29 = call v24 (a, b)
return v29
non_function:
trap 'Attempted to call a non-function'
wrong_arity:
trap 'Call with the wrong number of arguments'
function (+ a b) entry=bb0
bb0:
v0 = lookup 'assert
v1 = lookup 'number?
v2 = call v1 (a) (object)
v3 = call v0 (v2) (bool)
v4 = lookup 'assert
v5 = lookup 'number?
v6 = call v5 (b) (object)
v7 = call v4 (v6) (bool)
v8 = lookup 'inst/+
v9 = call v8 (a, b) (object, object)
return v9
function (+ a b) entry=bb0 (number, number)
bb0:
v0 = lookup 'inst/+
v1 = call v0 (a, b) (number, number)
return v1
function (+ a b) entry=bb0
bb0:
inl4@inl1@inl0@result = typeof a
inl4@inl0@inl0@result = Binop.SYM_EQ inl4@inl1@inl0@result 'number
brn inl4@inl0@inl0@result bb0.split5
inl2@inl1@inl0@result = typeof b
inl2@inl0@inl0@result = Binop.SYM_EQ inl2@inl1@inl0@result 'number
brn inl2@inl0@inl0@result bb0.split6
inl0@result = Binop.ADD a b
return inl0@result
bb0.split5:
trap '(trap)'
bb0.split6:
trap '(trap)'
function (+ a b) entry=bb0
bb0:
v0 = typeof a
v1 = Binop.SYM_EQ v0 'number
brn v1 error
v2 = typeof b
v3 = Binop.SYM_EQ v2 'number
brn v3 error
v4 = Binop.ADD a b
return v4
error:
trap '(trap)'
function (+ a b) entry=bb0 (number, number)
bb0:
inl0@result = Binop.ADD a b
return inl0@result
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.