| 299 | } // namespace fiber |
| 300 | |
| 301 | class function final { |
| 302 | context_t mContext; |
| 303 | #ifdef CS_DEBUGGER |
| 304 | // Debug Information |
| 305 | mutable bool mMatch = false; |
| 306 | std::string mDecl; |
| 307 | statement_base *mStmt; |
| 308 | #endif |
| 309 | bool mIsMemFn = false; |
| 310 | bool mIsVargs = false; |
| 311 | bool mIsLambda = false; |
| 312 | std::vector<std::string> mArgs; |
| 313 | std::deque<statement_base *> mBody; |
| 314 | |
| 315 | static var call_rr(const function *, vector &); |
| 316 | |
| 317 | static var call_vv(const function *, vector &); |
| 318 | |
| 319 | static var call_rl(const function *, vector &); |
| 320 | |
| 321 | static var call_el(const function *, vector &); |
| 322 | |
| 323 | var (*call_ptr)(const function *, vector &) = nullptr; |
| 324 | |
| 325 | inline void init_call_ptr() noexcept |
| 326 | { |
| 327 | if (!mIsVargs) { |
| 328 | if (mIsLambda) |
| 329 | call_ptr = mArgs.empty() ? &call_el : &call_rl; |
| 330 | else |
| 331 | call_ptr = &call_rr; |
| 332 | } |
| 333 | else |
| 334 | call_ptr = &call_vv; |
| 335 | } |
| 336 | |
| 337 | public: |
| 338 | function() = delete; |
| 339 | |
| 340 | function(const function &) = default; |
| 341 | |
| 342 | #ifdef CS_DEBUGGER |
| 343 | function(context_t c, std::string decl, statement_base *stmt, std::vector<std::string> args, std::deque<statement_base *> body, bool is_vargs = false, bool is_lambda = false) : mContext(std::move(c)), mDecl(std::move(decl)), mStmt(stmt), mIsVargs(is_vargs), mIsLambda(is_lambda), mArgs(std::move(args)), mBody(std::move(body)) |
| 344 | { |
| 345 | init_call_ptr(); |
| 346 | } |
| 347 | #else |
| 348 | |
| 349 | function(context_t c, std::vector<std::string> args, std::deque<statement_base *> body, bool is_vargs = false, bool is_lambda = false) : mContext(std::move(c)), mIsVargs(is_vargs), mIsLambda(is_lambda), mArgs(std::move(args)), mBody(std::move(body)) |
| 350 | { |
| 351 | init_call_ptr(); |
| 352 | } |
| 353 | |
| 354 | #endif |
| 355 | |
| 356 | ~function() = default; |
| 357 | |
| 358 | var call(vector &args) const |
nothing calls this directly
no outgoing calls
no test coverage detected