Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compile from the interpreter is broken. #2069

Closed
darkbushido opened this issue Jul 19, 2017 · 3 comments
Closed

Compile from the interpreter is broken. #2069

darkbushido opened this issue Jul 19, 2017 · 3 comments
Milestone

Comments

@darkbushido
Copy link

I'm trying to compile code in KOS to see if i can save some space.

test.ks

print "hello".

When I run compile "test.ks" to "test.ksm". I hit the following error.

[LOG 20:22:10.598] kOS: FlightControl Unbound
[LOG 20:22:16.987] kOS: Pushing context staring with: File                 Line:Col IP   label   opcode operand
[LOG 20:22:16.988] kOS: Saving and removing 3 pointers
[LOG 20:22:17.016] kOS: (Cannot Show kOS Error Location - error might really be internal. See kOS devs.)
[LOG 20:22:17.017] System.ArgumentOutOfRangeException: Argument is out of range.
Parameter name: index
  at System.Collections.Generic.List`1[kOS.Safe.Compilation.Opcode].get_Item (Int32 index) [0x00000] in <filename unknown>:0 
  at kOS.Safe.Execution.CPU.ExecuteInstruction (IProgramContext context, Boolean doProfiling) [0x00000] in <filename unknown>:0 
  at kOS.Safe.Execution.CPU.ContinueExecution (Boolean doProfiling) [0x00000] in <filename unknown>:0 
  at kOS.Safe.Execution.CPU.KOSFixedUpdate (Double deltaTime) [0x00000] in <filename unknown>:0 
[LOG 20:22:17.019] Code Fragment
File                 Line:Col IP   label   opcode operand
====                 ====:=== ==== ================================  

[LOG 20:22:17.020] kOS: Stack dump: stackPointer = 0
000 SP-> False (type: Boolean)
@hvacengi
Copy link
Member

I suspect that this is due to how we switch to the program context in the new compile logic. The context is switched before the script is actually compiled, at which point the context's program is a zero length list of opcodes. Except that the cpu should be yielding at that point and not trying to execute instructions. So maybe I'm wrong about the source.

@hvacengi
Copy link
Member

I think I've tracked down the real issue here. When compiling but not running the script, we still switch to the program context. So the solution should simply be to add a condition that doesn't switch to the program context if compiling to a file. I'll get a PR up tonight.

@darkbushido
Copy link
Author

Sweet!!

@Dunbaratu Dunbaratu added this to the v1.1.2.0 milestone Sep 13, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants