| 543 | } // anonymous namespace |
| 544 | |
| 545 | LangModule::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, |
nothing calls this directly
no test coverage detected