heap.go 1000 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. package std
  2. import (
  3. "fmt"
  4. "fw/cp/node"
  5. "fw/cp/object"
  6. "fw/rt2/context"
  7. "fw/rt2/scope"
  8. "reflect"
  9. )
  10. type heap struct {
  11. d context.Domain
  12. data *area
  13. next int64
  14. }
  15. func nh() scope.Manager {
  16. return &heap{data: &area{ready: true, root: nil, x: make(map[scope.ID]interface{})}}
  17. }
  18. func (h *heap) Allocate(n node.Node) scope.ValueFor {
  19. switch v := n.(type) {
  20. case node.VariableNode:
  21. switch t := v.Object().Complex().(type) {
  22. case object.PointerType:
  23. default:
  24. panic(fmt.Sprintln("unsupported type", reflect.TypeOf(t)))
  25. }
  26. default:
  27. panic(fmt.Sprintln("unsupported node", reflect.TypeOf(v)))
  28. }
  29. }
  30. func (h *heap) Dispose(n node.Node) {
  31. }
  32. func (h *heap) Target(...scope.Allocator) scope.Allocator {
  33. return h
  34. }
  35. func (h *heap) Update(i scope.ID, val scope.ValueFor) {}
  36. func (h *heap) Select(i scope.ID) interface{} { return nil }
  37. func (h *heap) Init(d context.Domain) { h.d = d }
  38. func (h *heap) Domain() context.Domain { return h.d }
  39. func (h *heap) Handle(msg interface{}) {}