-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathLoxFunction.hpp
41 lines (33 loc) · 866 Bytes
/
LoxFunction.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
// Copyright 2020 <Copyright hulin>
#ifndef LOXFUNCTION_HPP_
#define LOXFUNCTION_HPP_
#include <memory>
#include <vector>
#include <string>
#include "./LoxCallable.hpp"
#include "./Interpreter.hpp"
#include "./Environment.hpp"
#include "./Stmt.hpp"
#include "./Token.hpp"
using std::shared_ptr;
using std::vector;
using std::string;
class LoxFunction: public LoxCallable {
public:
shared_ptr<Function> declaration;
shared_ptr<Environment> closure;
bool isInitializer;
explicit LoxFunction(
shared_ptr<Function> declaration_,
shared_ptr<Environment> closure_,
bool isInitializer_
);
int arity();
Object call(
shared_ptr<Interpreter> interpreter,
vector<Object> arguments
);
shared_ptr<LoxFunction> bind(shared_ptr<LoxInstance> instance);
string toString();
};
#endif // LOXFUNCTION_HPP_