Compare commits
9 Commits
Author | SHA1 | Date | |
---|---|---|---|
![]() |
7339ff2c2f | ||
![]() |
665125665a | ||
![]() |
d1c7645a4e | ||
![]() |
58faea1cf2 | ||
![]() |
8b7fe33bf1 | ||
![]() |
21495ebb40 | ||
![]() |
bec1b91b7b | ||
![]() |
4b81a24a0a | ||
![]() |
cefb4d3c78 |
@@ -103,7 +103,7 @@ set(CPACK_PACKAGE_DESCRIPTION_FILE "${CMAKE_CURRENT_SOURCE_DIR}/description.txt"
|
||||
|
||||
set(CPACK_PACKAGE_VERSION_MAJOR 5)
|
||||
set(CPACK_PACKAGE_VERSION_MINOR 8)
|
||||
set(CPACK_PACKAGE_VERSION_PATCH 2)
|
||||
set(CPACK_PACKAGE_VERSION_PATCH 5)
|
||||
|
||||
set(CPACK_PACKAGE_EXECUTABLES "chai;ChaiScript Eval")
|
||||
set(CPACK_PACKAGE_VENDOR "ChaiScript.com")
|
||||
|
@@ -99,7 +99,7 @@
|
||||
namespace chaiscript {
|
||||
static const int version_major = 5;
|
||||
static const int version_minor = 8;
|
||||
static const int version_patch = 2;
|
||||
static const int version_patch = 5;
|
||||
|
||||
static const char *compiler_version = CHAISCRIPT_COMPILER_VERSION;
|
||||
static const char *compiler_name = CHAISCRIPT_COMPILER_NAME;
|
||||
|
@@ -430,7 +430,8 @@ namespace chaiscript
|
||||
};
|
||||
|
||||
Dispatch_Engine()
|
||||
: m_stack_holder(this)
|
||||
: m_stack_holder(this),
|
||||
m_method_missing_loc(0)
|
||||
{
|
||||
}
|
||||
|
||||
|
@@ -846,7 +846,8 @@ namespace chaiscript
|
||||
plist.begin(),
|
||||
std::back_inserter(newplist),
|
||||
[](const Type_Info &ti, const Boxed_Value ¶m) -> Boxed_Value {
|
||||
if (ti.is_arithmetic() && param.get_type_info().is_arithmetic()) {
|
||||
if (ti.is_arithmetic() && param.get_type_info().is_arithmetic()
|
||||
&& param.get_type_info() != ti) {
|
||||
return Boxed_Number(param).get_as(ti).bv;
|
||||
} else {
|
||||
return param;
|
||||
@@ -854,8 +855,6 @@ namespace chaiscript
|
||||
}
|
||||
);
|
||||
|
||||
|
||||
|
||||
try {
|
||||
return (*(matching_func->second))(newplist, t_conversions);
|
||||
} catch (const exception::bad_boxed_cast &) {
|
||||
|
@@ -60,6 +60,16 @@ namespace chaiscript
|
||||
return m_type_info < ti.m_type_info;
|
||||
}
|
||||
|
||||
CHAISCRIPT_CONSTEXPR bool operator!=(const Type_Info &ti) const CHAISCRIPT_NOEXCEPT
|
||||
{
|
||||
return !(operator==(ti));
|
||||
}
|
||||
|
||||
CHAISCRIPT_CONSTEXPR bool operator!=(const std::type_info &ti) const CHAISCRIPT_NOEXCEPT
|
||||
{
|
||||
return !(operator==(ti));
|
||||
}
|
||||
|
||||
CHAISCRIPT_CONSTEXPR bool operator==(const Type_Info &ti) const CHAISCRIPT_NOEXCEPT
|
||||
{
|
||||
return ti.m_type_info == m_type_info
|
||||
|
@@ -85,7 +85,8 @@ namespace chaiscript
|
||||
public:
|
||||
Binary_Operator_AST_Node(const std::string &t_oper, Parse_Location t_loc, std::vector<AST_NodePtr> t_children) :
|
||||
AST_Node(t_oper, AST_Node_Type::Binary, std::move(t_loc), std::move(t_children)),
|
||||
m_oper(Operators::to_operator(t_oper))
|
||||
m_oper(Operators::to_operator(t_oper)),
|
||||
m_loc(0)
|
||||
{ }
|
||||
|
||||
virtual ~Binary_Operator_AST_Node() {}
|
||||
@@ -393,7 +394,10 @@ namespace chaiscript
|
||||
public:
|
||||
Equation_AST_Node(std::string t_ast_node_text, Parse_Location t_loc, std::vector<AST_NodePtr> t_children) :
|
||||
AST_Node(std::move(t_ast_node_text), AST_Node_Type::Equation, std::move(t_loc), std::move(t_children)),
|
||||
m_oper(Operators::to_operator(children[1]->text))
|
||||
m_oper(Operators::to_operator(children[1]->text)),
|
||||
m_loc(0),
|
||||
m_clone_loc(0)
|
||||
|
||||
{ assert(children.size() == 3); }
|
||||
|
||||
Operators::Opers m_oper;
|
||||
@@ -535,7 +539,7 @@ namespace chaiscript
|
||||
struct Array_Call_AST_Node : public AST_Node {
|
||||
public:
|
||||
Array_Call_AST_Node(std::string t_ast_node_text, Parse_Location t_loc, std::vector<AST_NodePtr> t_children) :
|
||||
AST_Node(std::move(t_ast_node_text), AST_Node_Type::Array_Call, std::move(t_loc), std::move(t_children)) { }
|
||||
AST_Node(std::move(t_ast_node_text), AST_Node_Type::Array_Call, std::move(t_loc), std::move(t_children)), m_loc(0) { }
|
||||
virtual ~Array_Call_AST_Node() {}
|
||||
virtual Boxed_Value eval_internal(const chaiscript::detail::Dispatch_State &t_ss) const CHAISCRIPT_OVERRIDE{
|
||||
chaiscript::eval::detail::Function_Push_Pop fpp(t_ss);
|
||||
@@ -574,6 +578,8 @@ namespace chaiscript
|
||||
public:
|
||||
Dot_Access_AST_Node(std::string t_ast_node_text, Parse_Location t_loc, std::vector<AST_NodePtr> t_children) :
|
||||
AST_Node(std::move(t_ast_node_text), AST_Node_Type::Dot_Access, std::move(t_loc), std::move(t_children)),
|
||||
m_loc(0),
|
||||
m_array_loc(0),
|
||||
m_fun_name(
|
||||
((children[2]->identifier == AST_Node_Type::Fun_Call) || (children[2]->identifier == AST_Node_Type::Array_Call))?
|
||||
children[2]->children[0]->text:children[2]->text) { }
|
||||
@@ -923,7 +929,7 @@ namespace chaiscript
|
||||
struct Switch_AST_Node : public AST_Node {
|
||||
public:
|
||||
Switch_AST_Node(std::string t_ast_node_text, Parse_Location t_loc, std::vector<AST_NodePtr> t_children) :
|
||||
AST_Node(std::move(t_ast_node_text), AST_Node_Type::Switch, std::move(t_loc), std::move(t_children)) { }
|
||||
AST_Node(std::move(t_ast_node_text), AST_Node_Type::Switch, std::move(t_loc), std::move(t_children)), m_loc(0) { }
|
||||
virtual ~Switch_AST_Node() {}
|
||||
virtual Boxed_Value eval_internal(const chaiscript::detail::Dispatch_State &t_ss) const CHAISCRIPT_OVERRIDE {
|
||||
bool breaking = false;
|
||||
@@ -999,7 +1005,10 @@ namespace chaiscript
|
||||
struct Inline_Array_AST_Node : public AST_Node {
|
||||
public:
|
||||
Inline_Array_AST_Node(std::string t_ast_node_text, Parse_Location t_loc, std::vector<AST_NodePtr> t_children) :
|
||||
AST_Node(std::move(t_ast_node_text), AST_Node_Type::Inline_Array, std::move(t_loc), std::move(t_children)) { }
|
||||
AST_Node(std::move(t_ast_node_text), AST_Node_Type::Inline_Array, std::move(t_loc), std::move(t_children)),
|
||||
m_loc(0)
|
||||
{ }
|
||||
|
||||
virtual ~Inline_Array_AST_Node() {}
|
||||
virtual Boxed_Value eval_internal(const chaiscript::detail::Dispatch_State &t_ss) const CHAISCRIPT_OVERRIDE {
|
||||
try {
|
||||
@@ -1033,7 +1042,7 @@ namespace chaiscript
|
||||
struct Inline_Map_AST_Node : public AST_Node {
|
||||
public:
|
||||
Inline_Map_AST_Node(std::string t_ast_node_text, Parse_Location t_loc, std::vector<AST_NodePtr> t_children) :
|
||||
AST_Node(std::move(t_ast_node_text), AST_Node_Type::Inline_Map, std::move(t_loc), std::move(t_children)) { }
|
||||
AST_Node(std::move(t_ast_node_text), AST_Node_Type::Inline_Map, std::move(t_loc), std::move(t_children)), m_loc(0) { }
|
||||
virtual ~Inline_Map_AST_Node() {}
|
||||
virtual Boxed_Value eval_internal(const chaiscript::detail::Dispatch_State &t_ss) const CHAISCRIPT_OVERRIDE{
|
||||
try {
|
||||
@@ -1123,7 +1132,8 @@ namespace chaiscript
|
||||
public:
|
||||
Prefix_AST_Node(std::string t_ast_node_text, Parse_Location t_loc, std::vector<AST_NodePtr> t_children) :
|
||||
AST_Node(std::move(t_ast_node_text), AST_Node_Type::Prefix, std::move(t_loc), std::move(t_children)),
|
||||
m_oper(Operators::to_operator(children[0]->text, true))
|
||||
m_oper(Operators::to_operator(children[0]->text, true)),
|
||||
m_loc(0)
|
||||
{ }
|
||||
|
||||
virtual ~Prefix_AST_Node() {}
|
||||
@@ -1204,7 +1214,7 @@ namespace chaiscript
|
||||
struct Inline_Range_AST_Node : public AST_Node {
|
||||
public:
|
||||
Inline_Range_AST_Node(std::string t_ast_node_text, Parse_Location t_loc, std::vector<AST_NodePtr> t_children) :
|
||||
AST_Node(std::move(t_ast_node_text), AST_Node_Type::Inline_Range, std::move(t_loc), std::move(t_children)) { }
|
||||
AST_Node(std::move(t_ast_node_text), AST_Node_Type::Inline_Range, std::move(t_loc), std::move(t_children)), m_loc(0) { }
|
||||
virtual ~Inline_Range_AST_Node() {}
|
||||
virtual Boxed_Value eval_internal(const chaiscript::detail::Dispatch_State &t_ss) const CHAISCRIPT_OVERRIDE{
|
||||
try {
|
||||
|
@@ -219,6 +219,10 @@ namespace chaiscript
|
||||
m_operators.emplace_back(AST_Node_Type::Multiplication);
|
||||
m_operator_matches.emplace_back(std::initializer_list<std::string>({"*", "/", "%"}));
|
||||
|
||||
// Prefix placeholder
|
||||
m_operators.emplace_back(AST_Node_Type::Prefix);
|
||||
m_operator_matches.emplace_back(std::initializer_list<std::string>({}));
|
||||
|
||||
for (auto & elem : m_alphabet) {
|
||||
std::fill(std::begin(elem), std::end(elem), false);
|
||||
}
|
||||
@@ -2160,7 +2164,7 @@ namespace chaiscript
|
||||
/// Reads a unary prefixed expression from input
|
||||
bool Prefix() {
|
||||
const auto prev_stack_top = m_match_stack.size();
|
||||
const std::vector<std::string> prefix_opers{"++", "--", "-", "+", "!", "~", "&"};
|
||||
const std::vector<std::string> prefix_opers{"++", "--", "-", "+", "!", "~"};
|
||||
|
||||
for (const auto &oper : prefix_opers)
|
||||
{
|
||||
@@ -2197,7 +2201,7 @@ namespace chaiscript
|
||||
bool retval = false;
|
||||
const auto prev_stack_top = m_match_stack.size();
|
||||
|
||||
if (t_precedence < m_operators.size()) {
|
||||
if (m_operators[t_precedence] != AST_Node_Type::Prefix) {
|
||||
if (Operator(t_precedence+1)) {
|
||||
retval = true;
|
||||
if (Operator_Helper(t_precedence)) {
|
||||
@@ -2257,8 +2261,7 @@ namespace chaiscript
|
||||
} while (Operator_Helper(t_precedence));
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
return Value();
|
||||
}
|
||||
|
||||
|
@@ -1,6 +1,17 @@
|
||||
Notes:
|
||||
=======
|
||||
Current Version: 5.8.2
|
||||
Current Version: 5.8.5
|
||||
|
||||
### Changes since 5.8.4
|
||||
* Fix order of operations for prefix operators
|
||||
* Make sure atomics are initialized properly
|
||||
* Remove parsing of unused prefix `&` operator
|
||||
|
||||
### Changes since 5.8.3
|
||||
* Fix case with some numeric conversions mixed with numerics that do not need conversion
|
||||
|
||||
### Changes since 5.8.2
|
||||
* Add support for reference of pointer return types
|
||||
|
||||
### Changes since 5.8.1
|
||||
* Allow casting to non-const & std::shared_ptr<T>
|
||||
|
@@ -950,4 +950,34 @@ TEST_CASE("Parse floats with non-posix locale")
|
||||
|
||||
|
||||
|
||||
bool FindBitmap(int &ox, int &oy, long) {
|
||||
ox = 1;
|
||||
oy = 2;
|
||||
return true;
|
||||
}
|
||||
|
||||
TEST_CASE("Mismatched numeric types only convert necessary params")
|
||||
{
|
||||
chaiscript::ChaiScript chai;
|
||||
|
||||
chai.add(chaiscript::fun(&FindBitmap), "FindBitmap");
|
||||
int x = 0;
|
||||
int y = 0;
|
||||
chai.add(chaiscript::var(&x), "x");
|
||||
chai.add(chaiscript::var(&y), "y");
|
||||
chai.eval( "if ( FindBitmap ( x, y, 0) ) { print(\"found at \" + to_string(x) + \", \" + to_string(y))}" );
|
||||
CHECK(x == 1);
|
||||
CHECK(y == 2);
|
||||
|
||||
}
|
||||
|
||||
TEST_CASE("type_conversion to bool")
|
||||
{
|
||||
auto module = std::make_shared<chaiscript::Module>();
|
||||
struct T {
|
||||
operator bool() const { return true; }
|
||||
};
|
||||
module->add(chaiscript::type_conversion<T, bool>());
|
||||
}
|
||||
|
||||
|
||||
|
Binary file not shown.
4
unittests/precedence_4.chai
Normal file
4
unittests/precedence_4.chai
Normal file
@@ -0,0 +1,4 @@
|
||||
|
||||
var i = 2;
|
||||
|
||||
assert_equal(++i * i, 9)
|
Reference in New Issue
Block a user