Loading...
Searching...
No Matches
func.hpp
Go to the documentation of this file.
1
2#pragma once
3
7#include "core/ast/params.hpp"
8#include "core/ast/scope.hpp"
10
11namespace by {
12
13 class visitor;
14
38 class _nout func: public baseFunc {
39 BY(ME(func, baseFunc), CLONE(func), VISIT())
40 typedef std::function<void(const std::string&, const node&)> onEval;
41 friend class coreInternal;
42
43 public:
44 explicit func(const modifier& mod, const funcType& type);
45 explicit func(const modifier& mod, const funcType& type, const blockExpr& newBlock);
46 explicit func(const modifier& mod, const funcType& type, const scope& subs, const blockExpr& newBlock);
47
48 public:
49 const ntype& getType() const override;
50
51 blockExpr& getBlock();
52 const blockExpr& getBlock() const;
53 void setBlock(const blockExpr& new1);
54 scope& subs() override;
55
56 using super::eval;
57 str eval(const args& a) override;
58
59 using super::inFrame;
60 void inFrame(const bicontainable* args) const override;
61
62 using super::outFrame;
63 void outFrame() const override;
64
65 const baseObj& getOrigin() const override;
66
72 const ends& getEnds() const BY_CONST_FUNC(getEnds())
73
74 void onCloneDeep(const clonable& from) override;
75
76 nbool isAbstract() const;
77
88 virtual str _interactFrame(node& meObj, scope& s, nidx exN);
89 str _run(nidx exN);
90
91 private:
92 scope* _evalArgs(const args& args);
93 str _postprocess(const str& ret, nidx exN);
94 void _runEnds();
95
96 public:
97 // special funcs:
98 inline static const std::string LAMBDA_NAME = "@lambda";
99 inline static const std::string CTOR_NAME = "@ctor";
100 inline static const std::string GETTER_NAME = "@get";
101 inline static const std::string SETTER_NAME = "@set";
102 inline static const std::array<std::string, 4> SPECIAL_FUNC_NAMES = {LAMBDA_NAME, CTOR_NAME, GETTER_NAME,
103 SETTER_NAME};
104
105 private:
106 tstr<obj> _org;
107 funcType _type;
108 scope _subs;
109 tstr<blockExpr> _blk;
110 ends _ends;
111 };
112} // namespace by
Function or object evaluation arguments.
Definition args.hpp:22
Base class for all function types.
Definition baseFunc.hpp:41
Base class for representing byeol objects.
Definition baseObj.hpp:73
Block expression.
Definition blockExpr.hpp:24
Definition coreInternal.hpp:39
Constructor function for byeol objects.
Definition ctor.hpp:12
Function definition in byeol language.
Definition func.hpp:38
ends & getEnds()
Gets the list of endExpr (defer-like statements) registered for this function.
script type for function objects in byeol language.
Definition funcType.hpp:11
Access modifier for type members.
Definition modifier.hpp:13
Base class for all AST nodes in the byeol language.
Definition node.hpp:195
represents native c++ type system for byeol language
Definition ntype.hpp:33
Definition tnarr.hpp:9
to Top