/source/core/ast/Call.ooc

http://github.com/nddrylliog/oc · Unknown · 36 lines · 27 code · 9 blank · 0 comment · 0 complexity · 51f1a539b755f65a3670f086eb4f07fb MD5 · raw file

  1. import structs/[List, ArrayList]
  2. import middle/Resolver
  3. import FuncDecl, Expression, Access, Type
  4. Call: class extends Expression {
  5. subject: Access { get set }
  6. args: List<Expression> { get set }
  7. init: func (=subject) {
  8. args = ArrayList<Expression> new()
  9. }
  10. resolve: func (task: Task) {
  11. task queueList(args)
  12. task queue(subject)
  13. }
  14. toString: func -> String {
  15. subject toString() + "(" + args map(|x| x toString()) join(", ") + ")"
  16. }
  17. getType: func -> Type {
  18. sType := subject getType()
  19. if(sType) match (sType) {
  20. case ft: FuncType =>
  21. return ft proto retType
  22. case =>
  23. Exception new("Trying to call something that's not a function! " + sType toString())
  24. }
  25. null
  26. }
  27. }