<Comment># This file is a testcase for the highlighting of Crystal code</Comment><br/>
<Comment># It's not executable code, but a collection of code snippets</Comment><br/>
<Comment>#</Comment><br/>
<Normal Text></Normal Text><br/>
<Kernel methods>require</Kernel methods><Normal Text> </Normal Text><String>"lib_z"</String><br/>
<Kernel methods>require</Kernel methods><Normal Text> </Normal Text><String>"./digest"</String><br/>
<Normal Text></Normal Text><br/>
<Keyword>module</Keyword><Normal Text> </Normal Text><Constant>Digest</Constant><Operator>::</Operator><Constant>Adler32</Constant><br/>
<Normal Text>  </Normal Text><Keyword>def</Keyword><Normal Text> </Normal Text><Pseudo variable>self</Pseudo variable><Message>.initial</Message><Normal Text> : </Normal Text><Constant>UInt32</Constant><br/>
<Normal Text>    </Normal Text><Constant>LibZ</Constant><Message>.adler32</Message><Normal Text>(</Normal Text><Dec>0</Dec><Normal Text>, </Normal Text><Pseudo variable>nil</Pseudo variable><Normal Text>, </Normal Text><Dec>0</Dec><Normal Text>)</Normal Text><Message>.to_u32</Message><br/>
<Normal Text>  </Normal Text><Keyword>end</Keyword><br/>
<Normal Text></Normal Text><br/>
<Normal Text>  </Normal Text><Keyword>def</Keyword><Normal Text> </Normal Text><Pseudo variable>self</Pseudo variable><Message>.checksum</Message><Normal Text>(data) : </Normal Text><Constant>UInt32</Constant><br/>
<Normal Text>    update(data, initial)</Normal Text><br/>
<Normal Text>  </Normal Text><Keyword>end</Keyword><br/>
<Normal Text></Normal Text><br/>
<Normal Text>  </Normal Text><Keyword>def</Keyword><Normal Text> </Normal Text><Pseudo variable>self</Pseudo variable><Message>.update</Message><Normal Text>(data, adler32 : </Normal Text><Constant>UInt32</Constant><Normal Text>) : </Normal Text><Constant>UInt32</Constant><br/>
<Normal Text>    slice </Normal Text><Operator>=</Operator><Normal Text> data</Normal Text><Message>.to_slice</Message><br/>
<Normal Text>    </Normal Text><Constant>LibZ</Constant><Message>.adler32</Message><Normal Text>(adler32, slice, slice</Normal Text><Message>.size</Message><Normal Text>)</Normal Text><Message>.to_u32</Message><br/>
<Normal Text>  </Normal Text><Keyword>end</Keyword><br/>
<Normal Text></Normal Text><br/>
<Normal Text>  </Normal Text><Keyword>def</Keyword><Normal Text> </Normal Text><Pseudo variable>self</Pseudo variable><Message>.combine</Message><Normal Text>(adler1 : </Normal Text><Constant>UInt32</Constant><Normal Text>, adler2 : </Normal Text><Constant>UInt32</Constant><Normal Text>, len) : </Normal Text><Constant>UInt32</Constant><br/>
<Normal Text>    </Normal Text><Constant>LibZ</Constant><Message>.adler32_combine</Message><Normal Text>(adler1, adler2, len)</Normal Text><Message>.to_u32</Message><br/>
<Normal Text>  </Normal Text><Keyword>end</Keyword><br/>
<Keyword>end</Keyword><br/>
<Normal Text></Normal Text><br/>
<Keyword>struct</Keyword><Normal Text> </Normal Text><Constant>BigRational</Constant><br/>
<Normal Text>  </Normal Text><Constant>Number</Constant><Message>.expand_div</Message><Normal Text> </Normal Text><Delimiter>[</Delimiter><Constant>Int8</Constant><Normal Text>, </Normal Text><Constant>UInt8</Constant><Normal Text>, </Normal Text><Constant>Int16</Constant><Normal Text>, </Normal Text><Constant>UInt16</Constant><Normal Text>, </Normal Text><Constant>Int32</Constant><Normal Text>, </Normal Text><Constant>UInt32</Constant><Normal Text>, </Normal Text><Constant>Int64</Constant><Normal Text>, </Normal Text><Constant>UInt64</Constant><Normal Text>, </Normal Text><Constant>Int128</Constant><Normal Text>, </Normal Text><Constant>UInt128</Constant><Delimiter>]</Delimiter><Normal Text>, </Normal Text><Constant>BigRational</Constant><br/>
<Normal Text>  </Normal Text><Constant>Number</Constant><Message>.expand_div</Message><Normal Text> </Normal Text><Delimiter>[</Delimiter><Constant>Float32</Constant><Normal Text>, </Normal Text><Constant>Float64</Constant><Delimiter>]</Delimiter><Normal Text>, </Normal Text><Constant>BigRational</Constant><br/>
<Keyword>end</Keyword><br/>
<Normal Text></Normal Text><br/>
<Keyword>module</Keyword><Normal Text> </Normal Text><Constant>Crystal</Constant><Operator>::</Operator><Constant>Repl</Constant><Operator>::</Operator><Constant>Closure</Constant><br/>
<Normal Text>  </Normal Text><Global Constant>VAR_NAME</Global Constant><Normal Text> </Normal Text><Operator>=</Operator><Normal Text> </Normal Text><String>".closure_var"</String><br/>
<Normal Text>  </Normal Text><Global Constant>ARG_NAME</Global Constant><Normal Text> </Normal Text><Operator>=</Operator><Normal Text> </Normal Text><String>".closure_arg"</String><br/>
<Keyword>end</Keyword><br/>
<Normal Text></Normal Text><br/>
<Keyword>class</Keyword><Normal Text> </Normal Text><Constant>FunctionType</Constant><br/>
<Normal Text>  </Normal Text><Attribute Definition>getter</Attribute Definition><Normal Text> arg_types : </Normal Text><Constant>Array</Constant><Normal Text>(</Normal Text><Constant>ArgType</Constant><Normal Text>)</Normal Text><br/>
<Normal Text>  </Normal Text><Attribute Definition>getter</Attribute Definition><Normal Text> return_type : </Normal Text><Constant>ArgType</Constant><br/>
<Normal Text></Normal Text><br/>
<Normal Text>  </Normal Text><Class Variable>@@cvar</Class Variable><Normal Text> </Normal Text><Operator>=</Operator><Normal Text> </Normal Text><Dec>3</Dec><br/>
<Normal Text>  </Normal Text><Instance Variable>@ivar</Instance Variable><Normal Text> </Normal Text><Operator>=</Operator><Normal Text> </Normal Text><Dec>7</Dec><br/>
<Normal Text></Normal Text><br/>
<Normal Text>  </Normal Text><Keyword>def</Keyword><Normal Text> initialize(</Normal Text><Instance Variable>@arg_types</Instance Variable><Normal Text>, </Normal Text><Instance Variable>@return_type</Instance Variable><Normal Text>)</Normal Text><br/>
<Normal Text>  </Normal Text><Keyword>end</Keyword><br/>
<Normal Text></Normal Text><br/>
<Normal Text>  </Normal Text><Keyword>def</Keyword><Normal Text> /</Normal Text><Regular Expression>/(other : Int::Unsigned) : BigInt</Regular Expression><br/>
<Regular Expression>    check_division_by_zero other</Regular Expression><br/>
<Regular Expression>    unsafe_floored_div(other)</Regular Expression><br/>
<Regular Expression>  end</Regular Expression><br/>
<Regular Expression></Regular Expression><br/>
<Regular Expression>  def /</Regular Expression><Operator>/</Operator><Normal Text>(other : </Normal Text><Constant>Int</Constant><Normal Text>) : </Normal Text><Constant>BigInt</Constant><br/>
<Normal Text>    check_division_by_zero other</Normal Text><br/>
<Normal Text></Normal Text><br/>
<Normal Text>    </Normal Text><Keyword>if</Keyword><Normal Text> other </Normal Text><Operator><</Operator><Normal Text> </Normal Text><Dec>0</Dec><br/>
<Normal Text>      (</Normal Text><Operator>-</Operator><Pseudo variable>self</Pseudo variable><Normal Text>)</Normal Text><Message>.unsafe_floored_div</Message><Normal Text>(</Normal Text><Operator>-</Operator><Normal Text>other)</Normal Text><br/>
<Normal Text>      </Normal Text><Instance Variable>@cvar</Instance Variable><Normal Text> </Normal Text><Operator>+=</Operator><Normal Text> </Normal Text><Dec>1</Dec><br/>
<Normal Text>    </Normal Text><Keyword>else</Keyword><br/>
<Normal Text>      unsafe_floored_div(other)</Normal Text><br/>
<Normal Text>     </Normal Text><Instance Variable>@ivar</Instance Variable><Normal Text> </Normal Text><Operator>+=</Operator><Normal Text> </Normal Text><Dec>10</Dec><br/>
<Normal Text>    </Normal Text><Keyword>end</Keyword><br/>
<Normal Text>  </Normal Text><Keyword>end</Keyword><br/>
<Keyword>end</Keyword><br/>
<Normal Text></Normal Text><br/>
<Kernel methods>require</Kernel methods><Normal Text> </Normal Text><String>"llvm/enums/atomic"</String><br/>
<Keyword>struct</Keyword><Normal Text> </Normal Text><Constant>Atomic</Constant><Normal Text>(T)</Normal Text><br/>
<Normal Text>  </Normal Text><Comment># Creates an Atomic with the given initial value.</Comment><br/>
<Normal Text>  </Normal Text><Keyword>def</Keyword><Normal Text> compare_and_set(cmp : T, new : T) : </Normal Text><Operator>{</Operator><Normal Text>T, </Normal Text><Constant>Bool</Constant><Operator>}</Operator><br/>
<Normal Text>    </Normal Text><Operator>{%</Operator><Normal Text> </Normal Text><Keyword>if</Keyword><Normal Text> T</Normal Text><Message>.union?</Message><Normal Text> </Normal Text><Operator>&&</Operator><Normal Text> T</Normal Text><Message>.union_types.all?</Message><Normal Text> </Normal Text><Operator>{</Operator><Normal Text> </Normal Text><Operator>|</Operator><Normal Text>t</Normal Text><Operator>|</Operator><Normal Text> t </Normal Text><Operator>==</Operator><Normal Text> </Normal Text><Constant>Nil</Constant><Normal Text> </Normal Text><Operator>||</Operator><Normal Text> t </Normal Text><Operator><</Operator><Normal Text> </Normal Text><Constant>Reference</Constant><Normal Text> </Normal Text><Operator>}</Operator><Normal Text> </Normal Text><Operator>%}</Operator><br/>
<Normal Text>      address, success </Normal Text><Operator>=</Operator><Normal Text> </Normal Text><Constant>Ops</Constant><Message>.cmpxchg</Message><Normal Text>(pointerof(</Normal Text><Instance Variable>@value</Instance Variable><Normal Text>)</Normal Text><Message>.as</Message><Normal Text>(</Normal Text><Constant>LibC</Constant><Operator>::</Operator><Constant>SizeT</Constant><Operator>*</Operator><Normal Text>), </Normal Text><Constant>LibC</Constant><Operator>::</Operator><Constant>SizeT</Constant><Message>.new</Message><Normal Text>(cmp</Normal Text><Message>.as</Message><Normal Text>(T)</Normal Text><Message>.object_id</Message><Normal Text>), </Normal Text><Constant>LibC</Constant><Operator>::</Operator><Constant>SizeT</Constant><Message>.new</Message><Normal Text>(new</Normal Text><Message>.as</Message><Normal Text>(T)</Normal Text><Message>.object_id</Message><Normal Text>), </Normal Text><Symbol>:sequentially_consistent</Symbol><Normal Text>, </Normal Text><Symbol>:sequentially_consistent</Symbol><Normal Text>)</Normal Text><br/>
<Normal Text>      </Normal Text><Operator>{</Operator><Normal Text>address </Normal Text><Operator>==</Operator><Normal Text> </Normal Text><Dec>0</Dec><Normal Text> ? </Normal Text><Pseudo variable>nil</Pseudo variable><Normal Text> : </Normal Text><Constant>Pointer</Constant><Normal Text>(T)</Normal Text><Message>.new</Message><Normal Text>(address)</Normal Text><Message>.as</Message><Normal Text>(T), success</Normal Text><Operator>}</Operator><br/>
<Normal Text>    </Normal Text><Operator>{%</Operator><Normal Text> </Normal Text><Keyword>elsif</Keyword><Normal Text> T </Normal Text><Operator><</Operator><Normal Text> </Normal Text><Constant>Reference</Constant><Normal Text> </Normal Text><Operator>%}</Operator><br/>
<Normal Text>      </Normal Text><Comment># Use addresses again (but this can't return nil)</Comment><br/>
<Normal Text>      address, success </Normal Text><Operator>=</Operator><Normal Text> </Normal Text><Constant>Ops</Constant><Message>.cmpxchg</Message><Normal Text>(pointerof(</Normal Text><Instance Variable>@value</Instance Variable><Normal Text>)</Normal Text><Message>.as</Message><Normal Text>(</Normal Text><Constant>LibC</Constant><Operator>::</Operator><Constant>SizeT</Constant><Operator>*</Operator><Normal Text>), </Normal Text><Constant>LibC</Constant><Operator>::</Operator><Constant>SizeT</Constant><Message>.new</Message><Normal Text>(cmp</Normal Text><Message>.as</Message><Normal Text>(T)</Normal Text><Message>.object_id</Message><Normal Text>), </Normal Text><Constant>LibC</Constant><Operator>::</Operator><Constant>SizeT</Constant><Message>.new</Message><Normal Text>(new</Normal Text><Message>.as</Message><Normal Text>(T)</Normal Text><Message>.object_id</Message><Normal Text>), </Normal Text><Symbol>:sequentially_consistent</Symbol><Normal Text>, </Normal Text><Symbol>:sequentially_consistent</Symbol><Normal Text>)</Normal Text><br/>
<Normal Text>      </Normal Text><Operator>{</Operator><Constant>Pointer</Constant><Normal Text>(T)</Normal Text><Message>.new</Message><Normal Text>(address)</Normal Text><Message>.as</Message><Normal Text>(T), success</Normal Text><Operator>}</Operator><br/>
<Normal Text>    </Normal Text><Operator>{%</Operator><Normal Text> </Normal Text><Keyword>else</Keyword><Normal Text> </Normal Text><Operator>%}</Operator><br/>
<Normal Text>      </Normal Text><Constant>Ops</Constant><Message>.cmpxchg</Message><Normal Text>(pointerof(</Normal Text><Instance Variable>@value</Instance Variable><Normal Text>), cmp, new, </Normal Text><Symbol>:sequentially_consistent</Symbol><Normal Text>, </Normal Text><Symbol>:sequentially_consistent</Symbol><Normal Text>)</Normal Text><br/>
<Normal Text>    </Normal Text><Operator>{%</Operator><Normal Text> </Normal Text><Keyword>end</Keyword><Normal Text> </Normal Text><Operator>%}</Operator><br/>
<Normal Text>  </Normal Text><Keyword>end</Keyword><br/>
<Normal Text></Normal Text><br/>
<Normal Text>  </Normal Text><Keyword>def</Keyword><Normal Text> swap(value : T)</Normal Text><br/>
<Normal Text>    </Normal Text><Operator>{%</Operator><Normal Text> </Normal Text><Keyword>if</Keyword><Normal Text> T</Normal Text><Message>.union?</Message><Normal Text> </Normal Text><Operator>&&</Operator><Normal Text> T</Normal Text><Message>.union_types.all?</Message><Normal Text> </Normal Text><Operator>{</Operator><Normal Text> </Normal Text><Operator>|</Operator><Normal Text>t</Normal Text><Operator>|</Operator><Normal Text> t </Normal Text><Operator>==</Operator><Normal Text> </Normal Text><Constant>Nil</Constant><Normal Text> </Normal Text><Operator>||</Operator><Normal Text> t </Normal Text><Operator><</Operator><Normal Text> </Normal Text><Constant>Reference</Constant><Normal Text> </Normal Text><Operator>}</Operator><Normal Text> </Normal Text><Operator>||</Operator><Normal Text> T </Normal Text><Operator><</Operator><Normal Text> </Normal Text><Constant>Reference</Constant><Normal Text> </Normal Text><Operator>%}</Operator><br/>
<Normal Text>      address </Normal Text><Operator>=</Operator><Normal Text> </Normal Text><Constant>Ops</Constant><Message>.atomicrmw</Message><Normal Text>(</Normal Text><Symbol>:xchg</Symbol><Normal Text>, pointerof(</Normal Text><Instance Variable>@value</Instance Variable><Normal Text>)</Normal Text><Message>.as</Message><Normal Text>(</Normal Text><Constant>LibC</Constant><Operator>::</Operator><Constant>SizeT</Constant><Operator>*</Operator><Normal Text>), </Normal Text><Constant>LibC</Constant><Operator>::</Operator><Constant>SizeT</Constant><Message>.new</Message><Normal Text>(value</Normal Text><Message>.as</Message><Normal Text>(T)</Normal Text><Message>.object_id</Message><Normal Text>), </Normal Text><Symbol>:sequentially_consistent</Symbol><Normal Text>, </Normal Text><Pseudo variable>false</Pseudo variable><Normal Text>)</Normal Text><br/>
<Normal Text>      </Normal Text><Constant>Pointer</Constant><Normal Text>(T)</Normal Text><Message>.new</Message><Normal Text>(address)</Normal Text><Message>.as</Message><Normal Text>(T)</Normal Text><br/>
<Normal Text>    </Normal Text><Operator>{%</Operator><Normal Text> </Normal Text><Keyword>else</Keyword><Normal Text> </Normal Text><Operator>%}</Operator><br/>
<Normal Text>      </Normal Text><Constant>Ops</Constant><Message>.atomicrmw</Message><Normal Text>(</Normal Text><Symbol>:xchg</Symbol><Normal Text>, pointerof(</Normal Text><Instance Variable>@value</Instance Variable><Normal Text>), value, </Normal Text><Symbol>:sequentially_consistent</Symbol><Normal Text>, </Normal Text><Pseudo variable>false</Pseudo variable><Normal Text>)</Normal Text><br/>
<Normal Text>    </Normal Text><Operator>{%</Operator><Normal Text> </Normal Text><Keyword>end</Keyword><Normal Text> </Normal Text><Operator>%}</Operator><br/>
<Normal Text>  </Normal Text><Keyword>end</Keyword><br/>
<Keyword>end</Keyword><br/>
<Normal Text></Normal Text><br/>
<Keyword>class</Keyword><Normal Text> </Normal Text><Constant>Deque</Constant><Normal Text>(T)</Normal Text><br/>
<Normal Text>  </Normal Text><Module mixin methods>include</Module mixin methods><Normal Text> </Normal Text><Constant>Indexable</Constant><Operator>::</Operator><Constant>Mutable</Constant><Normal Text>(T)</Normal Text><br/>
<Normal Text></Normal Text><br/>
<Normal Text>  </Normal Text><Instance Variable>@start</Instance Variable><Normal Text> </Normal Text><Operator>=</Operator><Normal Text> </Normal Text><Dec>0</Dec><br/>
<Normal Text>  </Normal Text><Access Control>protected</Access Control><Normal Text> </Normal Text><Attribute Definition>setter</Attribute Definition><Normal Text> size</Normal Text><br/>
<Normal Text>  </Normal Text><Access Control>private</Access Control><Normal Text> </Normal Text><Attribute Definition>getter</Attribute Definition><Normal Text> buffer</Normal Text><br/>
<Normal Text></Normal Text><br/>
<Normal Text>  </Normal Text><Keyword>def</Keyword><Normal Text> initialize(size : </Normal Text><Constant>Int</Constant><Normal Text>, value : T)</Normal Text><br/>
<Normal Text>    </Normal Text><Keyword>if</Keyword><Normal Text> size </Normal Text><Operator><</Operator><Normal Text> </Normal Text><Dec>0</Dec><br/>
<Normal Text>      </Normal Text><Kernel methods>raise</Kernel methods><Normal Text> </Normal Text><Constant>ArgumentError</Constant><Message>.new</Message><Normal Text>(</Normal Text><String>"Negative deque size: </String><Substitution>#{</Substitution><Normal Text>size</Normal Text><Substitution>}</Substitution><String>"</String><Normal Text>)</Normal Text><br/>
<Normal Text>    </Normal Text><Keyword>end</Keyword><br/>
<Normal Text>    </Normal Text><Instance Variable>@size</Instance Variable><Normal Text> </Normal Text><Operator>=</Operator><Normal Text> size</Normal Text><Message>.to_i</Message><br/>
<Normal Text>    </Normal Text><Instance Variable>@capacity</Instance Variable><Normal Text> </Normal Text><Operator>=</Operator><Normal Text> size</Normal Text><Message>.to_i</Message><br/>
<Normal Text></Normal Text><br/>
<Normal Text>    </Normal Text><Keyword>unless</Keyword><Normal Text> </Normal Text><Instance Variable>@capacity</Instance Variable><Normal Text> </Normal Text><Operator>==</Operator><Normal Text> </Normal Text><Dec>0</Dec><br/>
<Normal Text>      </Normal Text><Instance Variable>@buffer</Instance Variable><Normal Text> </Normal Text><Operator>=</Operator><Normal Text> </Normal Text><Constant>Pointer</Constant><Normal Text>(T)</Normal Text><Message>.malloc</Message><Normal Text>(</Normal Text><Instance Variable>@capacity</Instance Variable><Normal Text>, value)</Normal Text><br/>
<Normal Text>    </Normal Text><Keyword>end</Keyword><br/>
<Normal Text>  </Normal Text><Keyword>end</Keyword><br/>
<Normal Text></Normal Text><br/>
<Normal Text>  </Normal Text><Comment># Returns a new `Deque` that has this deque's elements cloned.</Comment><br/>
<Normal Text>  </Normal Text><Comment># That is, it returns a deep copy of this deque.</Comment><br/>
<Normal Text>  </Normal Text><Comment>#</Comment><br/>
<Normal Text>  </Normal Text><Comment># Use `#dup` if you want a shallow copy.</Comment><br/>
<Normal Text>  </Normal Text><Keyword>def</Keyword><Normal Text> clone</Normal Text><br/>
<Normal Text>    </Normal Text><Operator>{%</Operator><Normal Text> </Normal Text><Keyword>if</Keyword><Normal Text> T </Normal Text><Operator>==</Operator><Normal Text> </Normal Text><Operator>::</Operator><Constant>Bool</Constant><Normal Text> </Normal Text><Operator>||</Operator><Normal Text> T </Normal Text><Operator>==</Operator><Normal Text> </Normal Text><Operator>::</Operator><Constant>Char</Constant><Normal Text> </Normal Text><Operator>||</Operator><Normal Text> T </Normal Text><Operator>==</Operator><Normal Text> </Normal Text><Operator>::</Operator><Constant>String</Constant><Normal Text> </Normal Text><Operator>||</Operator><Normal Text> T </Normal Text><Operator>==</Operator><Normal Text> </Normal Text><Operator>::</Operator><Constant>Symbol</Constant><Normal Text> </Normal Text><Operator>||</Operator><Normal Text> T </Normal Text><Operator><</Operator><Normal Text> </Normal Text><Operator>::</Operator><Constant>Number</Constant><Operator>::</Operator><Constant>Primitive</Constant><Normal Text> </Normal Text><Operator>%</Operator><Delimiter>}</Delimiter><br/>
<Normal Text>      </Normal Text><Constant>Deque</Constant><Normal Text>(T)</Normal Text><Message>.new</Message><Normal Text>(size) </Normal Text><Operator>{</Operator><Normal Text> </Normal Text><Operator>|</Operator><Normal Text>i</Normal Text><Operator>|</Operator><Normal Text> </Normal Text><Pseudo variable>self</Pseudo variable><Delimiter>[</Delimiter><Normal Text>i</Normal Text><Delimiter>]</Delimiter><Message>.clone.as</Message><Normal Text>(T) </Normal Text><Operator>}</Operator><br/>
<Normal Text>    </Normal Text><Operator>{</Operator><Normal Text>% </Normal Text><Keyword>else</Keyword><Normal Text> %</Normal Text><Operator>}</Operator><br/>
<Normal Text>      exec_recursive_clone </Normal Text><Keyword>do</Keyword><Normal Text> </Normal Text><Operator>|</Operator><Normal Text>hash</Normal Text><Operator>|</Operator><br/>
<Normal Text>        clone </Normal Text><Operator>=</Operator><Normal Text> </Normal Text><Constant>Deque</Constant><Normal Text>(T)</Normal Text><Message>.new</Message><Normal Text>(size)</Normal Text><br/>
<Normal Text>        each </Normal Text><Keyword>do</Keyword><Normal Text> </Normal Text><Operator>|</Operator><Normal Text>element</Normal Text><Operator>|</Operator><br/>
<Normal Text>          clone </Normal Text><Operator><<</Operator><Normal Text> element</Normal Text><Message>.clone</Message><br/>
<Normal Text>        </Normal Text><Keyword>end</Keyword><br/>
<Normal Text>        clone</Normal Text><br/>
<Normal Text>      </Normal Text><Keyword>end</Keyword><br/>
<Normal Text>    </Normal Text><Operator>{</Operator><Normal Text>% </Normal Text><Keyword>end</Keyword><Normal Text> %</Normal Text><Operator>}</Operator><br/>
<Normal Text>  </Normal Text><Keyword>end</Keyword><br/>
<Normal Text></Normal Text><br/>
<Normal Text>  </Normal Text><Keyword>def</Keyword><Normal Text> delete_at(index : </Normal Text><Constant>Int</Constant><Normal Text>) : T</Normal Text><br/>
<Normal Text>    </Normal Text><Keyword>unless</Keyword><Normal Text> </Normal Text><Dec>0</Dec><Normal Text> </Normal Text><Operator><=</Operator><Normal Text> index </Normal Text><Operator><</Operator><Normal Text> @size</Normal Text><br/>
<Normal Text>      raise </Normal Text><Constant>IndexError</Constant><Message>.new</Message><br/>
<Normal Text>    </Normal Text><Keyword>end</Keyword><br/>
<Normal Text>    </Normal Text><Keyword>return</Keyword><Normal Text> shift </Normal Text><Keyword>if</Keyword><Normal Text> index </Normal Text><Operator>==</Operator><Normal Text> </Normal Text><Dec>0</Dec><br/>
<Normal Text></Normal Text><br/>
<Normal Text>    </Normal Text><Keyword>if</Keyword><Normal Text> index </Normal Text><Operator>></Operator><Normal Text> @size </Normal Text><Operator>//</Operator><Normal Text> </Normal Text><Dec>2</Dec><br/>
<Normal Text>      </Normal Text><Comment># Move following items to the left, starting with the first one</Comment><br/>
<Normal Text>      </Normal Text><Comment># [56-01234] -> [6x-01235]</Comment><br/>
<Normal Text>      dst </Normal Text><Operator>=</Operator><Normal Text> rindex</Normal Text><br/>
<Normal Text>      finish </Normal Text><Operator>=</Operator><Normal Text> (@start </Normal Text><Operator>+</Operator><Normal Text> @size </Normal Text><Operator>-</Operator><Normal Text> </Normal Text><Dec>1</Dec><Normal Text>) </Normal Text><Operator>%</Operator><Normal Text> @capacity</Normal Text><br/>
<Normal Text>      loop </Normal Text><Keyword>do</Keyword><br/>
<Normal Text>        src </Normal Text><Operator>=</Operator><Normal Text> dst </Normal Text><Operator>+</Operator><Normal Text> </Normal Text><Dec>1</Dec><br/>
<Normal Text>        src </Normal Text><Operator>-=</Operator><Normal Text> @capacity </Normal Text><Keyword>if</Keyword><Normal Text> src </Normal Text><Operator>>=</Operator><Normal Text> @capacity</Normal Text><br/>
<Normal Text>        @buffer</Normal Text><Delimiter>[</Delimiter><Normal Text>dst</Normal Text><Delimiter>]</Delimiter><Normal Text> </Normal Text><Operator>=</Operator><Normal Text> @buffer</Normal Text><Delimiter>[</Delimiter><Normal Text>src</Normal Text><Delimiter>]</Delimiter><br/>
<Normal Text>        </Normal Text><Keyword>break</Keyword><Normal Text> </Normal Text><Keyword>if</Keyword><Normal Text> src </Normal Text><Operator>==</Operator><Normal Text> finish</Normal Text><br/>
<Normal Text>        dst </Normal Text><Operator>=</Operator><Normal Text> src</Normal Text><br/>
<Normal Text>      </Normal Text><Keyword>end</Keyword><br/>
<Normal Text>      (@buffer </Normal Text><Operator>+</Operator><Normal Text> finish)</Normal Text><Message>.clear</Message><br/>
<Normal Text>    </Normal Text><Keyword>end</Keyword><br/>
<Normal Text></Normal Text><br/>
<Normal Text>  </Normal Text><Keyword>end</Keyword><br/>
<Normal Text></Normal Text><br/>
<Normal Text>  </Normal Text><Keyword>def</Keyword><Normal Text> each(</Normal Text><Operator>& : </Operator><Normal Text>T </Normal Text><Operator>-></Operator><Normal Text>) : </Normal Text><Constant>Nil</Constant><br/>
<Normal Text>    halfs </Normal Text><Keyword>do</Keyword><Normal Text> </Normal Text><Operator>|</Operator><Normal Text>r</Normal Text><Operator>|</Operator><br/>
<Normal Text>      r</Normal Text><Message>.each</Message><Normal Text> </Normal Text><Keyword>do</Keyword><Normal Text> </Normal Text><Operator>|</Operator><Normal Text>i</Normal Text><Operator>|</Operator><br/>
<Normal Text>        </Normal Text><Keyword>yield</Keyword><Normal Text> @buffer</Normal Text><Delimiter>[</Delimiter><Normal Text>i</Normal Text><Delimiter>]</Delimiter><br/>
<Normal Text>      </Normal Text><Keyword>end</Keyword><br/>
<Normal Text>    </Normal Text><Keyword>end</Keyword><br/>
<Normal Text>  </Normal Text><Keyword>end</Keyword><br/>
<Normal Text></Normal Text><br/>
<Normal Text>  </Normal Text><Keyword>def</Keyword><Normal Text> pop : T</Normal Text><br/>
<Normal Text>    pop </Normal Text><Operator>{</Operator><Normal Text> </Normal Text><Kernel methods>raise</Kernel methods><Normal Text> </Normal Text><Constant>IndexError</Constant><Message>.new</Message><Normal Text> </Normal Text><Operator>}</Operator><br/>
<Normal Text>  </Normal Text><Keyword>end</Keyword><br/>
<Normal Text></Normal Text><br/>
<Normal Text></Normal Text><br/>
<Normal Text>  </Normal Text><Definition>macro</Definition><Normal Text> </Normal Text><Delimiter>[]</Delimiter><Normal Text>(</Normal Text><Operator>*</Operator><Normal Text>args)</Normal Text><br/>
<Normal Text>    array </Normal Text><Operator>=</Operator><Normal Text> uninitialized </Normal Text><Constant>Array</Constant><Normal Text>(</Normal Text><Constant>Int32</Constant><Normal Text>)</Normal Text><br/>
<Normal Text>    </Normal Text><Operator>{</Operator><Normal Text>% </Normal Text><Keyword>for</Keyword><Normal Text> arg, i </Normal Text><Keyword>in</Keyword><Normal Text> args %</Normal Text><Operator>}</Operator><br/>
<Normal Text>      array</Normal Text><Message>.to_unsafe</Message><Delimiter>[</Delimiter><Operator>{{</Operator><Normal Text>i</Normal Text><Operator>}}</Operator><Delimiter>]</Delimiter><Normal Text> </Normal Text><Operator>=</Operator><Normal Text> </Normal Text><Operator>{{</Operator><Normal Text>arg</Normal Text><Operator>}}</Operator><br/>
<Normal Text>    </Normal Text><Operator>{</Operator><Normal Text>% </Normal Text><Keyword>end</Keyword><Normal Text> %</Normal Text><Operator>}</Operator><br/>
<Normal Text>    array</Normal Text><br/>
<Normal Text>  </Normal Text><Keyword>end</Keyword><br/>
<Normal Text></Normal Text><br/>
<Normal Text>    </Normal Text><Keyword>def</Keyword><Normal Text> message : </Normal Text><Constant>String</Constant><br/>
<Normal Text>        </Normal Text><Keyword>case</Keyword><Normal Text> </Normal Text><Pseudo variable>self</Pseudo variable><br/>
<Normal Text>        </Normal Text><Keyword>when</Keyword><Normal Text> </Normal Text><Global Constant>SUCCESS</Global Constant><Normal Text>        </Normal Text><Keyword>then</Keyword><Normal Text> </Normal Text><String>"No error occurred. System call completed successfully."</String><br/>
<Normal Text>        </Normal Text><Keyword>when</Keyword><Normal Text> </Normal Text><Global Constant>TXTBSY</Global Constant><Normal Text>         </Normal Text><Keyword>then</Keyword><Normal Text> </Normal Text><Constant>Errno</Constant><Operator>::</Operator><Constant Value>ETXTBSY</Constant Value><br/>
<Normal Text>        </Normal Text><Keyword>when</Keyword><Normal Text> </Normal Text><Global Constant>NOTCAPABLE</Global Constant><Normal Text>     </Normal Text><Keyword>then</Keyword><Normal Text> </Normal Text><Constant>Errno</Constant><Operator>::</Operator><Constant Value>ENOTCAPABLE</Constant Value><br/>
<Normal Text>        </Normal Text><Keyword>else</Keyword><Normal Text>                     </Normal Text><Constant>Errno</Constant><Operator>::</Operator><Constant Value>EINVAL</Constant Value><br/>
<Normal Text>        </Normal Text><Keyword>end</Keyword><br/>
<Normal Text>    </Normal Text><Keyword>end</Keyword><br/>
<Normal Text></Normal Text><br/>
<Normal Text>    enum </Normal Text><Constant>Signal</Constant><br/>
<Normal Text>        </Normal Text><Global Constant>KILL</Global Constant><Normal Text> </Normal Text><Operator>=</Operator><Normal Text> </Normal Text><Dec>0</Dec><br/>
<Normal Text>        </Normal Text><Global Constant>BILL</Global Constant><Normal Text> </Normal Text><Operator>=</Operator><Normal Text> </Normal Text><Dec>101</Dec><br/>
<Normal Text>    </Normal Text><Keyword>end</Keyword><br/>
<Normal Text></Normal Text><br/>
<Keyword>end</Keyword><br/>
<Normal Text></Normal Text><br/>
<Normal Text></Normal Text><br/>
<Normal Text>  </Normal Text><Comment># :nodoc:</Comment><br/>
<Definition>module</Definition><Normal Text> </Normal Text><Constant>Ops</Constant><br/>
<Normal Text>    </Normal Text><Comment># Defines methods that directly map to LLVM instructions related to atomic operations.</Comment><br/>
<Normal Text></Normal Text><br/>
<Normal Text>    @</Normal Text><Delimiter>[</Delimiter><Constant>Primitive</Constant><Normal Text>(</Normal Text><Symbol>:cmpxchg</Symbol><Normal Text>)</Normal Text><Delimiter>]</Delimiter><br/>
<Normal Text>    </Normal Text><Keyword>def</Keyword><Normal Text> </Normal Text><Pseudo variable>self</Pseudo variable><Message>.cmpxchg</Message><Normal Text>(ptr : T</Normal Text><Operator>*</Operator><Normal Text>, cmp : T, new : T, success_ordering : </Normal Text><Global Constant>LLVM</Global Constant><Operator>::</Operator><Constant>AtomicOrdering</Constant><Normal Text>, failure_ordering : </Normal Text><Global Constant>LLVM</Global Constant><Operator>::</Operator><Constant>AtomicOrdering</Constant><Normal Text>) : </Normal Text><Operator>{</Operator><Normal Text>T, </Normal Text><Constant>Bool</Constant><Operator>}</Operator><Normal Text> forall T</Normal Text><br/>
<Normal Text>    </Normal Text><Keyword>end</Keyword><br/>
<Normal Text></Normal Text><br/>
<Normal Text>    @</Normal Text><Delimiter>[</Delimiter><Constant>Primitive</Constant><Normal Text>(</Normal Text><Symbol>:atomicrmw</Symbol><Normal Text>)</Normal Text><Delimiter>]</Delimiter><br/>
<Normal Text>    </Normal Text><Keyword>def</Keyword><Normal Text> </Normal Text><Pseudo variable>self</Pseudo variable><Message>.atomicrmw</Message><Normal Text>(op : </Normal Text><Global Constant>LLVM</Global Constant><Operator>::</Operator><Constant>AtomicRMWBinOp</Constant><Normal Text>, ptr : T</Normal Text><Operator>*</Operator><Normal Text>, val : T, ordering : </Normal Text><Global Constant>LLVM</Global Constant><Operator>::</Operator><Constant>AtomicOrdering</Constant><Normal Text>, singlethread : </Normal Text><Constant>Bool</Constant><Normal Text>) : T forall T</Normal Text><br/>
<Normal Text>    </Normal Text><Keyword>end</Keyword><br/>
<Keyword>end</Keyword><br/>
<Normal Text></Normal Text><br/>
<Normal Text></Normal Text><br/>
<Normal Text>@</Normal Text><Delimiter>[</Delimiter><Constant>Link</Constant><Normal Text>(</Normal Text><String>"z"</String><Normal Text>)</Normal Text><Delimiter>]</Delimiter><br/>
<Normal Text>lib </Normal Text><Constant>LibZ</Constant><br/>
<Normal Text>  </Normal Text><Definition>alias</Definition><Normal Text> </Normal Text><Constant>Char</Constant><Normal Text> </Normal Text><Operator>=</Operator><Normal Text> </Normal Text><Constant>LibC</Constant><Operator>::</Operator><Constant>Char</Constant><br/>
<Normal Text>  </Normal Text><Definition>alias</Definition><Normal Text> </Normal Text><Constant>SizeT</Constant><Normal Text> </Normal Text><Operator>=</Operator><Normal Text> </Normal Text><Constant>LibC</Constant><Operator>::</Operator><Constant>SizeT</Constant><br/>
<Normal Text></Normal Text><br/>
<Normal Text>  fun zlibVersion : </Normal Text><Constant>Char</Constant><Operator>*</Operator><br/>
<Normal Text>  fun crc32_combine(crc1 : </Normal Text><Constant>ULong</Constant><Normal Text>, crc2 : </Normal Text><Constant>ULong</Constant><Normal Text>, len : </Normal Text><Constant>Long</Constant><Normal Text>) : </Normal Text><Constant>ULong</Constant><br/>
<Normal Text></Normal Text><br/>
<Normal Text>  </Normal Text><Definition>alias</Definition><Normal Text> </Normal Text><Constant>AllocFunc</Constant><Normal Text> </Normal Text><Operator>=</Operator><Normal Text> </Normal Text><Constant>Void</Constant><Operator>*</Operator><Normal Text>, </Normal Text><Constant>UInt</Constant><Normal Text>, </Normal Text><Constant>UInt</Constant><Normal Text> </Normal Text><Operator>-></Operator><Normal Text> </Normal Text><Constant>Void</Constant><Operator>*</Operator><br/>
<Normal Text>  </Normal Text><Definition>alias</Definition><Normal Text> </Normal Text><Constant>FreeFunc</Constant><Normal Text> </Normal Text><Operator>=</Operator><Normal Text> (</Normal Text><Constant>Void</Constant><Operator>*</Operator><Normal Text>, </Normal Text><Constant>Void</Constant><Operator>*</Operator><Normal Text>) </Normal Text><Operator>-></Operator><br/>
<Normal Text></Normal Text><br/>
<Normal Text>  </Normal Text><Definition>struct</Definition><Normal Text> </Normal Text><Constant>ZStream</Constant><br/>
<Normal Text>    next_in : </Normal Text><Constant>Bytef</Constant><Operator>*</Operator><br/>
<Normal Text>    avail_in : </Normal Text><Constant>UInt</Constant><br/>
<Normal Text>    next_out : </Normal Text><Constant>Bytef</Constant><Operator>*</Operator><br/>
<Normal Text>    total_out : </Normal Text><Constant>ULong</Constant><br/>
<Normal Text>    msg : </Normal Text><Constant>Char</Constant><Operator>*</Operator><br/>
<Normal Text>    state : </Normal Text><Constant>Void</Constant><Operator>*</Operator><br/>
<Normal Text>    zalloc : </Normal Text><Constant>AllocFunc</Constant><br/>
<Normal Text>    zfree : </Normal Text><Constant>FreeFunc</Constant><br/>
<Normal Text>    opaque : </Normal Text><Constant>Void</Constant><Operator>*</Operator><br/>
<Normal Text>    data_type : </Normal Text><Constant>Int</Constant><br/>
<Normal Text>    adler : </Normal Text><Constant>Long</Constant><br/>
<Normal Text>  </Normal Text><Keyword>end</Keyword><br/>
<Normal Text></Normal Text><br/>
<Normal Text>  </Normal Text><Comment># error codes</Comment><br/>
<Normal Text>  enum </Normal Text><Constant>Error</Constant><br/>
<Normal Text>    </Normal Text><Global Constant>OK</Global Constant><Normal Text>            </Normal Text><Operator>=</Operator><Normal Text>  </Normal Text><Dec>0</Dec><br/>
<Normal Text>    </Normal Text><Global Constant>VERSION_ERROR</Global Constant><Normal Text> </Normal Text><Operator>=</Operator><Normal Text> </Normal Text><Operator>-</Operator><Dec>6</Dec><br/>
<Normal Text>  </Normal Text><Keyword>end</Keyword><br/>
<Normal Text></Normal Text><br/>
<Normal Text>  enum </Normal Text><Constant>Flush</Constant><br/>
<Normal Text>    </Normal Text><Global Constant>NO_FLUSH</Global Constant><Normal Text>      </Normal Text><Operator>=</Operator><Normal Text> </Normal Text><Dec>0</Dec><br/>
<Normal Text>    </Normal Text><Global Constant>TREES</Global Constant><Normal Text>         </Normal Text><Operator>=</Operator><Normal Text> </Normal Text><Dec>6</Dec><br/>
<Normal Text>  </Normal Text><Keyword>end</Keyword><br/>
<Normal Text></Normal Text><br/>
<Normal Text>  </Normal Text><Global Constant>MAX_BITS</Global Constant><Normal Text>      </Normal Text><Operator>=</Operator><Normal Text> </Normal Text><Dec>15</Dec><br/>
<Normal Text></Normal Text><br/>
<Normal Text>  fun deflateInit2 </Normal Text><Operator>=</Operator><Normal Text> deflateInit2_(stream : </Normal Text><Constant>ZStream</Constant><Operator>*</Operator><Normal Text>, level : </Normal Text><Constant>Int32</Constant><Normal Text>, method : </Normal Text><Constant>Int32</Constant><Normal Text>,</Normal Text><br/>
<Normal Text>                                   window_bits : </Normal Text><Constant>Int32</Constant><Normal Text>, mem_level : </Normal Text><Constant>Int32</Constant><Normal Text>, strategy : </Normal Text><Constant>Int32</Constant><Normal Text>,</Normal Text><br/>
<Normal Text>                                   version : </Normal Text><Constant>UInt8</Constant><Operator>*</Operator><Normal Text>, stream_size : </Normal Text><Constant>Int32</Constant><Normal Text>) : </Normal Text><Constant>Error</Constant><br/>
<Normal Text>  fun deflate(stream : </Normal Text><Constant>ZStream</Constant><Operator>*</Operator><Normal Text>, flush : </Normal Text><Constant>Flush</Constant><Normal Text>) : </Normal Text><Constant>Error</Constant><br/>
<Normal Text>  fun deflateSetDictionary(stream : </Normal Text><Constant>ZStream</Constant><Operator>*</Operator><Normal Text>, dictionary : </Normal Text><Constant>UInt8</Constant><Operator>*</Operator><Normal Text>, len : </Normal Text><Constant>UInt</Constant><Normal Text>) : </Normal Text><Constant>Int</Constant><br/>
<Normal Text></Normal Text><br/>
<Normal Text>  fun inflateInit2 </Normal Text><Operator>=</Operator><Normal Text> inflateInit2_(stream : </Normal Text><Constant>ZStream</Constant><Operator>*</Operator><Normal Text>, window_bits : </Normal Text><Constant>Int32</Constant><Normal Text>, version : </Normal Text><Constant>UInt8</Constant><Operator>*</Operator><Normal Text>, stream_size : </Normal Text><Constant>Int32</Constant><Normal Text>) : </Normal Text><Constant>Error</Constant><br/>
<Normal Text>  fun inflate(stream : </Normal Text><Constant>ZStream</Constant><Operator>*</Operator><Normal Text>, flush : </Normal Text><Constant>Flush</Constant><Normal Text>) : </Normal Text><Constant>Error</Constant><br/>
<Normal Text>  fun inflateSetDictionary(stream : </Normal Text><Constant>ZStream</Constant><Operator>*</Operator><Normal Text>, dictionary : </Normal Text><Constant>UInt8</Constant><Operator>*</Operator><Normal Text>, len : </Normal Text><Constant>UInt</Constant><Normal Text>) : </Normal Text><Constant>Error</Constant><br/>
<Keyword>end</Keyword><br/>
