about summary refs log blame commit diff stats
path: root/baremetal/shell/cell.mu
blob: 8627af1c3f757a9a391fc239095e25fac9d15db0 (plain) (tree)
1
2
3
4
5
6
7
8
9








                      
                                 

                                            









                                                                       







                                                





                                              
type cell {
  type: int
  # type 0: pair
  left: (handle cell)
  right: (handle cell)
  # type 1: number
  number-data: float
  # type 2: symbol
  # type 3: string
  text-data: (handle stream byte)
  # TODO: array, (associative) table, stream
}

fn new-symbol _out: (addr handle cell) {
  var out/eax: (addr handle cell) <- copy _out
  allocate out
  var out-addr/eax: (addr cell) <- lookup *out
  var type/ecx: (addr int) <- get out-addr, type
  copy-to *type, 2/symbol
  var dest-ah/eax: (addr handle stream byte) <- get out-addr, text-data
  populate-stream dest-ah, 0x40/max-symbol-size
}

fn new-number _out: (addr handle cell) {
  var out/eax: (addr handle cell) <- copy _out
  allocate out
  var out-addr/eax: (addr cell) <- lookup *out
  var type/ecx: (addr int) <- get out-addr, type
  copy-to *type, 1/number
}

fn new-pair _out: (addr handle cell) {
  var out/eax: (addr handle cell) <- copy _out
  allocate out
  # new cells have type pair by default
}