MCPcopy Create free account
hub / github.com/covscript/covscript / dispatcher

Function dispatcher

include/covscript/core/variable.hpp:448–508  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

446 ::new (&val->m_store.buffer) T(std::forward<ArgsT>(args)...);
447 }
448 static inline operators::result dispatcher(operators::type op, const basic_var *lhs, void *rhs)
449 {
450 using handler_t = operators::result (*)(void *, void *);
451 using op_handler = operators::handler<T>;
452 static constexpr handler_t op_handlers[] = {
453 op_copy,
454 op_move,
455 op_swap,
456 op_destroy,
457 op_handler::get,
458 op_handler::type_id,
459 op_handler::type_name,
460 op_handler::to_integer,
461 op_handler::to_string,
462 op_handler::hash,
463 op_handler::detach,
464 op_handler::ext_ns,
465 op_handler::add,
466 op_handler::sub,
467 op_handler::mul,
468 op_handler::div,
469 op_handler::mod,
470 op_handler::pow,
471 op_handler::minus,
472 op_handler::escape,
473 op_handler::selfinc,
474 op_handler::selfdec,
475 op_handler::compare,
476 op_handler::abocmp,
477 op_handler::undcmp,
478 op_handler::aeqcmp,
479 op_handler::ueqcmp,
480 op_handler::index,
481 op_handler::cindex,
482 op_handler::index_ref,
483 op_handler::access,
484 op_handler::caccess,
485 op_handler::access_ref,
486 op_handler::prep_call,
487 op_handler::fcall,
488 };
489#ifdef CS_ENABLE_PROFILING
490 ++op_perf[static_cast<unsigned>(op)];
491#endif
492#ifdef CS_AGGRESSIVE_OPTIMIZE
493 void *ptr = (void *) &lhs->m_store.buffer;
494 // Optimize hotspot operators
495 if (op == operators::type::get)
496 return operators::result::from_ptr(ptr);
497 else if (op == operators::type::destroy)
498 return op_destroy(ptr, nullptr);
499 else if (op == operators::type::prep_call)
500 return op_handler::prep_call(ptr, rhs);
501 else if (op == operators::type::fcall)
502 return op_handler::fcall(ptr, rhs);
503 else
504 return op_handlers[static_cast<unsigned>(op)](ptr, rhs);
505#else

Callers

nothing calls this directly

Calls 3

from_ptrFunction · 0.85
prep_callFunction · 0.85
fcallFunction · 0.85

Tested by

no test coverage detected