bytecode-todo.txt 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. when rewriting bytecode, keep in mind jumps are relative to END of opcode now
  2. string offsets should be relative to operand position!
  3. bytecode issues-
  4. operand types- basic datatypes, array/hash, variant, specific object types
  5. stack/local/global/pop
  6. requires conversion in-place
  7. requires conversion as-temporary
  8. static string
  9. conversion via operand is slower than conversion opcode, so use opcode when from-type is known
  10. linking to functions/variables within OTHER objects
  11. I can detect functions or code blocks that never exit without requiring the 'main' keyword.
  12. Temporary data types-
  13. Special types: datatype (for as/is), 'all', 'all_other', 'nothing', 'this'
  14. Location: stack (temporary or variable), local, global, literal
  15. Type: unknown / variant
  16. variant hash or array
  17. int, str, float, obj_*
  18. any of these + hash or array
  19. obj_* subtype (applies to obj_* or strings or special values above)
  20. Flags: is a unique copy (not a reference to hash/array)
  21. for stack items, can be flagged as a direct pointer derived from an array/hash index (not w/variant type)
  22. String literals can be a literal or a reference into string bank
  23. Operand modes- 8 bits
  24. 0-15: base type- 0 actual entry 1 int 2 float 3 string 4 const-string 5 array 6 hash 7 obj_entity 8 obj_entity+subtype 9+ obj_* (7 types available)
  25. 0-15 alone: literals- 0 none 1 int/offset 2 float 3 pointer (jump/c) 4 (const-)string 5-6 reserved for array/hash literals 7 'all' 8 'all_other' 9 'this'
  26. (this works because pop+convert-in-place+NO-convert-as-copy is illegal and conveniently 0)
  27. 16/32: 0 pop 16 stack 32 local 48 global
  28. +0: convert-in-place (new hash/array ref IF converted)
  29. +64: do NOT convert-in-place: type is prechecked
  30. +128: convert-as-copy (ALWAYS a new hash/array even if proper type)
  31. +64+128: use with pop/stack to denote a pointer directly to the base type within an array/hash (no conversion allowed; subtype legal though)
  32. All operand modes pull a single 32bit operand out of bytecode except-
  33. pop or 'none/all/all_other/this'- pull nothing
  34. obj_entity+subtype- pulls an extra 32bit for subtype FIRST
  35. literal/global pointer- pulls pointer size (may be 32bit or 64bit etc)
  36. literal float- pulls float size (may be 32bit or more)
  37. Stack entries-
  38. Special types: return pointer, reply pointer, reply-waiting pointer, empty, array/hash-item-pointer
  39. Type: int, str, float, obj_*, (specific obj_* subtype tracked by code and unneeded)
  40. any of these + hash or array
  41. Globals-
  42. Any 'type:' above, plus subtypes are actually denoted
  43. Array/hash members-
  44. Type: int, str, float, obj_*, specific obj_* subtype
  45. One type throughout entire structure
  46. Single entity reference of known type, linked method/property location, known parameters- (best case)
  47. Can be 'nothing' reference-
  48. SEND [obj_entity] [function_ptr] [num_param]
  49. STOREx [obj_entity] [local_ptr]
  50. PUSHx [obj_entity] [local_ptr]
  51. Entity reference is cast using 'as', but unsure if matches type-
  52. OR Entity reference of unknown type, uncast, but method only exists in one script type-
  53. Can be 'nothing' reference-
  54. SEND [obj_entity](type) [function_ptr] [num_param]
  55. STOREx [obj_entity](type) [local_ptr]
  56. PUSHx [obj_entity](type) [local_ptr]
  57. Accessing matching entities of specified type, linked method/property location, known parameters-
  58. SEND [string|all|all_but](type) [function_ptr] [num_param]
  59. STOREx [string|all|all_but](type) [local_ptr]
  60. PUSHx [string|all|all_but](type) [local_ptr]
  61. Entity reference of unknown type, uncast, cannot know location of method or property-
  62. Can be 'nothing' reference-
  63. SEND [obj_entity] [string] [num_param]
  64. STOREx [obj_entity] [string]
  65. PUSHx [obj_entity] [string]
  66. Accessing matching entities of unknown/any type, cannot know location of method or property-
  67. SEND [string|all|all_but] [string] [num_param]
  68. STOREx [string|all|all_but] [string]
  69. PUSHx [string|all|all_but] [string]
  70. FURTHER TODO: (need to reevaluate in light of recent changes)
  71. whenever requesting a token, you can say "not looking for a newline" and it'll ignore them?
  72. shorthand to access all objects of a given name-
  73. with (ball)
  74. {
  75. x = other.x;
  76. y = other.y;
  77. }
  78. also of note- 'other'- need a way to refer to the 'sending' object if there is one
  79. use variables for common things like x/y position?
  80. built-in variables/variables that trigger get/set events?
  81. How to peek beyond current block for possibly main/possibly replies?
  82. void return type to avoid 'did not return a value' error?
  83. global (and local!) initialization needs clarification/strategy
  84. condense [offset] (S) (B) etc into one [Raw] addr mode
  85. [reuse] addr mode?
  86. array constants (as a var/datatype)
  87. finish const assignment
  88. finish string virtualization in const vars
  89. certain other built-ins may become operators or pseudo-operators (self, values, changename, indices, length, substr, sizeof)
  90. add internal operand modes- 'datatype', '(something) as script name'
  91. &&||^^real as alternate syntax