Remove unnecessary type comparison in equation
This commit is contained in:
@@ -8,10 +8,8 @@ SET (CMAKE_BUILD_TYPE gdb)
|
||||
SET (CMAKE_C_FLAGS_GDB " -Wall -ggdb")
|
||||
SET (CMAKE_CXX_FLAGS_GDB " -Wall -ggdb")
|
||||
|
||||
include_directories(dispatchkit langkit)
|
||||
include_directories(dispatchkit)
|
||||
|
||||
add_subdirectory(langkit bin)
|
||||
add_subdirectory(dispatchkit bin)
|
||||
add_subdirectory(chaiscript bin)
|
||||
add_subdirectory(chaioop bin)
|
||||
|
||||
|
@@ -10,7 +10,7 @@ SET (CMAKE_CXX_FLAGS_GDB " -Wall -ggdb")
|
||||
find_package(Boost 1.36.0 COMPONENTS regex unit_test_framework)
|
||||
if(Boost_FOUND)
|
||||
include_directories(${Boost_INCLUDE_DIRS})
|
||||
include_directories(../langkit ../dispatchkit)
|
||||
include_directories(../dispatchkit)
|
||||
|
||||
add_executable(chaiscript_test main.cpp)
|
||||
target_link_libraries(chaiscript_test ${Boost_LIBRARIES})
|
||||
@@ -25,3 +25,4 @@ if(Boost_FOUND)
|
||||
endif()
|
||||
|
||||
|
||||
|
@@ -78,7 +78,6 @@ namespace chaiscript
|
||||
for (i = node->children.size()-3; ((int)i) >= 0; i -= 2) {
|
||||
if (node->children[i+1]->text == "=") {
|
||||
dispatchkit::Boxed_Value lhs = eval_token(ss, node->children[i]);
|
||||
if (lhs.is_unknown() || dispatchkit::Bootstrap::type_match(lhs, retval)) {
|
||||
try {
|
||||
if (lhs.is_unknown())
|
||||
{
|
||||
@@ -98,10 +97,6 @@ namespace chaiscript
|
||||
throw EvalError("Can not clone right hand side of equation", node->children[i+1]);
|
||||
}
|
||||
}
|
||||
else {
|
||||
throw EvalError("Mismatched types in equation", node->children[i+1]);
|
||||
}
|
||||
}
|
||||
else if (node->children[i+1]->text == ":=") {
|
||||
dispatchkit::Boxed_Value lhs = eval_token(ss, node->children[i]);
|
||||
if (lhs.is_unknown() || dispatchkit::Bootstrap::type_match(lhs, retval)) {
|
||||
|
@@ -20,6 +20,8 @@ def puts(x) { \n\
|
||||
def print(x) { \n\
|
||||
println_string(x.to_string()) \n\
|
||||
}; \n\
|
||||
def max(a, b) { if (a>b) { a } else { b } } \n\
|
||||
def min(a, b) { if (a<b) { a } else { b } } \n\
|
||||
def for_each(container, func) : call_exists(range, container) { \n\
|
||||
var range = range(container); \n\
|
||||
while (!range.empty()) { \n\
|
||||
@@ -45,8 +47,8 @@ def foldl(container, func, initial) : call_exists(range, container){ \n\
|
||||
} \n\
|
||||
retval \n\
|
||||
} \n\
|
||||
def sum(x) { foldl(x, `+`, 0) } \n\
|
||||
def product(x) { foldl(x, `*`, 1) } \n\
|
||||
def sum(container) { foldl(container, `+`, 0) } \n\
|
||||
def product(container) { foldl(container, `*`, 1) } \n\
|
||||
def take(container, num) : call_exists(range, container) { \n\
|
||||
var r = range(container); \n\
|
||||
var i = num; \n\
|
||||
@@ -105,8 +107,6 @@ def reduce(container, func) : container.size() >= 2 && call_exists(range, contai
|
||||
} \n\
|
||||
retval \n\
|
||||
} \n\
|
||||
def max(a, b) { if (a>b) { a } else { b } } \n\
|
||||
def min(a, b) { if (a<b) { a } else { b } } \n\
|
||||
def join(container, delim) { \n\
|
||||
var retval = \"\" \n\
|
||||
var range = range(container) \n\
|
||||
@@ -121,9 +121,9 @@ def join(container, delim) { \n\
|
||||
} \n\
|
||||
retval \n\
|
||||
} \n\
|
||||
def filter(a, f) : call_exists(range, a) { \n\
|
||||
def filter(container, f) : call_exists(range, container) { \n\
|
||||
var retval = Vector(); \n\
|
||||
var r = range(a); \n\
|
||||
var r = range(container); \n\
|
||||
while (!r.empty()) { \n\
|
||||
if (f(r.front())) { \n\
|
||||
retval.push_back(r.front()); \n\
|
||||
|
Reference in New Issue
Block a user