#troubles with making my own programming language
1 messages · Page 1 of 1 (latest)
@primal merlin , @manic bobcat
for anyone else here
i need help debugging that
the compiler produces these list of instructions from the code above:
vm.Instruction{ .type = vm.Instruction.Type.LABEL, .values = { fib } }
vm.Instruction{ .type = vm.Instruction.Type.STORE, .values = { 0 } }
vm.Instruction{ .type = vm.Instruction.Type.LOAD, .values = { 0 } }
vm.Instruction{ .type = vm.Instruction.Type.PUSH, .values = { 2 } }
vm.Instruction{ .type = vm.Instruction.Type.LESS, .values = { } }
vm.Instruction{ .type = vm.Instruction.Type.NOT, .values = { } }
vm.Instruction{ .type = vm.Instruction.Type.IFJMP, .values = { 9 } }
vm.Instruction{ .type = vm.Instruction.Type.LOAD, .values = { 0 } }
vm.Instruction{ .type = vm.Instruction.Type.RET, .values = { } }
vm.Instruction{ .type = vm.Instruction.Type.LOAD, .values = { 0 } }
vm.Instruction{ .type = vm.Instruction.Type.PUSH, .values = { 1 } }
vm.Instruction{ .type = vm.Instruction.Type.SUB, .values = { } }
vm.Instruction{ .type = vm.Instruction.Type.CALL, .values = { fib } }
vm.Instruction{ .type = vm.Instruction.Type.LOAD, .values = { 0 } }
vm.Instruction{ .type = vm.Instruction.Type.PUSH, .values = { 2 } }
vm.Instruction{ .type = vm.Instruction.Type.SUB, .values = { } }
vm.Instruction{ .type = vm.Instruction.Type.CALL, .values = { fib } }
vm.Instruction{ .type = vm.Instruction.Type.ADD, .values = { } }
vm.Instruction{ .type = vm.Instruction.Type.RET, .values = { } }
vm.Instruction{ .type = vm.Instruction.Type.END_LABEL, .values = { } }
vm.Instruction{ .type = vm.Instruction.Type.PUSH, .values = { 2 } }
vm.Instruction{ .type = vm.Instruction.Type.CALL, .values = { fib } }
vm.Instruction{ .type = vm.Instruction.Type.LOG, .values = { } }
vm.Instruction{ .type = vm.Instruction.Type.EXIT, .values = { } }```
try adding
more debug logs as it's being run
somewhere a value isn't done incorrectly
i suspect around returning and passing that as a value to the add
it's hard to tell
This might be a problem with local scopes
You might treat all n as the same thing
And they are not
yea...
That's why I liked implementing knight-lang
It has no concept of local scope
Every variable is global
And functions don't take args (but they don't actually exist tho)
the reason mine has been taking a while to get going is the bytecode requires you assign each variable name an id and finding out if it's global or local ahead of time
Popping would delete the argument
Probably
But keeping it on the stack also doesn't sound too easy
Since you'd need to understand when to swap or do stuff like under or rot
Coming from forth terms
call should do the store
What's the store argument?
yippee