remove some comments
This commit is contained in:
parent
bfcefbb045
commit
4bc784ba80
53
ml.cpp
53
ml.cpp
|
|
@ -1,8 +1,7 @@
|
||||||
// Comment this define out to drop support for standard library functions.
|
// Comment this define out to drop support for standard library functions.
|
||||||
// This allows the program to run without a runtime.
|
// This allows the program to run without a runtime.
|
||||||
#define USE_STD
|
|
||||||
|
|
||||||
// Comment this define out to drop support for libm functions
|
|
||||||
#ifdef HAS_LIBM
|
#ifdef HAS_LIBM
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
#else
|
#else
|
||||||
|
|
@ -13,10 +12,6 @@
|
||||||
#include "ml.h"
|
#include "ml.h"
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
/// REQUIRED INCLUDES //////////////////////////////////////////////////////////
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
@ -30,7 +25,6 @@
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include <ctime>
|
#include <ctime>
|
||||||
#include <regex>
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
@ -39,9 +33,6 @@
|
||||||
#include "sslclient.h"
|
#include "sslclient.h"
|
||||||
#include "json11.h"
|
#include "json11.h"
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
/// ERROR MESSAGES /////////////////////////////////////////////////////////////
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
#define TOO_FEW_ARGS "too few arguments to function"
|
#define TOO_FEW_ARGS "too few arguments to function"
|
||||||
#define TOO_MANY_ARGS "too many arguments to function"
|
#define TOO_MANY_ARGS "too many arguments to function"
|
||||||
|
|
@ -59,9 +50,6 @@
|
||||||
#define INDEX_OUT_OF_RANGE "index out of range"
|
#define INDEX_OUT_OF_RANGE "index out of range"
|
||||||
#define MALFORMED_PROGRAM "malformed program"
|
#define MALFORMED_PROGRAM "malformed program"
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
/// TYPE NAMES /////////////////////////////////////////////////////////////////
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
#define STRING_TYPE "string"
|
#define STRING_TYPE "string"
|
||||||
#define INT_TYPE "int"
|
#define INT_TYPE "int"
|
||||||
|
|
@ -72,9 +60,6 @@
|
||||||
#define QUOTE_TYPE "quote"
|
#define QUOTE_TYPE "quote"
|
||||||
#define LIST_TYPE "list"
|
#define LIST_TYPE "list"
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
/// HELPER FUNCTIONS ///////////////////////////////////////////////////////////
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef USE_STD
|
#ifdef USE_STD
|
||||||
|
|
@ -118,16 +103,10 @@ bool is_symbol(char ch) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
/// LISP CONSTRUCTS ////////////////////////////////////////////////////////////
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
MlValue::MlValue() : type(UNIT) {}
|
MlValue::MlValue() : type(UNIT) {}
|
||||||
|
|
||||||
|
|
||||||
MlValue::MlValue(int i) : type(INT) { stack_data.i = i; }
|
MlValue::MlValue(int i) : type(INT) { stack_data.i = i; }
|
||||||
|
|
||||||
MlValue::MlValue(double f) : type(FLOAT) { stack_data.f = f; }
|
MlValue::MlValue(double f) : type(FLOAT) { stack_data.f = f; }
|
||||||
|
|
@ -187,9 +166,6 @@ MlValue::MlValue(const std::string &name, Builtin b) : type(BUILTIN) {
|
||||||
stack_data.b = b;
|
stack_data.b = b;
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
/// C++ INTEROP METHODS ////////////////////////////////////////////////////////
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
// Get all of the atoms used in a given MlValue
|
// Get all of the atoms used in a given MlValue
|
||||||
std::vector<std::string> MlValue::get_used_atoms() {
|
std::vector<std::string> MlValue::get_used_atoms() {
|
||||||
|
|
@ -296,9 +272,6 @@ MlValue MlValue::pop() {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
/// TYPECASTING METHODS ////////////////////////////////////////////////////////
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
// Cast this to an integer value
|
// Cast this to an integer value
|
||||||
MlValue MlValue::cast_to_int() const {
|
MlValue MlValue::cast_to_int() const {
|
||||||
|
|
@ -326,9 +299,6 @@ MlValue MlValue::cast_to_float() const {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
/// COMPARISON OPERATIONS //////////////////////////////////////////////////////
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
bool MlValue::operator==(MlValue other) const {
|
bool MlValue::operator==(MlValue other) const {
|
||||||
// If either of these values are floats, promote the
|
// If either of these values are floats, promote the
|
||||||
|
|
@ -368,9 +338,6 @@ bool MlValue::operator!=(const MlValue &other) const {
|
||||||
return !(*this == other);
|
return !(*this == other);
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
/// ORDERING OPERATIONS ////////////////////////////////////////////////////////
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
bool MlValue::operator>=(const MlValue &other) const {
|
bool MlValue::operator>=(const MlValue &other) const {
|
||||||
return !(*this < other);
|
return !(*this < other);
|
||||||
|
|
@ -405,9 +372,6 @@ bool MlValue::operator<(const MlValue &other) const {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
/// ARITHMETIC OPERATIONS //////////////////////////////////////////////////////
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
// This function adds two lisp values, and returns the lisp value result.
|
// This function adds two lisp values, and returns the lisp value result.
|
||||||
MlValue MlValue::operator+(const MlValue &other) const {
|
MlValue MlValue::operator+(const MlValue &other) const {
|
||||||
|
|
@ -564,12 +528,11 @@ MlValue MlValue::operator%(const MlValue &other) const {
|
||||||
// If we support libm, we can find the remainder of floating point values.
|
// If we support libm, we can find the remainder of floating point values.
|
||||||
#ifdef HAS_LIBM
|
#ifdef HAS_LIBM
|
||||||
case FLOAT:
|
case FLOAT:
|
||||||
return MlValue(fmod(stack_data.f, other.cast_to_float().stack_data.f));
|
return MlValue(fmod(stack_data.f, other.cast_to_float().stack_data.f));
|
||||||
case INT:
|
case INT:
|
||||||
if (other.type == FLOAT)
|
if (other.type == FLOAT)
|
||||||
return MlValue(fmod(cast_to_float().stack_data.f, other.stack_data.f));
|
return MlValue(fmod(cast_to_float().stack_data.f, other.stack_data.f));
|
||||||
else return MlValue(stack_data.i % other.stack_data.i);
|
else return MlValue(stack_data.i % other.stack_data.i);
|
||||||
|
|
||||||
#else
|
#else
|
||||||
case INT:
|
case INT:
|
||||||
// If we do not support libm, we have to throw errors for floating point values.
|
// If we do not support libm, we have to throw errors for floating point values.
|
||||||
|
|
@ -1224,7 +1187,7 @@ namespace builtin {
|
||||||
|
|
||||||
std::string cmd = args[0].as_string();
|
std::string cmd = args[0].as_string();
|
||||||
|
|
||||||
std::string cmd_output = "";
|
std::string cmd_output;
|
||||||
int stat;
|
int stat;
|
||||||
|
|
||||||
// TODO better parameter here
|
// TODO better parameter here
|
||||||
|
|
@ -1705,7 +1668,7 @@ bool MlEnvironment::has(std::string name) const {
|
||||||
if (itr != defs.end())
|
if (itr != defs.end())
|
||||||
// If it was found
|
// If it was found
|
||||||
return true;
|
return true;
|
||||||
else if (parent_scope != NULL)
|
else if (parent_scope != nullptr)
|
||||||
// If it was not found in the current environment,
|
// If it was not found in the current environment,
|
||||||
// try to find it in the parent environment
|
// try to find it in the parent environment
|
||||||
return parent_scope->has(name);
|
return parent_scope->has(name);
|
||||||
|
|
|
||||||
2
ml.h
2
ml.h
|
|
@ -4,6 +4,8 @@
|
||||||
// This allows the program to run without a runtime.
|
// This allows the program to run without a runtime.
|
||||||
#define USE_STD
|
#define USE_STD
|
||||||
|
|
||||||
|
// Comment this define out to drop support for libm functions
|
||||||
|
#define HAS_LIBM
|
||||||
|
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue