fw.go 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. package main
  2. import (
  3. "flag"
  4. "fw/cp"
  5. cpm "fw/cp/module"
  6. "fw/rt2/context"
  7. "fw/rt2/decision"
  8. rtm "fw/rt2/module"
  9. _ "fw/rt2/rules2"
  10. "fw/rt2/scope"
  11. "fw/utils"
  12. "github.com/kpmy/ypk/assert"
  13. "log"
  14. "time"
  15. )
  16. var name string
  17. var debug bool = false
  18. var heap scope.Manager
  19. func init() {
  20. flag.StringVar(&name, "i", "", "-i name.ext")
  21. flag.BoolVar(&debug, "d", false, "-d true/false")
  22. }
  23. func close() {
  24. utils.Debug(false)
  25. utils.PrintFrame("____")
  26. utils.PrintFrame(heap)
  27. utils.PrintFrame("^^^^")
  28. log.Println("closed")
  29. }
  30. func main() {
  31. flag.Parse()
  32. utils.Debug(debug)
  33. if name == "" {
  34. utils.Debug2(false, false)
  35. //name = "XevDemo23"
  36. //name = "XevDemo11"
  37. //name = "XevDemo12"
  38. //name = "XevDemo13"
  39. //name = "XevDemo19"
  40. name = "Start4"
  41. }
  42. global := &stdDomain{god: true}
  43. global.global = global
  44. modList := rtm.New()
  45. global.Attach(context.MOD, modList)
  46. global.Attach(context.DIGEST, context.Data(cp.Init()))
  47. global.Attach(context.HEAP, scope.New(context.HEAP))
  48. global.Attach(context.SCOPE, scope.New(context.SCOPE))
  49. global.Attach(context.CALL, scope.New(context.CALL))
  50. t0 := time.Now()
  51. var init []*cpm.Module
  52. _, err := modList.Load(name, func(m *cpm.Module) {
  53. init = append(init, m)
  54. })
  55. t1 := time.Now()
  56. log.Println("load", t1.Sub(t0))
  57. assert.For(err == nil, 40)
  58. defer close()
  59. decision.Run(global, init)
  60. }