diff --git a/language/culebra.h b/language/culebra.h index ce9c712..26aede9 100644 --- a/language/culebra.h +++ b/language/culebra.h @@ -396,7 +396,7 @@ struct Environment std::map dictionary; }; -typedef std::function env, bool force_to_break)> Debugger; +typedef std::function Debugger; inline bool ObjectValue::has(const std::string& name) const { if (properties->find(name) == properties->end()) { @@ -538,7 +538,7 @@ struct Eval if (debugger_) { if (ast.original_tag == "STATEMENT"_) { auto force_to_break = ast.tag == "DEBUGGER"_; - debugger_(ast, env, force_to_break); + debugger_(ast, *env, force_to_break); } } diff --git a/language/main.cc b/language/main.cc index 51e4758..5d01438 100644 --- a/language/main.cc +++ b/language/main.cc @@ -28,14 +28,14 @@ bool read_file(const char* path, vector& buff) struct CommandLineDebugger { - void operator()(const Ast& ast, shared_ptr env, bool force_to_break) { + void operator()(const Ast& ast, Environment& env, bool force_to_break) { if (quit) { return; } - if ((command_ == "n" && env->level <= level_) || + if ((command_ == "n" && env.level <= level_) || (command_ == "s") || - (command_ == "o" && env->level < level_)) { + (command_ == "o" && env.level < level_)) { force_to_break = true; } @@ -72,7 +72,7 @@ struct CommandLineDebugger break; } } - level_ = env->level;; + level_ = env.level;; } } @@ -123,22 +123,22 @@ struct CommandLineDebugger } } - void print(const Ast& ast, shared_ptr env, const string& symbol) { + void print(const Ast& ast, Environment& env, const string& symbol) { if (symbol.empty()) { print_all(ast, env); - } else if (env->has(symbol)) { - cout << symbol << ": " << env->get(symbol).str() << endl; + } else if (env.has(symbol)) { + cout << symbol << ": " << env.get(symbol).str() << endl; } else { cout << "'" << symbol << "'" << "is not undefined." << endl; } } - void print_all(const Ast& ast, shared_ptr env) { + void print_all(const Ast& ast, Environment& env) { auto node = find_function_node(ast); set references; enum_identifiers(*node, references); for (const auto& symbol: references) { - const auto& val = env->get(symbol); + const auto& val = env.get(symbol); cout << symbol << ": " << val.str() << endl; } }