-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathFunctionPointer.h
40 lines (34 loc) · 1.3 KB
/
FunctionPointer.h
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
#pragma once
#include <string>
#include <vector>
#include <memory>
class Context;
class Expression;
class TypedValue;
/// Egy meghívható függvényt reprezentál
class FunctionPointer
{
public:
/// Függvény meghívása
/// @param callingContext A hívó kontextus
/// @param paramValues A függvény paraméterei
virtual std::shared_ptr<const TypedValue> call(const Context& callingContext, std::vector<const Expression*> params, int startLine, int startColumn) = 0;
/// A függvény fejléce (kiíráshoz)
virtual std::string getSignature() const = 0;
};
/// Nem built in függvény
class ExpressionFunctionPointer : public FunctionPointer
{
private:
/// A függvény paramétereinek azonosítói
std::vector<std::string> parameters;
/// A függvény kifejezése (ezt értékeljük ki híváskor)
const Expression* expression;
public:
/// @param parameters A függvény paramétereinek azonosítói
/// @param expression A függvény kifejezése (ezt értékeljük ki híváskor)
ExpressionFunctionPointer(const std::vector<std::string>& parameters, const Expression* expression);
~ExpressionFunctionPointer();
std::shared_ptr<const TypedValue> call(const Context& callingContext, std::vector<const Expression*> params, int startLine, int startColumn) override;
std::string getSignature() const override;
};