a bit better call stack
This commit is contained in:
48
ml.h
48
ml.h
@@ -1,6 +1,5 @@
|
||||
#pragma once
|
||||
|
||||
|
||||
#include <map>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
@@ -94,6 +93,8 @@ private:
|
||||
// and the environment to run the function in.
|
||||
typedef MlValue (*Builtin)(std::vector<MlValue>, MlEnvironment &);
|
||||
|
||||
// friend class
|
||||
class MlPerfMon;
|
||||
|
||||
class MlValue {
|
||||
public:
|
||||
@@ -140,29 +141,15 @@ public:
|
||||
MlValue eval(MlEnvironment &env);
|
||||
|
||||
bool is_builtin() const;
|
||||
|
||||
bool is_number() const;
|
||||
|
||||
bool is_string() const;
|
||||
|
||||
bool is_list() const;
|
||||
|
||||
// Get the boolean value of this value.
|
||||
bool as_bool() const;
|
||||
|
||||
// Get this item's integer value
|
||||
long as_int() const;
|
||||
|
||||
// Get this item's floating point value
|
||||
double as_float() const;
|
||||
|
||||
// Get this item's string value
|
||||
std::string as_string() const;
|
||||
|
||||
// Get this item's atom value
|
||||
std::string as_atom() const;
|
||||
|
||||
// Get this item's list value
|
||||
std::vector<MlValue> as_list() const;
|
||||
|
||||
// Push an item to the end of this list
|
||||
@@ -172,13 +159,8 @@ public:
|
||||
MlValue pop();
|
||||
|
||||
|
||||
// Cast this to an integer value
|
||||
MlValue cast_to_int() const;
|
||||
|
||||
// Cast this to a floating point value
|
||||
MlValue cast_to_float() const;
|
||||
|
||||
// Cast this to a string
|
||||
MlValue cast_to_string() const;
|
||||
|
||||
|
||||
@@ -207,24 +189,26 @@ public:
|
||||
|
||||
private:
|
||||
enum {
|
||||
QUOTE,
|
||||
ATOM,
|
||||
INT,
|
||||
FLOAT,
|
||||
LIST,
|
||||
STRING,
|
||||
LAMBDA,
|
||||
BUILTIN,
|
||||
NIL
|
||||
QUOTE,
|
||||
ATOM,
|
||||
INT,
|
||||
FLOAT,
|
||||
LIST,
|
||||
STRING,
|
||||
LAMBDA,
|
||||
BUILTIN,
|
||||
NIL
|
||||
} type;
|
||||
|
||||
union {
|
||||
long i;
|
||||
double f;
|
||||
Builtin b;
|
||||
long i;
|
||||
double f;
|
||||
Builtin b;
|
||||
} stack_data;
|
||||
|
||||
std::string str;
|
||||
std::vector<MlValue> list;
|
||||
MlEnvironment lambda_scope;
|
||||
|
||||
friend class MlPerfMon;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user