Skip to content

Commit

Permalink
removed Macro magic
Browse files Browse the repository at this point in the history
  • Loading branch information
leissa committed Oct 20, 2024
1 parent 859ab6f commit 808946b
Show file tree
Hide file tree
Showing 9 changed files with 289 additions and 108 deletions.
5 changes: 1 addition & 4 deletions docs/Doxyfile.in
Original file line number Diff line number Diff line change
Expand Up @@ -2538,10 +2538,7 @@ EXPAND_AS_DEFINED = CODE \
MIM_CONV \
MIM_TRAIT \
MIM_ACC \
MIM_PE \
MIM_SETTERS \
MIM_SETTERS_ \
MIM_DEF_MIXIN
MIM_PE

# If the SKIP_FUNCTION_MACROS tag is set to YES then Doxygen's preprocessor will
# remove all references to function-like macros that are alone on a line, have
Expand Down
11 changes: 9 additions & 2 deletions include/mim/axiom.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,13 @@

namespace mim {

class Axiom : public Def {
class Axiom : public Def, public Setters<Axiom> {
private:
Axiom(NormalizeFn, u8 curry, u8 trip, const Def* type, plugin_t, tag_t, sub_t);

public:
using Setters<Axiom>::set;

/// @name Normalization
/// @anchor normalization
/// For a curried App of an Axiom, you only want to trigger normalization at specific spots.
Expand Down Expand Up @@ -58,7 +60,12 @@ class Axiom : public Def {
using type = App;
};

MIM_DEF_MIXIN(Axiom)
static constexpr auto Node = Node::Axiom;

private:
Ref rebuild_(World&, Ref, Defs) const override;

friend class World;
};

// clang-format off
Expand Down
12 changes: 9 additions & 3 deletions include/mim/check.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,14 @@ namespace mim {
/// This node is a hole in the IR that is inferred by its context later on.
/// It is modelled as a *mut*able Def.
/// If inference was successful, it's Infer::op will be set to the inferred Def.
class Infer : public Def {
class Infer : public Def, public Setters<Infer> {
private:
Infer(const Def* type)
: Def(Node, type, 1, 0) {}

public:
using Setters<Infer>::set;

/// @name op
///@{
const Def* op() const { return Def::op(0); }
Expand All @@ -35,12 +37,16 @@ class Infer : public Def {

Infer* stub(Ref type) { return stub_(world(), type)->set(dbg()); }

static constexpr auto Node = Node::Infer;

private:
Infer* stub_(World&, Ref) override;
flags_t rank() const { return flags(); }
flags_t& rank() { return flags_; }

MIM_DEF_MIXIN(Infer)
Ref rebuild_(World&, Ref, Defs) const override;
Infer* stub_(World&, Ref) override;

friend class World;
friend class Check;
};

Expand Down
Loading

0 comments on commit 808946b

Please sign in to comment.