Search Unity

Crash on infinite loop inside loop? Loopception! :)

Discussion in 'Scripting' started by BlackArcane, May 9, 2013.

  1. BlackArcane

    BlackArcane

    Joined:
    Jun 26, 2011
    Posts:
    119
    Hey all! I have a question! I have created my own "assembly-like" programming language inside unity and I have it execute a Scan function in a forloop in itself to handle with labels. The code that the interpreter executes is:

    $Some stuff
    DEF Start
    $Do somethind
    JMP Start

    In order to handle that, the interpreter does the following:
    Scans all lines in the text using a 'foreach' loop.
    Executes "Some stuff" if there's stuff.
    Executes "Do something" if there's something to do.
    Calls the scan function in itself to handle JMP Start and scans from the DEF Start going downwards.

    Upon execution, the editor stops responding. (Play button remains grey, never turns blue). The strange thing is that this works:

    $Some stuff
    JMP Start
    $This is never executed
    DEF Start
    $This is executed as it should!

    I am too tired to think, so could somebody please tell me how to trace editor "crashes"? Technically, it's not a crash because I force it shutdown. Thanks in advance!