1 # new data structure: a slice is an open interval of addresses [start, end) 2 # that includes 'start' but not 'end' 3 4 == code 5 # instruction effective address register displacement immediate 6 # . op subop mod rm32 base index scale r32 7 # . 1-3 bytes 3 bits 2 bits 3 bits 3 bits 3 bits 2 bits 2 bits 0/1/2/4 bytes 0/1/2/4 bytes 8 9 slice-empty?: # s: (addr slice) -> result/eax: boolean 10 # . prologue 11 55/push-ebp 12 89/copy 3/mod/direct 5/rm32/ebp . . . 4/r32/esp . . # copy esp to ebp 13 # . save registers 14 51/push-ecx 15 # ecx = s 16 8b/copy 1/mod/*+disp8 5/rm32/ebp . . . 1/r32/ecx 8/disp8 . # copy *(ebp+8) to ecx 17 # if (s->start >= s->end) return true 18 # . eax = s->start 19 8b/copy 0/mod/indirect 1/rm32/ecx . . . 0/r32/eax . . # copy *ecx to eax 20 # . if (eax >= s->end) return true 21 3b/compare 1/mod/*+disp8 1/rm32/ecx . . . 0/r32/eax 4/disp8 . # compare eax with *(ecx+4) 22 b8/copy-to-eax 1/imm32/true 23 73/jump-if-addr>= $slice-empty?:end/disp8 24 b8/copy-to-eax 0/imm32/false 25 $slice-empty?:end: 26 # . restore registers 27 59/pop-to-ecx 28 # . epilogue 29 89/copy 3/mod/direct 4/rm32/esp . . . 5/r32/ebp . . # copy ebp to esp 30 5d/pop-to-ebp 31 c3/return 32 33 test-slice-empty-true: 34 # . prologue 35 55/push-ebp 36 89/copy 3/mod/direct 5/rm32/ebp . . . 4/r32/esp . . # copy esp to ebp 37 # var slice/ecx: slice = {34, 34} 38 68/push 34/imm32/end 39 68/push 34/imm32/start 40 89/copy 3/mod/direct 1/rm32/ecx . . . 4/r32/esp . . # copy esp to ecx 41 # slice-empty?(slice) 42 # . . push args 43 51/push-ecx 44 # . . call 45 e8/call slice-empty?/disp32 46 # . . discard args 47 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 4/imm32 # add to esp 48 # check-ints-equal(eax, 1, msg) 49 # . . push args 50 68/push "F - test-slice-empty-true"/imm32 51 68/push 1/imm32 52 50/push-eax 53 # . . call 54 e8/call check-ints-equal/disp32 55 # . . discard args 56 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 0xc/imm32 # add to esp 57 # . epilogue 58 89/copy 3/mod/direct 4/rm32/esp . . . 5/r32/ebp . . # copy ebp to esp 59 5d/pop-to-ebp 60 c3/return 61 62 test-slice-empty-false: 63 # . prologue 64 55/push-ebp 65 89/copy 3/mod/direct 5/rm32/ebp . . . 4/r32/esp . . # copy esp to ebp 66 # var slice/ecx: slice = {32, 34} 67 68/push 34/imm32/end 68 68/push 32/imm32/start 69 89/copy 3/mod/direct 1/rm32/ecx . . . 4/r32/esp . . # copy esp to ecx 70 # slice-empty?(slice) 71 # . . push args 72 51/push-ecx 73 # . . call 74 e8/call slice-empty?/disp32 75 # . . discard args 76 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 4/imm32 # add to esp 77 # check-ints-equal(eax, 0, msg) 78 # . . push args 79 68/push "F - test-slice-empty-false"/imm32 80 68/push 0/imm32 81 50/push-eax 82 # . . call 83 e8/call check-ints-equal/disp32 84 # . . discard args 85 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 0xc/imm32 # add to esp 86 # . epilogue 87 89/copy 3/mod/direct 4/rm32/esp . . . 5/r32/ebp . . # copy ebp to esp 88 5d/pop-to-ebp 89 c3/return 90 91 test-slice-empty-if-start-greater-than-end: 92 # . prologue 93 55/push-ebp 94 89/copy 3/mod/direct 5/rm32/ebp . . . 4/r32/esp . . # copy esp to ebp 95 # var slice/ecx: slice = {34, 32} 96 68/push 32/imm32/end 97 68/push 34/imm32/start 98 89/copy 3/mod/direct 1/rm32/ecx . . . 4/r32/esp . . # copy esp to ecx 99 # slice-empty?(slice) 100 # . . push args 101 51/push-ecx 102 # . . call 103 e8/call slice-empty?/disp32 104 # . . discard args 105 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 4/imm32 # add to esp 106 # check-ints-equal(eax, 1, msg) 107 # . . push args 108 68/push "F - test-slice-empty-if-start-greater-than-end"/imm32 109 68/push 1/imm32 110 50/push-eax 111 # . . call 112 e8/call check-ints-equal/disp32 113 # . . discard args 114 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 0xc/imm32 # add to esp 115 # . epilogue 116 89/copy 3/mod/direct 4/rm32/esp . . . 5/r32/ebp . . # copy ebp to esp 117 5d/pop-to-ebp 118 c3/return 119 120 slice-equal?: # s: (addr slice), p: (addr array byte) -> result/eax: boolean 121 # pseudocode: 122 # if (p == 0) return (s == 0) 123 # currs = s->start 124 # maxs = s->end 125 # if (maxs - currs != p->size) return false 126 # currp = p->data 127 # while currs < maxs 128 # if (*currs != *currp) return false 129 # ++currs 130 # ++currp 131 # return true 132 # 133 # registers: 134 # currs: edx 135 # maxs: esi 136 # currp: ebx 137 # *currs: eax 138 # *currp: ecx 139 # 140 # . prologue 141 55/push-ebp 142 89/copy 3/mod/direct 5/rm32/ebp . . . 4/r32/esp . . # copy esp to ebp 143 # . save registers 144 51/push-ecx 145 52/push-edx 146 53/push-ebx 147 56/push-esi 148 # esi = s 149 8b/copy 1/mod/*+disp8 5/rm32/ebp . . . 6/r32/esi 8/disp8 . # copy *(ebp+8) to esi 150 # var currs/edx: (addr byte) = s->start 151 8b/copy 0/mod/indirect 6/rm32/esi . . . 2/r32/edx . . # copy *esi t<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <html><head><title>Python: module ranger.fsobject.loader</title> </head><body bgcolor="#f0f0f8"> <table width="100%" cellspacing=0 cellpadding=2 border=0 summary="heading"> <tr bgcolor="#7799ee"> <td valign=bottom> <br> <font color="#ffffff" face="helvetica, arial"> <br><big><big><strong><a href="ranger.html"><font color="#ffffff">ranger</font></a>.<a href="ranger.fsobject.html"><font color="#ffffff">fsobject</font></a>.loader</strong></big></big></font></td ><td align=right valign=bottom ><font color="#ffffff" face="helvetica, arial"><a href=".">index</a><br><a href="file:/home/hut/ranger/ranger/fsobject/loader.py">/home/hut/ranger/ranger/fsobject/loader.py</a></font></td></tr></table> <p><tt># Copyright (C) 2009, 2010 Roman Zimbelmann <romanz@lavabit.com><br> #<br> # This program is free software: you can redistribute it and/or modify<br> # it under the terms of the GNU General Public License as published by<br> # the Free Software Foundation, either version 3 of the License, or<br> # (at your option) any later version.<br> #<br> # This program is distributed in the hope that it will be useful,<br> # but WITHOUT ANY WARRANTY; without even the implied warranty of<br> # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the<br> # GNU General Public License for more details.<br> #<br> # You should have received a copy of the GNU General Public License<br> # along with this program. If not, see <<a href="http://www.gnu.org/licenses/">http://www.gnu.org/licenses/</a>>.</tt></p> <p> <table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section"> <tr bgcolor="#aa55cc"> <td colspan=3 valign=bottom> <br> <font color="#ffffff" face="helvetica, arial"><big><strong>Modules</strong></big></font></td></tr> <tr><td bgcolor="#aa55cc"><tt> </tt></td><td> </td> <td width="100%"><table width="100%" summary="list"><tr><td width="25%" valign=top><a href="math.html">math</a><br> </td><td width="25%" valign=top></td><td width="25%" valign=top></td><td width="25%" valign=top></td></tr></table></td></tr></table><p> <table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section"> <tr bgcolor="#ee77aa"> <td colspan=3 valign=bottom> <br> <font color="#ffffff" face="helvetica, arial"><big><strong>Classes</strong></big></font></td></tr> <tr><td bgcolor="#ee77aa"><tt> </tt></td><td> </td> <td width="100%"><dl> <dt><font face="helvetica, arial"><a href="__builtin__.html#object">__builtin__.object</a> </font></dt><dd> <dl> <dt><font face="helvetica, arial"><a href="ranger.fsobject.loader.html#LoadableObject">LoadableObject</a> </font></dt></dl> </dd> <dt><font face="helvetica, arial"><a href="ranger.shared.html#FileManagerAware">ranger.shared.FileManagerAware</a>(<a href="ranger.shared.html#Awareness">ranger.shared.Awareness</a>) </font></dt><dd> <dl> <dt><font face="helvetica, arial"><a href="ranger.fsobject.loader.html#Loader">Loader</a> </font></dt></dl> </dd> </dl> <p> <table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section"> <tr bgcolor="#ffc8d8"> <td colspan=3 valign=bottom> <br> <font color="#000000" face="helvetica, arial"><a name="LoadableObject">class <strong>LoadableObject</strong></a>(<a href="__builtin__.html#object">__builtin__.object</a>)</font></td></tr> <tr><td bgcolor="#ffc8d8"><tt> </tt></td><td> </td> <td width="100%">Methods defined here:<br> <dl><dt><a name="LoadableObject-__init__"><strong>__init__</strong></a>(self, gen, descr)</dt></dl> <dl><dt><a name="LoadableObject-get_description"><strong>get_description</strong></a>(self)</dt></dl> <hr> Data descriptors defined here:<br> <dl><dt><strong>__dict__</strong></dt> <dd><tt>dictionary for instance variables (if defined)</tt></dd> </dl> <dl><dt><strong>__weakref__</strong></dt> <dd><tt>list of weak references to the object (if defined)</tt></dd> </dl> </td></tr></table> <p> <table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section"> <tr bgcolor="#ffc8d8"> <td colspan=3 valign=bottom> <br> <font color="#000000" face="helvetica, arial"><a name="Loader">class <strong>Loader</strong></a>(<a href="ranger.shared.html#FileManagerAware">ranger.shared.FileManagerAware</a>)</font></td></tr> <tr><td bgcolor="#ffc8d8"><tt> </tt></td><td> </td> <td width="100%"><dl><dt>Method resolution order:</dt> <dd><a href="ranger.fsobject.loader.html#Loader">Loader</a></dd> <dd><a href="ranger.shared.html#FileManagerAware">ranger.shared.FileManagerAware</a></dd> <dd><a href="ranger.shared.html#Awareness">ranger.shared.Awareness</a></dd> <dd><a href="__builtin__.html#object">__builtin__.object</a></dd> </dl> <hr> Methods defined here:<br> <dl><dt><a name="Loader-__init__"><strong>__init__</strong></a>(self)</dt></dl> <dl><dt><a name="Loader-add"><strong>add</strong></a>(self, obj)</dt><dd><tt>Add an <a href="__builtin__.html#object">object</a> to the queue.<br> It should have a load_generator method.</tt></dd></dl> <dl><dt><a name="Loader-has_work"><strong>has_work</strong></a>(self)</dt><dd><tt>Is there anything to load?</tt></dd></dl> <dl><dt><a name="Loader-move"><strong>move</strong></a>(self, _from, to)</dt></dl> <dl><dt><a name="Loader-remove"><strong>remove</strong></a>(self, item<font color="#909090">=None</font>, index<font color="#909090">=None</font>)</dt></dl> <dl><dt><a name="Loader-rotate"><strong>rotate</strong></a>(self)</dt><dd><tt>Rotate the throbber</tt></dd></dl> <dl><dt><a name="Loader-work"><strong>work</strong></a>(self)</dt><dd><tt>Load items from the queue if there are any.<br> Stop after approximately self.<strong>seconds_of_work_time</strong>.</tt></dd></dl> <hr> Data and other attributes defined here:<br> <dl><dt><strong>seconds_of_work_time</strong> = 0.029999999999999999</dl> <hr> Data and other attributes inherited from <a href="ranger.shared.html#FileManagerAware">ranger.shared.FileManagerAware</a>:<br> <dl><dt><strong>fm</strong> = None</dl> <hr> Data descriptors inherited from <a href="ranger.shared.html#Awareness">ranger.shared.Awareness</a>:<br> <dl><dt><strong>__dict__</strong></dt> <dd><tt>dictionary for instance variables (if defined)</tt></dd> </dl> <dl><dt><strong>__weakref__</strong></dt> <dd><tt>list of weak references to the object (if defined)</tt></dd> </dl> </td></tr></table></td></tr></table><p> <table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section"> <tr bgcolor="#eeaa77"> <td colspan=3 valign=bottom> <br> <font color="#ffffff" face="helvetica, arial"><big><strong>Functions</strong></big></font></td></tr> <tr><td bgcolor="#eeaa77"><tt> </tt></td><td> </td> <td width="100%"><dl><dt><a name="-status_generator"><strong>status_generator</strong></a>()</dt><dd><tt>Generate a rotating line which can be used as a throbber</tt></dd></dl> <dl><dt><a name="-time"><strong>time</strong></a>(...)</dt><dd><tt><a href="#-time">time</a>() -> floating point number<br> <br> Return the current time in seconds since the Epoch.<br> Fractions of a second may be present if the system clock provides them.</tt></dd></dl> </td></tr></table> </body></html>