PageRenderTime 35ms CodeModel.GetById 32ms app.highlight 1ms RepoModel.GetById 1ms app.codeStats 0ms

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