Skip to content
This repository has been archived by the owner on Sep 27, 2023. It is now read-only.

Commit

Permalink
bug fix: first arg of repeat_radial can now be parametric
Browse files Browse the repository at this point in the history
  • Loading branch information
doug-moen committed Dec 11, 2021
1 parent e0fd615 commit 14503e3
Show file tree
Hide file tree
Showing 7 changed files with 92 additions and 63 deletions.
4 changes: 2 additions & 2 deletions curv/repl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -68,14 +68,14 @@ bool was_interrupted = false;
#endif

/// The meaning of a call to `help`, such as `help "foo"`.
struct Help_Action : public Operation
struct Help_Action : public Just_Action
{
Shared<Meaning> arg_;
Help_Action(
Shared<const Phrase> syntax,
Shared<Meaning> arg)
:
Operation(move(syntax)),
Just_Action(move(syntax)),
arg_(move(arg))
{}
virtual void exec(Frame& fm, Executor&) const override
Expand Down
24 changes: 12 additions & 12 deletions libcurv/builtin.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1119,14 +1119,14 @@ struct File_Metafunction : public Metafunction
};

/// The meaning of a call to `print`, such as `print "foo"`.
struct Print_Action : public Operation
struct Print_Action : public Just_Action
{
Shared<Operation> arg_;
Print_Action(
Shared<const Phrase> syntax,
Shared<Operation> arg)
:
Operation(move(syntax)),
Just_Action(move(syntax)),
arg_(move(arg))
{}
virtual void exec(Frame& fm, Executor&) const override
Expand All @@ -1153,14 +1153,14 @@ struct Print_Metafunction : public Metafunction
}
};

struct Warning_Action : public Operation
struct Warning_Action : public Just_Action
{
Shared<Operation> arg_;
Warning_Action(
Shared<const Phrase> syntax,
Shared<Operation> arg)
:
Operation(move(syntax)),
Just_Action(move(syntax)),
arg_(move(arg))
{}
virtual void exec(Frame& fm, Executor&) const override
Expand Down Expand Up @@ -1198,14 +1198,14 @@ struct Error_Function : public Function
}
};
/// The meaning of a call to `error`, such as `error("foo")`.
struct Error_Operation : public Operation
struct Error_Operation : public Just_Action
{
Shared<Operation> arg_;
Error_Operation(
Shared<const Phrase> syntax,
Shared<Operation> arg)
:
Operation(move(syntax)),
Just_Action(move(syntax)),
arg_(move(arg))
{}
[[noreturn]] void run(Frame& fm) const
Expand Down Expand Up @@ -1247,14 +1247,14 @@ struct Error_Metafunction : public Metafunction

// exec(expr) -- a debug action that evaluates expr, then discards the result.
// It is used to call functions or source files for their side effects.
struct Exec_Action : public Operation
struct Exec_Action : public Just_Action
{
Shared<Operation> arg_;
Exec_Action(
Shared<const Phrase> syntax,
Shared<Operation> arg)
:
Operation(move(syntax)),
Just_Action(move(syntax)),
arg_(move(arg))
{}
virtual void exec(Frame& fm, Executor&) const override
Expand All @@ -1278,14 +1278,14 @@ struct Exec_Metafunction : public Metafunction
}
};

struct Assert_Action : public Operation
struct Assert_Action : public Just_Action
{
Shared<Operation> arg_;
Assert_Action(
Shared<const Phrase> syntax,
Shared<Operation> arg)
:
Operation(move(syntax)),
Just_Action(move(syntax)),
arg_(move(arg))
{}
virtual void exec(Frame& fm, Executor&) const override
Expand Down Expand Up @@ -1314,7 +1314,7 @@ struct Assert_Metafunction : public Metafunction
}
};

struct Assert_Error_Action : public Operation
struct Assert_Error_Action : public Just_Action
{
Shared<Operation> expected_message_;
Shared<const String> actual_message_;
Expand All @@ -1326,7 +1326,7 @@ struct Assert_Error_Action : public Operation
Shared<const String> actual_message,
Shared<Operation> expr)
:
Operation(move(syntax)),
Just_Action(move(syntax)),
expected_message_(move(expected_message)),
actual_message_(move(actual_message)),
expr_(move(expr))
Expand Down
14 changes: 9 additions & 5 deletions libcurv/evaluator.cc
Original file line number Diff line number Diff line change
Expand Up @@ -275,11 +275,15 @@ If_Else_Op::tail_eval(std::unique_ptr<Frame>& fm) const
void
If_Else_Op::exec(Frame& fm, Executor& ex) const
{
bool a = arg1_->eval(fm).to_bool(At_Phrase(*arg1_->syntax_, fm));
if (a)
arg2_->exec(fm, ex);
else
arg3_->exec(fm, ex);
if (is_expr_) {
ex.push_value(eval(fm), At_Phrase(*syntax_,fm));
} else {
bool a = arg1_->eval(fm).to_bool(At_Phrase(*arg1_->syntax_, fm));
if (a)
arg2_->exec(fm, ex);
else
arg3_->exec(fm, ex);
}
}

Value
Expand Down
4 changes: 2 additions & 2 deletions libcurv/io/builtin.cc
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,14 @@ run_cpp_test(const Context& cx, Source_State& ss, Shared<const Function> func)
"assertion failed in C++; see ",cpp.path_));
}
}
struct SC_Test_Action : public Operation
struct SC_Test_Action : public Just_Action
{
Shared<Operation> arg_;
SC_Test_Action(
Shared<const Phrase> syntax,
Shared<Operation> arg)
:
Operation(move(syntax)),
Just_Action(move(syntax)),
arg_(move(arg))
{}
virtual void exec(Frame& f, Executor&) const override
Expand Down
Loading

0 comments on commit 14503e3

Please sign in to comment.