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
20 class _nout func: public baseFunc {
21 BY(ME(func, baseFunc), CLONE(func), VISIT())
22 friend class verifier;
23 friend class exprMaker;
24 friend class parser;
25 typedef std::function<void(const std::string&, const node&)> onEval;
26
27 public:
28 explicit func(const modifier& mod, const funcMgdType& type);
29 explicit func(const modifier& mod, const funcMgdType& type, const blockExpr& newBlock);
30 explicit func(const modifier& mod, const funcMgdType& type, const scope& subs, const blockExpr& newBlock);
31
32 public:
33 const ntype& getType() const override;
34
35 blockExpr& getBlock();
36 const blockExpr& getBlock() const;
37 void setBlock(const blockExpr& new1);
38 scope& subs() override;
39
40 using super::run;
41 str run(const args& a) override;
42
43 using super::inFrame;
44 void inFrame(const bicontainable* args) const override;
45
46 using super::outFrame;
47 void outFrame() const override;
48
49 const baseObj& getOrigin() const override;
50
51 ends& getEnds();
52 const ends& getEnds() const BY_CONST_FUNC(getEnds())
53
54 void onCloneDeep(const clonable& from) override;
55
56 nbool isAbstract() const;
57
58 protected:
59 virtual str _interactFrame(node& meObj, scope& s, nidx exN);
60 str _run(nidx exN);
61
62 private:
63 scope* _evalArgs(const args& args);
64 str _postprocess(const str& ret, nidx exN);
65 void _runEnds();
66 void _setOrigin(const baseObj& org);
67
68 public:
69 inline static const std::string LAMBDA_NAME = "@lambda";
70
71 private:
72 tstr<obj> _org;
73 funcMgdType _type;
74 scope _subs;
75 tstr<blockExpr> _blk;
76 ends _ends;
77 };
78} // namespace by
Function call arguments container.
Definition: args.hpp:13
Base class for all function types.
Definition: baseFunc.hpp:18
Base class for all objects in byeol language.
Definition: baseObj.hpp:24
Block expression containing multiple statements.
Definition: blockExpr.hpp:15
Interface for objects that can be cloned.
Definition: clonable.hpp:12
Factory for creating expressions with source location information.
Definition: exprMaker.hpp:17
Function definition in byeol language.
Definition: func.hpp:20
Managed type for function objects.
Definition: funcMgdType.hpp:10
Access modifier for class members and func.
Definition: modifier.hpp:12
Base class for all AST nodes in byeol language.
Definition: node.hpp:30
Native type system for byeol language.
Definition: ntype.hpp:19
Parser for byeol language source code.
Definition: parser.hpp:43
Template bidirectional container interface.
Definition: tbicontainable.hpp:17
Base class for runtime type information in byeol language.
Definition: type.hpp:12
AST verifier for semantic analysis.
Definition: verifier.hpp:20