callstack added
This commit is contained in:
23
ml.cpp
23
ml.cpp
@@ -51,10 +51,10 @@
|
||||
|
||||
|
||||
// Convert an object to a string using a string stream conveniently
|
||||
#if __APPLE_
|
||||
#define to_string(x) static_cast<std::ostringstream>((std::ostringstream() << std::dec << x )).str()
|
||||
#elif __linux
|
||||
#if __linux
|
||||
#define to_string(x) static_cast<std::ostringstream&>((std::ostringstream() << std::dec << x )).str()
|
||||
#else
|
||||
#define to_string(x) static_cast<std::ostringstream>((std::ostringstream() << std::dec << x )).str()
|
||||
#endif
|
||||
|
||||
// Is this character a valid lisp symbol character
|
||||
@@ -624,7 +624,8 @@ MlError::~MlError() {
|
||||
|
||||
std::string MlError::description() {
|
||||
// return "error: the expression `" + cause->debug() + "` failed in scope " + to_string(env) + " with message \"" + msg + "\"";
|
||||
return "error: the expression `" + cause->debug() + "` with message \"" + msg + "\"";
|
||||
return MlPerfMon::instance().callstack() +
|
||||
"error: the expression `" + cause->debug() + "` with message \"" + msg + "\"";
|
||||
}
|
||||
|
||||
void MlEnvironment::combine(MlEnvironment const &other) {
|
||||
@@ -693,6 +694,7 @@ MlValue MlValue::apply(std::vector<MlValue> args, MlEnvironment &env) {
|
||||
MlValue MlValue::eval(MlEnvironment &env) {
|
||||
std::vector<MlValue> args;
|
||||
MlValue function;
|
||||
MlValue res;
|
||||
MlEnvironment e;
|
||||
switch (type) {
|
||||
case QUOTE:
|
||||
@@ -715,11 +717,10 @@ MlValue MlValue::eval(MlEnvironment &env) {
|
||||
args[i] = args[i].eval(env);
|
||||
|
||||
MlPerfMon::instance().add_method_call(function.type == LAMBDA ? "lambda" : function.str);
|
||||
res = function.apply( args, env );
|
||||
MlPerfMon::instance().end_method_call();
|
||||
|
||||
return function.apply(
|
||||
args,
|
||||
env
|
||||
);
|
||||
return res;
|
||||
|
||||
default:
|
||||
return *this;
|
||||
@@ -1015,7 +1016,7 @@ namespace builtin {
|
||||
eval_args(args, env);
|
||||
|
||||
std::exit(args.size() < 1 ? 0 : args[0].cast_to_int().as_int());
|
||||
return MlValue();
|
||||
return MlValue(); // will not be called :-)
|
||||
}
|
||||
|
||||
// Print several values and return the last one
|
||||
@@ -1557,7 +1558,7 @@ namespace builtin {
|
||||
if (args.size() != 2)
|
||||
throw MlError(MlValue("string-split", string_split), env, args.size() > 2 ? TOO_MANY_ARGS : TOO_FEW_ARGS);
|
||||
|
||||
// TODO more efficient
|
||||
// TODO do it more efficient
|
||||
std::vector<std::string> elements = regexp_strsplit(args[0].as_string(), args[1].as_string());
|
||||
std::vector<MlValue> result{};
|
||||
|
||||
@@ -1970,7 +1971,7 @@ int main(int argc, char *argv[]) {
|
||||
} catch (MlError &e) {
|
||||
std::cerr << e.description() << std::endl;
|
||||
} catch (std::runtime_error &e) {
|
||||
std::cerr << e.what() << std::endl;
|
||||
std::cerr << MlPerfMon::instance().callstack() << e.what() << std::endl;
|
||||
}
|
||||
|
||||
return 1;
|
||||
|
||||
Reference in New Issue
Block a user