
== summary

This is the steps of amrita.

  1. parses the template and generate Node objects.

     Node object is direct representation of html/xhtml.

  2. compile Node objects to BYTECODE objects

     BYTECODE objects is virtual instructions for ARMITA-vm.

  3. set the model data and output port to AMRITA-vm.

  4. execute BYTECODE

     execute BYTECODE direct or translating it to Ruby-code partially.

== amrita virtual machine

amrita virtual machine is a virtual hardware with these virtual
hardwares.

  * register

    amrita-vm has only one register and most instructions fetch or
    store the data to/from it. This register can hold any Ruby datas.

  * stack

    amrita-vm has a stack of Ruby data. 

  * output port

    Any Ruby object which respond to '<<' method like String and IO
    ,can be set to this virtual output port. The result of template
    expanding will be put to this port by '<<' method.

  * Element Processor

    This is a virtual co-processor of amrita-vm. It treats Element
    objects. When amrita VM need to put an Element object to output
    port, it will use the ELement Processor in convertiong the ELement
    to String.

== BYTECODE

[NullInstruction] 
   do nothing                  
[GetDataByKey]
   get a data from register by [] method, push the old data to stack, and set the new data to register
[PopData] 
   pop a data from stack and set it to register
[SwapData] 
   swap the register and stack top
[PrintStaticNode] 
   put a static node object to output port
[PrintStaticText] 
   put a static text object to output port
[PrintRegister] 
   put the value of register to output port
[MergeElement]  
   merge the value of register with an Element given. set the new elemenet value to register
[GetDataFromAttrArray] 
   get the attributes as hash and body from register, set them to register and stack top.
[PushElement] 
   set the Element given to register
[ExtractData] 
   get a new Hash from register extracting by keys given.
[GetDataFromAmulet] 
   get the data and instruction set from an Amulet object set at register.
[ExecuteRegister]
   execute the 'execute' method of register

[Sequence]

[PrintDynamicElement]

[Loop]

[SelectByType]

InstructionSet holds a set of BYTECODE. It compiles and saves and
loads the BYTECODEs.

== Interface for BYTECODE

[prepare(opt, vm ,iset)]
  Prepares the internal data of this instruction. In pure-ruby mode,
  the BYTECODE is compiled to ruby-code.

[execute(register, stack, out, vm)]
  This will 'execute' the instruction and return the new register value.

== On-demand compilation and partial compilation


==


