summary refs log tree commit diff stats
path: root/compiler
ModeNameSize
-rw-r--r--aliasanalysis.nim4352log stats plain blame
-rw-r--r--aliases.nim6452log stats plain blame
-rw-r--r--ast.nim80276log stats plain blame
-rw-r--r--astalgo.nim21340log stats plain blame
-rw-r--r--astmsgs.nim1970log stats plain blame
-rw-r--r--astyaml.nim5843log stats plain blame
-rw-r--r--bitsets.nim2754log stats plain blame
-rw-r--r--btrees.nim5012log stats plain blame
-rw-r--r--cbuilder.nim5718log stats plain blame
-rw-r--r--ccgcalls.nim31798log stats plain blame
-rw-r--r--ccgexprs.nim135622log stats plain blame
-rw-r--r--ccgliterals.nim4366log stats plain blame
-rw-r--r--ccgmerge_unused.nim8140log stats plain blame
-rw-r--r--ccgreset.nim4056log stats plain blame
-rw-r--r--ccgstmts.nim62293log stats plain blame
-rw-r--r--ccgthreadvars.nim2333log stats plain blame
-rw-r--r--ccgtrav.nim6859log stats plain blame
-rw-r--r--ccgtypes.nim75174log stats plain blame
-rw-r--r--ccgutils.nim5396log stats plain blame
-rw-r--r--cgen.nim91479log stats plain blame
-rw-r--r--cgendata.nim10649log stats plain blame
-rw-r--r--cgmeth.nim11084log stats plain blame
-rw-r--r--closureiters.nim50660log stats plain blame
-rw-r--r--cmdlinehelper.nim3134log stats plain blame
-rw-r--r--commands.nim50294log stats plain blame
-rw-r--r--compiler.nimble523log stats plain blame
-rw-r--r--concepts.nim13171log stats plain blame
-rw-r--r--condsyms.nim6221log stats plain blame
-rw-r--r--debuginfo.nim2052log stats plain blame
-rw-r--r--debugutils.nim2192log stats plain blame
-rw-r--r--depends.nim3135log stats plain blame
-rw-r--r--dfa.nim13086log stats plain blame
-rw-r--r--docgen.nim78318log stats plain blame
-rw-r--r--docgen2.nim2211log stats plain blame
-rw-r--r--enumtostr.nim3670log stats plain blame
-rw-r--r--errorhandling.nim2419log stats plain blame
-rw-r--r--evalffi.nim17708log stats plain blame
-rw-r--r--evaltempl.nim8314log stats plain blame
-rw-r--r--expanddefaults.nim4655log stats plain blame
-rw-r--r--extccomp.nim45574log stats plain blame
-rw-r--r--filter_tmpl.nim6791log stats plain blame
-rw-r--r--filters.nim2779log stats plain blame
-rw-r--r--gorgeimpl.nim2279log stats plain blame
-rw-r--r--guards.nim37711log stats plain blame
-rw-r--r--hlo.nim3722log stats plain blame
d---------ic432log stats plain
-rw-r--r--idents.nim3574log stats plain blame
-rw-r--r--importer.nim14485log stats plain blame
-rw-r--r--index.nim478log stats plain blame
-rw-r--r--injectdestructors.nim50635log stats plain blame
-rw-r--r--installer.ini3787log stats plain blame
-rw-r--r--int128.nim16724log stats plain blame
-rw-r--r--isolation_check.nim7162log stats plain blame
-rw-r--r--jsgen.nim109232log stats plain blame
-rw-r--r--jstypes.nim6138log stats plain blame
-rw-r--r--lambdalifting.nim37757log stats plain blame
-rw-r--r--layouter.nim19550log stats plain blame
-rw-r--r--lexer.nim47458log stats plain blame
-rw-r--r--liftdestructors.nim51059log stats plain blame
-rw-r--r--liftlocals.nim2355log stats plain blame
-rw-r--r--lineinfos.nim16189log stats plain blame
-rw-r--r--linter.nim6525log stats plain blame
-rw-r--r--llstream.nim6014log stats plain blame
-rw-r--r--lookups.nim33043log stats plain blame
-rw-r--r--lowerings.nim12387log stats plain blame
-rw-r--r--macrocacheimpl.nim1375log stats plain blame
-rw-r--r--magicsys.nim6162log stats plain blame
-rw-r--r--main.nim16682log stats plain blame
-rw-r--r--mangleutils.nim1570log stats plain blame
-rw-r--r--modulegraphs.nim29373log stats plain blame
-rw-r--r--modulepaths.nim3438log stats plain blame
-rw-r--r--modules.nim2477log stats plain blame
-rw-r--r--msgs.nim27538log stats plain blame
-rw-r--r--ndi.nim1361log stats plain blame
-rw-r--r--nilcheck.nim44931log stats plain blame
-rw-r--r--nim.cfg1066log stats plain blame
-rw-r--r--nim.nim5910log stats plain blame
-rw-r--r--nimblecmd.nim5510log stats plain blame
-rw-r--r--nimconf.nim11684log stats plain blame
-rw-r--r--nimeval.nim6459log stats plain blame
-rw-r--r--nimlexbase.nim5417log stats plain blame
-rw-r--r--nimpaths.nim2194log stats plain blame
-rw-r--r--nimsets.nim4476log stats plain blame
-rw-r--r--nodejs.nim347log stats plain blame
-rw-r--r--nodekinds.nim9756log stats plain blame
-rw-r--r--nversion.nim764log stats plain blame
-rw-r--r--optimizer.nim7989log stats plain blame
-rw-r--r--options.nim41603log stats plain blame
-rw-r--r--packagehandling.nim1343log stats plain blame
-rw-r--r--packages.nim1507log stats plain blame
-rw-r--r--parampatterns.nim11665log stats plain blame
-rw-r--r--parser.nim85385log stats plain blame
-rw-r--r--passaux.nim942log stats plain blame
-rw-r--r--passes.nim9194log stats plain blame
-rw-r--r--pathutils.nim5089log stats plain blame
-rw-r--r--patterns.nim10585log stats plain blame
-rw-r--r--pipelines.nim11744log stats plain blame
-rw-r--r--pipelineutils.nim1133log stats plain blame
-rw-r--r--platform.nim14226log stats plain blame
d---------plugins199log stats plain
-rw-r--r--pluginsupport.nim943log stats plain blame
-rw-r--r--pragmas.nim52777log stats plain blame
-rw-r--r--prefixmatches.nim1543log stats plain blame
-rw-r--r--procfind.nim3474log stats plain blame
-rw-r--r--pushpoppragmas.nim2049log stats plain blame
-rw-r--r--readme.md327log stats plain blame
-rw-r--r--renderer.nim57999log stats plain blame
-rw-r--r--renderverbatim.nim4389log stats plain blame
-rw-r--r--reorder.nim13955log stats plain blame
-rw-r--r--rodutils.nim4802log stats plain blame
-rw-r--r--ropes.nim4172log stats plain blame
-rw-r--r--saturate.nim2189log stats plain blame
-rw-r--r--scriptconfig.nim8016log stats plain blame
-rw-r--r--sem.nim33736log stats plain blame
-rw-r--r--semcall.nim40022log stats plain blame
-rw-r--r--semdata.nim24540log stats plain blame
-rw-r--r--semexprs.nim140539log stats plain blame
-rw-r--r--semfields.nim5904log stats plain blame
-rw-r--r--semfold.nim31453log stats plain blame
-rw-r--r--semgnrc.nim24057log stats plain blame
-rw-r--r--seminst.nim17973log stats plain blame
-rw-r--r--semmacrosanity.nim4035log stats plain blame
-rw-r--r--semmagic.nim27663log stats plain blame
-rw-r--r--semobjconstr.nim22548log stats plain blame
-rw-r--r--semparallel.nim17150log stats plain blame
-rw-r--r--sempass2.nim66471log stats plain blame
-rw-r--r--semstmts.nim111668log stats plain blame
-rw-r--r--semstrictfuncs.nim1688log stats plain blame
-rw-r--r--semtempl.nim31063log stats plain blame
-rw-r--r--semtypes.nim98354log stats plain blame
-rw-r--r--semtypinst.nim32241log stats plain blame
-rw-r--r--sighashes.nim14435log stats plain blame
-rw-r--r--sigmatch.nim118169log stats plain blame
-rw-r--r--sinkparameter_inference.nim2346log stats plain blame
-rw-r--r--sizealignoffsetimpl.nim17025log stats plain blame
-rw-r--r--sourcemap.nim7591log stats plain blame
-rw-r--r--spawn.nim19063log stats plain blame
-rw-r--r--suggest.nim31868log stats plain blame
-rw-r--r--suggestsymdb.nim5356log stats plain blame
-rw-r--r--syntaxes.nim4730log stats plain blame
-rw-r--r--tccgen.nim2914log stats plain blame
-rw-r--r--transf.nim45642log stats plain blame
-rw-r--r--trees.nim7878log stats plain blame
-rw-r--r--treetab.nim3633log stats plain blame
-rw-r--r--typeallowed.nim10636log stats plain blame
-rw-r--r--types.nim68711log stats plain blame
-rw-r--r--typesrenderer.nim5110log stats plain blame
-rw-r--r--varpartitions.nim37395log stats plain blame
-rw-r--r--vm.nim92659log stats plain blame
-rw-r--r--vmconv.nim1723log stats plain blame
-rw-r--r--vmdef.nim11199log stats plain blame
-rw-r--r--vmdeps.nim13419log stats plain blame
-rw-r--r--vmgen.nim84895log stats plain blame
-rw-r--r--vmhooks.nim2334log stats plain blame
-rw-r--r--vmmarshal.nim9895log stats plain blame
-rw-r--r--vmops.nim14563log stats plain blame
-rw-r--r--vmprofiler.nim1361log stats plain blame
-rw-r--r--vtables.nim6787log stats plain blame
-rw-r--r--wordrecg.nim8361log stats plain blame
                                                                                                                                         


                                                  

                                                                                                                                              
                                                                                                                  
 
                                                                                                    
                                                                 
                                                                                                  
                                                                

                                                              

                                                                                                                                            
                                                                                                                  
 
                                                                                                  
                                                             
                                                                                                      




                                                                                      

                                                                                                                                                                                                                    

                                                                                                                                                                                                                                                                                        
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

                                                                         

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    

                                                                         

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             

                                                                         


                                                                                         
                                                                              
                                                                                                                                                                                                                                                                                      
                                                                                                                                                                                                                                                                                                                                                 
                                                                                                                                                                                                                                                                                                                    

                                                                         
                                                                                                                                                                                                                                                                                                                                                                       
                                                                                                                                                                                                                                                                                                                                                                              
                                                                                                                                         


                                                      
          

                                                                                                                    
 
                                                                                                      
                                                                 
                                                                                                    
                                                                

                                                                  
          

                                                                                                                      
 
                                                                                                        
                                                                 
                                                                                                      



                                                                  
                                     
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<title>Mu - 024jump.cc</title>
<meta name="Generator" content="Vim/7.4">
<meta name="plugin-version" content="vim7.4_v2">
<meta name="syntax" content="cpp">
<meta name="settings" content="use_css,pre_wrap,no_foldcolumn,expand_tabs,prevent_copy=">
<meta name="colorscheme" content="minimal">
<style type="text/css">
<!--
pre { white-space: pre-wrap; font-family: monospace; color: #eeeeee; background-color: #080808; }
body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color: #080808; }
* { font-size: 12pt; font-size: 1em; }
.Constant { color: #00a0a0; }
.traceAbsent { color: #c00000; }
.cSpecial { color: #008000; }
.traceContains { color: #008000; }
.Comment { color: #9090ff; }
.Delimiter { color: #800080; }
.Special { color: #c00000; }
.Identifier { color: #fcb165; }
.Normal { color: #eeeeee; background-color: #080808; padding-bottom: 1px; }
-->
</style>

<script type='text/javascript'>
<!--

-->
</script>
</head>
<body>
<pre id='vimCodeElement'>
<span class="Comment">//: Jump primitives</span>

<span class="Delimiter">:(scenario jump_can_skip_instructions)</span>
def main [
  jump <span class="Constant">1</span>:offset
  <span class="Constant">1</span>:number<span class="Special"> &lt;- </span>copy <span class="Constant">1</span>
]
<span class="traceContains">+run: jump {1: &quot;offset&quot;}</span>
<span class="traceAbsent">-run: {1: &quot;number&quot;} &lt;- copy {1: &quot;literal&quot;}</span>
<span class="traceAbsent">-mem: storing 1 in location 1</span>

<span class="Delimiter">:(before &quot;End Primitive Recipe Declarations&quot;)</span>
JUMP<span class="Delimiter">,</span>
<span class="Delimiter">:(before &quot;End Primitive Recipe Numbers&quot;)</span>
put<span class="Delimiter">(</span>Recipe_ordinal<span class="Delimiter">,</span> <span class="Constant">&quot;jump&quot;</span><span class="Delimiter">,</span> JUMP<span class="Delimiter">);</span>
<span class="Delimiter">:(before &quot;End Primitive Recipe Checks&quot;)</span>
<span class="Normal">case</span> JUMP: <span class="Delimiter">{</span>
  <span class="Normal">if</span> <span class="Delimiter">(</span>SIZE<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">)</span> != <span class="Constant">1</span><span class="Delimiter">)</span> <span class="Delimiter">{</span>
    raise &lt;&lt; maybe<span class="Delimiter">(</span>get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> r<span class="Delimiter">).</span>name<span class="Delimiter">)</span> &lt;&lt; <span class="Constant">&quot;'jump' requires exactly one ingredient, but got &quot;</span> &lt;&lt; to_original_string<span class="Delimiter">(</span>inst<span class="Delimiter">)</span> &lt;&lt; <span class="cSpecial">'\n'</span> &lt;&lt; end<span class="Delimiter">();</span>
    <span class="Identifier">break</span><span class="Delimiter">;</span>
  <span class="Delimiter">}</span>
  <span class="Normal">if</span> <span class="Delimiter">(</span>!is_mu_scalar<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">)))</span> <span class="Delimiter">{</span>
    raise &lt;&lt; maybe<span class="Delimiter">(</span>get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> r<span class="Delimiter">).</span>name<span class="Delimiter">)</span> &lt;&lt; <span class="Constant">&quot;first ingredient of 'jump' should be a label or offset, but got &quot;</span> &lt;&lt; inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">).</span>original_string &lt;&lt; <span class="cSpecial">'\n'</span> &lt;&lt; end<span class="Delimiter">();</span>
    <span class="Identifier">break</span><span class="Delimiter">;</span>
  <span class="Delimiter">}</span>
  <span class="Identifier">break</span><span class="Delimiter">;</span>
<span class="Delimiter">}</span>
<span class="Delimiter">:(before &quot;End Primitive Recipe Implementations&quot;)</span>
<span class="Normal">case</span> JUMP: <span class="Delimiter">{</span>
  assert<span class="Delimiter">(</span>current_instruction<span class="Delimiter">().</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">).</span>initialized<span class="Delimiter">);</span>
  current_step_index<span class="Delimiter">()</span> += ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">).</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">)</span>+<span class="Constant">1</span><span class="Delimiter">;</span>
  trace<span class="Delimiter">(</span><span class="Constant">9998</span><span class="Delimiter">,</span> <span class="Constant">&quot;run&quot;</span><span class="Delimiter">)</span> &lt;&lt; <span class="Constant">&quot;jumping to instruction &quot;</span> &lt;&lt; current_step_index<span class="Delimiter">()</span> &lt;&lt; end<span class="Delimiter">();</span>
  <span class="Identifier">continue</span><span class="Delimiter">;</span>  <span class="Comment">// skip rest of this instruction</span>
<span class="Delimiter">}</span>

<span class="Comment">//: special type to designate jump targets</span>
<span class="Delimiter">:(before &quot;End Mu Types Initialization&quot;)</span>
put<span class="Delimiter">(</span>Type_ordinal<span class="Delimiter">,</span> <span class="Constant">&quot;offset&quot;</span><span class="Delimiter">,</span> <span class="Constant">0</span><span class="Delimiter">);</span>

<span class="Delimiter">:(scenario jump_backward)</span>
def main [
  jump <span class="Constant">1</span>:offset  <span class="Comment"># 0 -+</span>
  jump <span class="Constant">3</span>:offset  <span class="Comment">#    |   +-+ 1</span>
                 <span class="Comment">#   \/  /\ |</span>
  jump -<span class="Constant">2</span>:offset <span class="Comment">#  2 +--&gt;+ |</span>
]                <span class="Comment">#         \/ 3</span>
<span class="traceContains">+run: jump {1: &quot;offset&quot;}</span>
<span class="traceContains">+run: jump {-2: &quot;offset&quot;}</span>
<span class="traceContains">+run: jump {3: &quot;offset&quot;}</span>

<span class="Delimiter">:(before &quot;End Primitive Recipe Declarations&quot;)</span>
JUMP_IF<span class="Delimiter">,</span>
<span class="Delimiter">:(before &quot;End Primitive Recipe Numbers&quot;)</span>
put<span class="Delimiter">(</span>Recipe_ordinal<span class="Delimiter">,</span> <span class="Constant">&quot;jump-if&quot;</span><span class="Delimiter">,</span> JUMP_IF<span class="Delimiter">);</span>
<span class="Delimiter">:(before &quot;End Primitive Recipe Checks&quot;)</span>
<span class="Normal">case</span> JUMP_IF: <span class="Delimiter">{</span>
  <span class="Normal">if</span> <span class="Delimiter">(</span>SIZE<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">)</span> != <span class="Constant">2</span><span class="Delimiter">)</span> <span class="Delimiter">{</span>
    raise &lt;&lt; maybe<span class="Delimiter">(</span>get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> r<span class="Delimiter">).</span>name<span class="Delimiter">)</span> &lt;&lt; <span class="Constant">&quot;'jump-if' requires exactly two ingredients, but got &quot;</span> &lt;&lt; to_original_string<span class="Delimiter">(</span>inst<span class="Delimiter">)</span> &lt;&lt; <span class="cSpecial">'\n'</span> &lt;&lt; end<span class="Delimiter">();</span>
    <span class="Identifier">break</span><span class="Delimiter">;</span>
  <span class="Delimiter">}</span>
  <span class="Normal">if</span> <span class="Delimiter">(</span>!is_mu_scalar<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">)))</span> <span class="Delimiter">{</span>
    raise &lt;&lt; maybe<span class="Delimiter">(</span>get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> r<span class="Delimiter">).</span>name<span class="Delimiter">)</span> &lt;&lt; <span class="Constant">&quot;'jump-if' requires a boolean for its first ingredient, but got &quot;</span> &lt;&lt; inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">).</span>original_string &lt;&lt; <span class="cSpecial">'\n'</span> &lt;&lt; end<span class="Delimiter">();</span>
    <span class="Identifier">break</span><span class="Delimiter">;</span>
  <span class="Delimiter">}</span>
  <span class="Normal">if</span> <span class="Delimiter">(</span>!is_mu_scalar<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">1</span><span class="Delimiter">)))</span> <span class="Delimiter">{</span>
    raise &lt;&lt; maybe<span class="Delimiter">(</span>get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> r<span class="Delimiter">).</span>name<span class="Delimiter">)</span> &lt;&lt; <span class="Constant">&quot;'jump-if' requires a label or offset for its second ingredient, but got &quot;</span> &lt;&lt; inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">).</span>original_string &lt;&lt; <span class="cSpecial">'\n'</span> &lt;&lt; end<span class="Delimiter">();</span>
    <span class="Identifier">break</span><span class="Delimiter">;</span>
  <span class="Delimiter">}</span>
  <span class="Identifier">break</span><span class="Delimiter">;</span>
<span class="Delimiter">}</span>
<span class="Delimiter">:(before &quot;End Primitive Recipe Implementations&quot;)</span>
<span class="Normal">case</span> JUMP_IF: <span class="Delimiter">{</span>
  assert<span class="Delimiter">(</span>current_instruction<span class="Delimiter">().</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">1</span><span class="Delimiter">).</span>initialized<span class="Delimiter">);</span>
  <span class="Normal">if</span> <span class="Delimiter">(</span>!ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">).</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">))</span> <span class="Delimiter">{</span>
    trace<span class="Delimiter">(</span><span class="Constant">9998</span><span class="Delimiter">,</span> <span class="Constant">&quot;run&quot;</span><span class="Delimiter">)</span> &lt;&lt; <span class="Constant">&quot;jump-if fell through&quot;</span> &lt;&lt; end<span class="Delimiter">();</span>
    <span class="Identifier">break</span><span class="Delimiter">;</span>
  <span class="Delimiter">}</span>
  current_step_index<span class="Delimiter">()</span> += ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">1</span><span class="Delimiter">).</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">)</span>+<span class="Constant">1</span><span class="Delimiter">;</span>
  trace<span class="Delimiter">(</span><span class="Constant">9998</span><span class="Delimiter">,</span> <span class="Constant">&quot;run&quot;</span><span class="Delimiter">)</span> &lt;&lt; <span class="Constant">&quot;jumping to instruction &quot;</span> &lt;&lt; current_step_index<span class="Delimiter">()</span> &lt;&lt; end<span class="Delimiter">();</span>
  <span class="Identifier">continue</span><span class="Delimiter">;</span>  <span class="Comment">// skip rest of this instruction</span>
<span class="Delimiter">}</span>

<span class="Delimiter">:(scenario jump_if)</span>
def main [
  jump-<span class="Normal">if</span> <span class="Constant">999</span><span class="Delimiter">,</span> <span class="Constant">1</span>:offset
  <span class="Constant">123</span>:number<span class="Special"> &lt;- </span>copy <span class="Constant">1</span>
]
<span class="traceContains">+run: jump-if {999: &quot;literal&quot;}, {1: &quot;offset&quot;}</span>
<span class="traceContains">+run: jumping to instruction 2</span>
<span class="traceAbsent">-run: {1: &quot;number&quot;} &lt;- copy {1: &quot;literal&quot;}</span>
<span class="traceAbsent">-mem: storing 1 in location 123</span>

<span class="Delimiter">:(scenario jump_if_fallthrough)</span>
def main [
  jump-<span class="Normal">if</span> <span class="Constant">0</span><span class="Delimiter">,</span> <span class="Constant">1</span>:offset
  <span class="Constant">123</span>:number<span class="Special"> &lt;- </span>copy <span class="Constant">1</span>
]
<span class="traceContains">+run: jump-if {0: &quot;literal&quot;}, {1: &quot;offset&quot;}</span>
<span class="traceContains">+run: jump-if fell through</span>
<span class="traceContains">+run: {123: &quot;number&quot;} &lt;- copy {1: &quot;literal&quot;}</span>
<span class="traceContains">+mem: storing 1 in location 123</span>

<span class="Delimiter">:(before &quot;End Primitive Recipe Declarations&quot;)</span>
JUMP_UNLESS<span class="Delimiter">,</span>
<span class="Delimiter">:(before &quot;End Primitive Recipe Numbers&quot;)</span>
put<span class="Delimiter">(</span>Recipe_ordinal<span class="Delimiter">,</span> <span class="Constant">&quot;jump-unless&quot;</span><span class="Delimiter">,</span> JUMP_UNLESS<span class="Delimiter">);</span>
<span class="Delimiter">:(before &quot;End Primitive Recipe Checks&quot;)</span>
<span class="Normal">case</span> JUMP_UNLESS: <span class="Delimiter">{</span>
  <span class="Normal">if</span> <span class="Delimiter">(</span>SIZE<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">)</span> != <span class="Constant">2</span><span class="Delimiter">)</span> <span class="Delimiter">{</span>
    raise &lt;&lt; maybe<span class="Delimiter">(</span>get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> r<span class="Delimiter">).</span>name<span class="Delimiter">)</span> &lt;&lt; <span class="Constant">&quot;'jump-unless' requires exactly two ingredients, but got &quot;</span> &lt;&lt; to_original_string<span class="Delimiter">(</span>inst<span class="Delimiter">)</span> &lt;&lt; <span class="cSpecial">'\n'</span> &lt;&lt; end<span class="Delimiter">();</span>
    <span class="Identifier">break</span><span class="Delimiter">;</span>
  <span class="Delimiter">}</span>
  <span class="Normal">if</span> <span class="Delimiter">(</span>!is_mu_scalar<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">)))</span> <span class="Delimiter">{</span>
    raise &lt;&lt; maybe<span class="Delimiter">(</span>get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> r<span class="Delimiter">).</span>name<span class="Delimiter">)</span> &lt;&lt; <span class="Constant">&quot;'jump-unless' requires a boolean for its first ingredient, but got &quot;</span> &lt;&lt; inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">).</span>original_string &lt;&lt; <span class="cSpecial">'\n'</span> &lt;&lt; end<span class="Delimiter">();</span>
    <span class="Identifier">break</span><span class="Delimiter">;</span>
  <span class="Delimiter">}</span>
  <span class="Normal">if</span> <span class="Delimiter">(</span>!is_mu_scalar<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">1</span><span class="Delimiter">)))</span> <span class="Delimiter">{</span>
    raise &lt;&lt; maybe<span class="Delimiter">(</span>get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> r<span class="Delimiter">).</span>name<span class="Delimiter">)</span> &lt;&lt; <span class="Constant">&quot;'jump-unless' requires a label or offset for its second ingredient, but got &quot;</span> &lt;&lt; inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">).</span>original_string &lt;&lt; <span class="cSpecial">'\n'</span> &lt;&lt; end<span class="Delimiter">();</span>
    <span class="Identifier">break</span><span class="Delimiter">;</span>
  <span class="Delimiter">}</span>
  <span class="Identifier">break</span><span class="Delimiter">;</span>
<span class="Delimiter">}</span>
<span class="Delimiter">:(before &quot;End Primitive Recipe Implementations&quot;)</span>
<span class="Normal">case</span> JUMP_UNLESS: <span class="Delimiter">{</span>
  assert<span class="Delimiter">(</span>current_instruction<span class="Delimiter">().</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">1</span><span class="Delimiter">).</span>initialized<span class="Delimiter">);</span>
  <span class="Normal">if</span> <span class="Delimiter">(</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">).</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">))</span> <span class="Delimiter">{</span>
    trace<span class="Delimiter">(</span><span class="Constant">9998</span><span class="Delimiter">,</span> <span class="Constant">&quot;run&quot;</span><span class="Delimiter">)</span> &lt;&lt; <span class="Constant">&quot;jump-unless fell through&quot;</span> &lt;&lt; end<span class="Delimiter">();</span>
    <span class="Identifier">break</span><span class="Delimiter">;</span>
  <span class="Delimiter">}</span>
  current_step_index<span class="Delimiter">()</span> += ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">1</span><span class="Delimiter">).</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">)</span>+<span class="Constant">1</span><span class="Delimiter">;</span>
  trace<span class="Delimiter">(</span><span class="Constant">9998</span><span class="Delimiter">,</span> <span class="Constant">&quot;run&quot;</span><span class="Delimiter">)</span> &lt;&lt; <span class="Constant">&quot;jumping to instruction &quot;</span> &lt;&lt; current_step_index<span class="Delimiter">()</span> &lt;&lt; end<span class="Delimiter">();</span>
  <span class="Identifier">continue</span><span class="Delimiter">;</span>  <span class="Comment">// skip rest of this instruction</span>
<span class="Delimiter">}</span>

