From 166e3c0d407a967d25d793b6a9db56ffd7a03727 Mon Sep 17 00:00:00 2001 From: "Kartik K. Agaram" Date: Thu, 1 Oct 2015 17:30:14 -0700 Subject: 2232 --- 064random.cc | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) (limited to '064random.cc') diff --git a/064random.cc b/064random.cc index 07667cc2..de304714 100644 --- a/064random.cc +++ b/064random.cc @@ -2,6 +2,10 @@ RANDOM, :(before "End Primitive Recipe Numbers") Recipe_ordinal["random"] = RANDOM; +:(before "End Primitive Recipe Checks") +case RANDOM: { + break; +} :(before "End Primitive Recipe Implementations") case RANDOM: { // todo: limited range of numbers, might be imperfectly random @@ -15,6 +19,10 @@ case RANDOM: { MAKE_RANDOM_NONDETERMINISTIC, :(before "End Primitive Recipe Numbers") Recipe_ordinal["make-random-nondeterministic"] = MAKE_RANDOM_NONDETERMINISTIC; +:(before "End Primitive Recipe Checks") +case MAKE_RANDOM_NONDETERMINISTIC: { + break; +} :(before "End Primitive Recipe Implementations") case MAKE_RANDOM_NONDETERMINISTIC: { srand(time(NULL)); @@ -25,16 +33,20 @@ case MAKE_RANDOM_NONDETERMINISTIC: { ROUND, :(before "End Primitive Recipe Numbers") Recipe_ordinal["round"] = ROUND; -:(before "End Primitive Recipe Implementations") +:(before "End Primitive Recipe Checks") case ROUND: { - if (SIZE(ingredients) != 1) { - raise << maybe(current_recipe_name()) << "'round' requires exactly one ingredient, but got " << current_instruction().to_string() << '\n' << end(); + if (SIZE(inst.ingredients) != 1) { + raise << maybe(Recipe[r].name) << "'round' requires exactly one ingredient, but got " << inst.to_string() << '\n' << end(); break; } - if (!scalar(ingredients.at(0))) { - raise << maybe(current_recipe_name()) << "first ingredient of 'round' should be a number, but got " << current_instruction().ingredients.at(0).original_string << '\n' << end(); + if (!is_mu_scalar(inst.ingredients.at(0))) { + raise << maybe(Recipe[r].name) << "first ingredient of 'round' should be a number, but got " << inst.ingredients.at(0).original_string << '\n' << end(); break; } + break; +} +:(before "End Primitive Recipe Implementations") +case ROUND: { products.resize(1); products.at(0).push_back(rint(ingredients.at(0).at(0))); break; -- cgit 1.4.1-2-gfad0