/source/core/ast/NumberLit.ooc

http://github.com/nddrylliog/oc · Unknown · 35 lines · 25 code · 10 blank · 0 comment · 0 complexity · cf0baec2443553e15bab463ca677044f MD5 · raw file

  1. import Expression, Type
  2. import middle/Resolver
  3. /** Different number formats - in sync with nagaqueen's "IntFormat" */
  4. NumberFormat: enum {
  5. bin = 2
  6. oct = 8
  7. dec = 10
  8. hex = 16
  9. }
  10. NumberLit: class extends Expression {
  11. format: NumberFormat
  12. value: String
  13. type := static BaseType new("int") // well, maybe
  14. init: func (=format, =value) {}
  15. resolve: func (task: Task) {
  16. task queue(type)
  17. }
  18. getType: func -> Type { type }
  19. intValue: func -> LLong {
  20. value toLLong(format as Int)
  21. }
  22. toString: func -> String {
  23. value
  24. }
  25. }