<span class="Delimiter">:(scenario jump_unless)</span>
def main [
  jump-unless <span class="Constant">0</span><span class="Delimiter">,</span> <span class="Constant">1</span>:offset
  <span class="Constant">123</span>:number<span class="Special"> &lt;- </span>copy <span class="Constant">1</span>
]
<span class="traceContains">+run: jump-unless {0: &quot;literal&quot;}, {1: &quot;offset&quot;}</span>
<span class="traceContains">+run: jumping to instruction 2</span>
<span class="traceAbsent">-run: {123: &quot;number&quot;} &lt;- copy {1: &quot;literal&quot;}</span>
<span class="traceAbsent">-mem: storing 1 in location 123</span>

<span class="Delimiter">:(scenario jump_unless_fallthrough)</span>
def main [
  jump-unless <span class="Constant">999</span><span class="Delimiter">,</span> <span class="Constant">1</span>:offset
  <span class="Constant">123</span>:number<span class="Special"> &lt;- </span>copy <span class="Constant">1</span>
]
<span class="traceContains">+run: jump-unless {999: &quot;literal&quot;}, {1: &quot;offset&quot;}</span>
<span class="traceContains">+run: jump-unless fell through</span>
<span class="traceContains">+run: {123: &quot;number&quot;} &lt;- copy {1: &quot;literal&quot;}</span>
<span class="traceContains">+mem: storing 1 in location 123</span>
</pre>
</body>
</html>
<!-- vim: set foldmethod=manual : -->