Skip to content

Commit

Permalink
Merge pull request #280 from AnyDSL/refactor/mixin
Browse files Browse the repository at this point in the history
Refactor/mixin
  • Loading branch information
leissa authored Oct 21, 2024
2 parents 859ab6f + 678c714 commit 10dce8e
Show file tree
Hide file tree
Showing 16 changed files with 331 additions and 147 deletions.
6 changes: 1 addition & 5 deletions docs/Doxyfile.in
Original file line number Diff line number Diff line change
Expand Up @@ -2518,7 +2518,6 @@ EXPAND_AS_DEFINED = CODE \
CODE2 \
CODE3 \
CODE4 \
MIM_ENUM_OPERATORS \
MIM_1_8_16_32_64 \
MIM_8_16_32_64 \
MIM_16_32_64 \
Expand All @@ -2538,10 +2537,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
2 changes: 1 addition & 1 deletion external/fe
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 10dce8e

Please sign in to comment.