From 6e67ce8574eff17b87b350e4f7f3323d2b4f4914 Mon Sep 17 00:00:00 2001 From: q66 Date: Thu, 9 Feb 2017 22:54:09 +0100 Subject: [PATCH] clean up pointerrange constructor --- src/cs_vm.cc | 13 ++++++------- src/cubescript.cc | 11 ++++++----- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/cs_vm.cc b/src/cs_vm.cc index fc527d3c..06d4a2b7 100644 --- a/src/cs_vm.cc +++ b/src/cs_vm.cc @@ -431,7 +431,7 @@ static inline void callcommand( cscript::util::tvals_concat(buf, ostd::iter(args, i), " "); CsValue tv; tv.set_str(std::move(buf.get())); - CsCommandInternal::call(cs, id, CsValueRange(&tv, 1), res); + CsCommandInternal::call(cs, id, CsValueRange(&tv, &tv + 1), res); return; } case 'V': @@ -450,7 +450,7 @@ static inline void callcommand( } } ++i; - CsCommandInternal::call(cs, id, CsValueRange(args, i), res); + CsCommandInternal::call(cs, id, CsValueRange(args, args + i), res); } static uint32_t *runcode(CsState &cs, uint32_t *code, CsValue &result); @@ -1339,10 +1339,9 @@ static uint32_t *runcode(CsState &cs, uint32_t *code, CsValue &result) { ); int offset = numargs - id->get_num_args(); result.force_null(); - CsCommandInternal::call( - cs, id, CsValueRange(args + offset, id->get_num_args()), - result - ); + CsCommandInternal::call(cs, id, CsValueRange( + args + offset, args + offset + id->get_num_args() + ), result); force_arg(result, op & CsCodeRetMask); numargs = offset; continue; @@ -1380,7 +1379,7 @@ static uint32_t *runcode(CsState &cs, uint32_t *code, CsValue &result) { ); CsValue tv; tv.set_str(std::move(buf.get())); - CsCommandInternal::call(cs, id, CsValueRange(&tv, 1), result); + CsCommandInternal::call(cs, id, CsValueRange(&tv, &tv + 1), result); } force_arg(result, op & CsCodeRetMask); numargs = offset; diff --git a/src/cubescript.cc b/src/cubescript.cc index a36f65a6..6d252243 100644 --- a/src/cubescript.cc +++ b/src/cubescript.cc @@ -531,14 +531,15 @@ bool CsState::have_ident(ostd::ConstCharRange name) { } CsIdentRange CsState::get_idents() { - return CsIdentRange(p_state->identmap.data(), p_state->identmap.size()); + return CsIdentRange( + p_state->identmap.data(), + p_state->identmap.data() + p_state->identmap.size() + ); } CsConstIdentRange CsState::get_idents() const { - return CsConstIdentRange( - const_cast(p_state->identmap.data()), - p_state->identmap.size() - ); + auto ptr = const_cast(p_state->identmap.data()); + return CsConstIdentRange(ptr, ptr + p_state->identmap.size()); } CsIvar *CsState::new_ivar(