exprMaker.hpp
Go to the documentation of this file.
1
2#pragma once
3
4#include "core/ast/expr.hpp"
5
6namespace by {
7
8 class func;
9 class defBlock;
10 class assignExpr;
11 class defVarExpr;
12
17 class _nout exprMaker: public typeProvidable, public clonable {
18 BY(CLASS(exprMaker))
19
20 public:
21 exprMaker();
22 exprMaker(const srcFile& s, ncnt row, ncnt col);
23
24 public:
25 me& addRow();
26 me& addRow(ncnt step);
27 me& addCol();
28 me& addCol(ncnt step);
29
30 me& setRow(ncnt row);
31 me& setCol(ncnt col);
32 me& setSrcFile(const srcFile& s);
33
34 void rel();
35
36 const point& getPos() const;
37 const srcFile& getSrcFile() const;
38
39 tstr<src> makeSrc(const std::string& name) const;
40
42 template <typename T, typename... Args> T* birth(const std::string& name, const Args&... args) const {
43 T* ret = new T(args...);
44 if(_file) ret->_setSrc(*makeSrc(name));
45 return ret;
46 }
47
48 template <typename T, typename... Args> T* make(const Args&... args) const {
49 T* ret = new T(args...);
50 if(_file) ret->_setSrc(*makeSrc(""));
51 return ret;
52 }
53
54 func* makeExpandFunc(const defBlock& blk) const;
55 assignExpr* makeAssignExprFrom(const defVarExpr& e) const;
56 func* makeCommonFunc(const defBlock& blk) const;
57
58 private:
59 func* _makeFunc(const std::string& name, const narr& stmts) const;
60
61 private:
62 tstr<srcFile> _file;
63 point _pos;
64 };
65} // namespace by
Function call arguments container.
Definition: args.hpp:13
Interface for objects that can be cloned.
Definition: clonable.hpp:12
Factory for creating expressions with source location information.
Definition: exprMaker.hpp:17
T * birth(const std::string &name, const Args &... args) const
Definition: exprMaker.hpp:42
Source file representation.
Definition: srcFile.hpp:13
Strong reference smart pointer with strict type checking.
Definition: tstr.hpp:13
Interface for objects that can provide their type information.
Definition: typeProvidable.hpp:12
Source code position tracking structure.
Definition: point.hpp:11