MCPcopy Create free account
hub / github.com/chigraph/chigraph / LangModule

Method LangModule

libchigraph/src/LangModule.cpp:545–857  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

543} // anonymous namespace
544
545LangModule::LangModule(Context& ctx) : ChiModule(ctx, "lang") {
546 using namespace std::string_literals;
547
548 // populate them
549 nodes = {
550 {"if"s,
551 [this](const nlohmann::json&, Result&) { return std::make_unique<IfNodeType>(*this); }},
552 {"i32+i32"s,
553 [this](const nlohmann::json&, Result&) {
554 return std::make_unique<BinaryOperationNodeType>(
555 *this, LangModule::typeFromName("i32"), BinOp::Add);
556 }},
557 {"i32-i32"s,
558 [this](const nlohmann::json&, Result&) {
559 return std::make_unique<BinaryOperationNodeType>(
560 *this, LangModule::typeFromName("i32"), BinOp::Subtract);
561 }},
562 {"i32*i32"s,
563 [this](const nlohmann::json&, Result&) {
564 return std::make_unique<BinaryOperationNodeType>(
565 *this, LangModule::typeFromName("i32"), BinOp::Multiply);
566 }},
567 {"i32/i32"s,
568 [this](const nlohmann::json&, Result&) {
569 return std::make_unique<BinaryOperationNodeType>(
570 *this, LangModule::typeFromName("i32"), BinOp::Divide);
571 }},
572 {"float+float"s,
573 [this](const nlohmann::json&, Result&) {
574 return std::make_unique<BinaryOperationNodeType>(
575 *this, LangModule::typeFromName("float"), BinOp::Add);
576 }},
577 {"float-float"s,
578 [this](const nlohmann::json&, Result&) {
579 return std::make_unique<BinaryOperationNodeType>(
580 *this, LangModule::typeFromName("float"), BinOp::Subtract);
581 }},
582 {"float*float"s,
583 [this](const nlohmann::json&, Result&) {
584 return std::make_unique<BinaryOperationNodeType>(
585 *this, LangModule::typeFromName("float"), BinOp::Multiply);
586 }},
587 {"float/float"s,
588 [this](const nlohmann::json&, Result&) {
589 return std::make_unique<BinaryOperationNodeType>(
590 *this, LangModule::typeFromName("float"), BinOp::Divide);
591 }},
592 {"i32<i32"s,
593 [this](const nlohmann::json&, Result&) {
594 return std::make_unique<CompareNodeType>(*this, LangModule::typeFromName("i32"),
595 CmpOp::Lt);
596 }},
597 {"i32>i32"s,
598 [this](const nlohmann::json&, Result&) {
599 return std::make_unique<CompareNodeType>(*this, LangModule::typeFromName("i32"),
600 CmpOp::Gt);
601 }},
602 {"i32<=i32"s,

Callers

nothing calls this directly

Calls 12

getFunction · 0.85
endMethod · 0.80
is_arrayMethod · 0.80
beginMethod · 0.80
typeFromModuleMethod · 0.80
addEntryMethod · 0.80
is_number_integerMethod · 0.80
is_numberMethod · 0.80
is_booleanMethod · 0.80
is_stringMethod · 0.80
keyMethod · 0.45
valueMethod · 0.45

Tested by

no test coverage detected