Changeset 3465:928c70cdbf08 in livinglogic.python.xist

Show
Ignore:
Timestamp:
07/08/08 13:26:33 (11 years ago)
Author:
Walter Doerwald <walter@…>
Branch:
default
Message:

Work on docstring for Opcode.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • src/ll/ul4c.py

    r3464 r3465  
    218218    """ 
    219219    Exception that is raised by the compiler when there are no more free 
    220     registers. This might happen with very complex expressions in tag code. 
     220    registers. This might happen with complex expressions in tag code. 
    221221    """ 
    222222 
     
    231231class Opcode(object): 
    232232    """ 
    233     An :class:`Opcode` stores an opcode. The type of opcode is stored in the 
    234     :attr:`code` attribute. Furthermore each opcode has up to five register 
    235     specifications (for the source or targets of the operation) in the attributes 
    236     :attr:`r1`, :attr:`r2`, :attr:`r3`, :attr:`r4` and :attr:`r5`. If the opcode 
    237     requires an additional argument (like a variable name or the value of a 
    238     constant) this will be stored in the :attr:`arg` attribute. 
     233    An :class:`Opcode` stores an opcode. An :class:`Opcode` object has the 
     234    following attributes: 
     235 
     236    :attr:`type` : string or :const:`None` 
     237        The opcode type (see below for a list). 
     238 
     239    :attr:`r1`, :attr:`r2`, :attr:`r3`, :attr:`r4`, :attr:`r5` : integer or :const:`None` 
     240         Register specifications (for the sources or the target of the opcode) 
     241 
     242    :attr:`arg` : string or :const:`None` 
     243        Used if the opcode requires an additional argument (like a variable name 
     244        or the value of a constant). 
     245 
     246    :attr:`location` : :class:`Location` object 
     247        The location of the tag to which this opcode belongs. 
    239248 
    240249    The following opcodes are available: 
     
    248257 
    249258    ``"loadnone"``: 
    250         Load the constant :const:`None`. 
     259        Load the constant :const:`None` into register :attr:`r1`. 
    251260 
    252261    ``"loadfalse"``: 
    253         Load the constant :const:`False`. 
     262        Load the constant :const:`False` into register :attr:`r1`. 
    254263 
    255264    ``"loadtrue"``: 
    256         Load the constant :const:`True`. 
     265        Load the constant :const:`True` into register :attr:`r1`. 
    257266 
    258267    ``"loadstr"``: 
    259         Load the string :attr:`arg` into the register :attr:`r1`. 
     268        Load the string :attr:`arg` into register :attr:`r1`. 
    260269 
    261270    ``"loadint"``: 
    262         Load the integer value :attr:`arg` into the register :attr:`r1`. 
     271        Load the integer value :attr:`arg` into register :attr:`r1`. 
    263272 
    264273    ``"loadfloat"``: 
    265         Load the float value :attr:`arg` into the register :attr:`r1`. 
     274        Load the float value :attr:`arg` into register :attr:`r1`. 
    266275 
    267276    ``"loaddate"``: 
    268         Load the date value :attr:`arg` into the register :attr:`r1`. :attr:`arg` 
    269         must be in ISO format (e.g. ``2008-07-02T11:05:55.460464``). 
     277        Load the date value :attr:`arg` into register :attr:`r1`. :attr:`arg` must 
     278        be in ISO format (e.g. ``2008-07-02T11:05:55.460464``). 
    270279 
    271280    ``"buildlist"``: 
    272         Load an empty list into the register :attr:`r1`. 
     281        Load an empty list into register :attr:`r1`. 
    273282 
    274283    ``"builddict"``: 
    275         Load an empty dictionary into the register :attr:`r1`. 
     284        Load an empty dictionary into register :attr:`r1`. 
    276285 
    277286    ``"addlist"`` 
     
    296305 
    297306    ``"endfor"``: 
    298         Ends the innermost running ``for`` loop. 
     307        End the innermost running ``for`` loop. 
    299308 
    300309    ``"if"``: 
    301         Starts a conditional block. If the objects in the register :attr:`r1` is 
     310        Start a conditional block. If the objects in the register :attr:`r1` is 
    302311        true the block will be executed. The "block" consists of all opcodes after 
    303312        the ``if`` upto the matching ``else`` or ``endif`` opcode. 
     
    315324    ``"getitem"``: 
    316325        Get an item from the object in register :attr:`r2`. If this object is a 
    317         list the object in register :attr:`r3` will be used as the index. If it is 
    318         a dictionary :attr:`r3` will be used as the key. The result will be stored 
    319         in register :attr:`r1`. 
     326        list or string the object in register :attr:`r3` will be used as the 
     327        index. If it is a dictionary :attr:`r3` will be used as the key. The 
     328        result will be stored in register :attr:`r1`. 
    320329 
    321330    ``"getslice12"``: 
    322331        Get an slice from the object in register :attr:`r2`. The object in 
    323332        register :attr:`r3` (which must be an ``int`` or :const:`None`) specifies 
    324         the start index, If this object in register :attr:`r4` specifies the end 
    325         index. The result will be stored in register :attr:`r1`. 
     333        the start index, the object in register :attr:`r4` specifies the end index. 
     334        The result will be stored in register :attr:`r1`. 
    326335 
    327336    ``"getslice1"``: 
     
    351360    ``"contains"``: 
    352361        Test whether the object in register :attr:`r3` contains the object in 
    353         register :attr:`r2` (either as a key if it's a dictionary or as an item 
    354         if it's a list or as a substring if it's a string) and store ``True`` into 
    355         the register :attr:`r1` if it does, ``False`` otherwise. 
     362        register :attr:`r2` (either as a key if :attr:`r3` is a dictionary or as 
     363        an item if it's a list or as a substring if it's a string) and store 
     364        ``True`` into the register :attr:`r1` if it does, ``False`` otherwise. 
    356365 
    357366    ``"notcontains"``: 
    358367        Test whether the object in register :attr:`r3` contains the object in 
    359         register :attr:`r2` (either as a key if it's a dictionary or as an item 
    360         if it's a list or as a substring if it's a string) and store ``False`` into 
    361         the register :attr:`r1` if it does, ``True`` otherwise. 
     368        register :attr:`r2` (either as a key if :attr:`r3` is a dictionary or as 
     369        an item if it's a list or as a substring if it's a string) and store 
     370        ``False`` into the register :attr:`r1` if it does, ``True`` otherwise. 
    362371 
    363372    ``"or"``: 
    364         Check the truth value of two object in registers :attr:`r2` and :attr:`r3` 
    365         and store :attr:`r2` in the register :attr:`r1` if it is true, :attr:`r3` 
    366         otherwise). 
     373        Check the truth value of the two objects in registers :attr:`r2` and 
     374        :attr:`r3` and store :attr:`r2` in the register :attr:`r1` if it is true, 
     375        :attr:`r3` otherwise). 
    367376 
    368377    ``"and"``: 
    369         Check the truth value of two object in registers :attr:`r2` and :attr:`r3` 
    370         and store :attr:`r3` in the register :attr:`r1` if :attr:`r2` is true, 
    371         :attr:`r3` otherwise). 
     378        Check the truth value of the two objects in registers :attr:`r2` and 
     379        :attr:`r3` and store :attr:`r3` in the register :attr:`r1` if :attr:`r2` 
     380        is true, :attr:`r3` otherwise). 
    372381 
    373382    ``"mod"``: 
    374383        Does a modulo operation: Calculates :attr:`r2` modulo :attr:`r3` and stores 
    375         the result in the register :attr:`r1`. 
     384        the result in register :attr:`r1`. 
    376385 
    377386    ``"callfunc0"``: 
     
    399408    ``"callmeth1"``: 
    400409        Call the method named :attr:`arg` on the object in register :attr:`r2` 
    401         using the object in register :attr:`r3` as to only argument and store the 
     410        using the object in register :attr:`r3` as the only argument and store the 
    402411        return value in register :attr:`r1`. 
    403412 
     
    414423    ``"render"``: 
    415424        Render the template whose name is in the attribute :attr:`arg`. The 
    416         content of register :attr:`r1` will be passed as the data object to the 
    417         template. 
     425        content of register :attr:`r1` (which must be a dictionary) will be passed 
     426        to the template as the variable dictionary. 
    418427    """ 
    419428    __slots__ = ("code", "r1", "r2", "r3", "r4", "r5", "arg", "location", "jump")