123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204 |
- diff --git a/include/teascript/StackMachine.hpp b/include/teascript/StackMachine.hpp
- index 4a0af14..b714742 100644
- --- a/include/teascript/StackMachine.hpp
- +++ b/include/teascript/StackMachine.hpp
- @@ -558,7 +558,7 @@ private:
- // TODO: Handle rContext.dialect.auto_define_unknown_identifiers on throw unknown_identifier
- // TODO: can this be merged with ASTNode_Assign ?
- try {
- - mStack[s - 2] = rContext.SetValue( id.GetValue<std::string>(), val, current_instr.payload.template GetValue<bool>() );
- + mStack[s - 2] = rContext.SetValue( id.template GetValue<std::string>(), val, current_instr.payload.template GetValue<bool>() );
- } catch( ... ) {
- HandleException( std::current_exception() );
- run = false;
- @@ -588,7 +588,7 @@ private:
- continue;
- }
- try {
- - mStack[s - 2] = rContext.AddValueObject( id.GetValue<std::string>(), val.MakeShared() );
- + mStack[s - 2] = rContext.AddValueObject( id.template GetValue<std::string>(), val.MakeShared() );
- } catch( ... ) {
- HandleException( std::current_exception() );
- run = false;
- @@ -611,7 +611,7 @@ private:
- val.Detach( true ); // make copy
- }
- try {
- - mStack[s - 2] = rContext.AddValueObject( id.GetValue<std::string>(), val.MakeShared().MakeConst() );
- + mStack[s - 2] = rContext.AddValueObject( id.template GetValue<std::string>(), val.MakeShared().MakeConst() );
- } catch( ... ) {
- HandleException( std::current_exception() );
- run = false;
- @@ -685,7 +685,7 @@ private:
- auto &val = mStack[s - 1];
- auto const &id = mStack[s - 2];
- auto &obj = mStack[s - 3];
- - auto &tuple = obj.GetValue<Tuple>();
- + auto &tuple = obj.template GetValue<Tuple>();
- bool const shared = current_instr.payload.template GetValue<bool>();
-
- if( obj.IsConst() ) {
- @@ -718,7 +718,7 @@ private:
- } else {
- auto &lhs = mStack.back();
- auto &rhs = current_instr.payload;
- - auto &tuple = lhs.GetValue<Tuple>();
- + auto &tuple = lhs.template GetValue<Tuple>();
-
- std::size_t idx = static_cast<std::size_t>(-1);
- if( rhs.GetTypeInfo()->IsSame( TypeString ) ) {
- @@ -741,7 +741,7 @@ private:
- if( stack_error( 2 ) ) [[unlikely]] {
- continue;
- } else {
- - auto param_count = mStack.back().GetValue<U64>();
- + auto param_count = mStack.back().template GetValue<U64>();
- if( stack_error( param_count + 1 + 1 ) ) [[unlikely]] {
- continue;
- }
- @@ -770,7 +770,7 @@ private:
- continue;
- } else {
- auto const s = mStack.size();
- - auto param_count = mStack[s-2].GetValue<U64>();
- + auto param_count = mStack[s-2].template GetValue<U64>();
- if( stack_error( param_count + 1 + 1 + 1 ) ) [[unlikely]] {
- continue;
- }
- @@ -882,7 +882,7 @@ private:
- run = false;
- continue;
- }
- - auto &tuple = lhs.GetValue<Tuple>();
- + auto &tuple = lhs.template GetValue<Tuple>();
- std::size_t idx = static_cast<std::size_t>(-1);
- if( rhs.GetTypeInfo()->IsSame( TypeString ) ) {
- idx = tuple.IndexOfKey( rhs.template GetValue<String>() );
- @@ -890,7 +890,7 @@ private:
- idx = static_cast<std::size_t>(rhs.GetAsInteger());
- }
- if( idx == static_cast<std::size_t>(-1) ) {
- - HandleException( std::make_exception_ptr( exception::unknown_identifier( rhs.GetValue<String>() ) ) );
- + HandleException( std::make_exception_ptr( exception::unknown_identifier( rhs.template GetValue<String>() ) ) );
- run = false;
- continue;
- } else if( not tuple.ContainsIdx( idx ) ) {
- @@ -953,21 +953,21 @@ private:
-
- // get the sequence
- auto &seq_val = mStack[s - 1];
- - if( not seq_val.GetTypeInfo()->IsSame<IntegerSequence>() && not seq_val.GetTypeInfo()->IsSame<Tuple>() ) {
- + if( not seq_val.GetTypeInfo()->template IsSame<IntegerSequence>() && not seq_val.GetTypeInfo()->template IsSame<Tuple>() ) {
- HandleException( std::make_exception_ptr( exception::eval_error( "Forall loop can actually only iterate over an IntegerSequence/Tuple!" ) ) );
- run = false;
- continue;
- }
-
- //FIXME: if seq_val is a sequence already we should use a reference for in later versions it will be possible to manipulate it elsewhere in the loop.
- - auto seq = seq_val.GetTypeInfo()->IsSame<Tuple>()
- - ? IntegerSequence( 0LL, static_cast<Integer>(seq_val.GetValue<Tuple>().Size() - 1), 1LL )
- - : seq_val.GetValue<IntegerSequence>();
- + auto seq = seq_val.GetTypeInfo()->template IsSame<Tuple>()
- + ? IntegerSequence( 0LL, static_cast<Integer>(seq_val.template GetValue<Tuple>().Size() - 1), 1LL )
- + : seq_val.template GetValue<IntegerSequence>();
- seq.Reset();
-
- // create the index variable
- // TODO: add mDebugInfo SourceLocation!
- - mStack[s - 2] = rContext.AddValueObject( mStack[s - 2].GetValue<std::string>(), ValueObject( seq.Current(), ValueConfig(ValueShared, ValueMutable)));
- + mStack[s - 2] = rContext.AddValueObject( mStack[s - 2].template GetValue<std::string>(), ValueObject( seq.Current(), ValueConfig(ValueShared, ValueMutable)));
-
- // store the seqeunce
- mStack[s - 1] = ValueObject( std::move(seq), ValueConfig(ValueShared, ValueMutable));
- @@ -978,7 +978,7 @@ private:
- continue;
- } else {
- auto const s = mStack.size();
- - auto &seq = mStack[s - 2].GetValue<IntegerSequence>();
- + auto &seq = mStack[s - 2].template GetValue<IntegerSequence>();
- if( seq.Next() ) {
- mStack[s - 3].AssignValue( seq.Current() );
- mStack.pop_back(); // clear previous result
- @@ -999,11 +999,11 @@ private:
- if( stack_error( 2 ) ) [[unlikely]] {
- continue;
- } else {
- - auto param_count = mStack.back().GetValue<U64>();
- + auto param_count = mStack.back().template GetValue<U64>();
- if( stack_error( param_count + 1 + 1 ) ) [[unlikely]] {
- continue;
- }
- - auto func = mStack[ mStack.size() - (param_count + 1 + 1)].GetValue<FunctionPtr>(); // copy is intended!!
- + auto func = mStack[ mStack.size() - (param_count + 1 + 1)].template GetValue<FunctionPtr>(); // copy is intended!!
- auto cfunc = std::dynamic_pointer_cast<CompiledFuncBase>(func);
- if( cfunc ) {
- mCallStack.emplace_back( current_instr.payload.template GetValue<std::string>(), mCurrent + 1, cfunc->GetProgram(), func );
- @@ -1089,7 +1089,7 @@ private:
- continue;
- } else {
- // we need a working copy of the param count for decrement!
- - mStack.emplace_back( mStack.back().GetValue<U64>() );
- + mStack.emplace_back( mStack.back().template GetValue<U64>() );
- }
- break;
- case eTSVM_Instr::ParamSpecClean:
- @@ -1097,7 +1097,7 @@ private:
- if( stack_error( 3 ) ) [[unlikely]] {
- continue;
- } else {
- - auto const left_params = mStack.back().GetValue<U64>();
- + auto const left_params = mStack.back().template GetValue<U64>();
- if( left_params != 0 ) [[unlikely]] {
- //NOTE: we need SourceLoc of the caller! But the caller is different for each call.
- // Here we know that callstack is at least 2 (we and the caller). The ret address - 1 is the CallFunc instruction which might carry a source loc.
- @@ -1106,7 +1106,7 @@ private:
- run = false;
- continue;
- } else {
- - auto orig_params = mStack[mStack.size() - 2].GetValue<U64>();
- + auto orig_params = mStack[mStack.size() - 2].template GetValue<U64>();
- mStack.pop_back(); // working param count
- mStack.pop_back(); // orig param count
- while( orig_params > 0 ) { // each param
- @@ -1123,7 +1123,7 @@ private:
- continue;
- } else {
- auto const pos = mStack.size() - 2;
- - auto param_count = mStack[pos].GetValue<U64>();
- + auto param_count = mStack[pos].template GetValue<U64>();
- if( param_count < 1 ) [[unlikely]] { // huh?
- //NOTE: we need SourceLoc of the caller! But the caller is different for each call.
- // Here we know that callstack is at least 2 (we and the caller). The ret address - 1 is the CallFunc instruction which might carry a source loc.
- @@ -1148,7 +1148,7 @@ private:
- continue;
- } else {
- auto const pos = mStack.size() - 2;
- - auto param_count = mStack[pos].GetValue<U64>();
- + auto param_count = mStack[pos].template GetValue<U64>();
- if( param_count > 0 ) { // there are still parameters given by the caller.
- // add current param to end (after the id)
- mStack.push_back( std::move( mStack[pos - (1 + param_count)] ) );
- @@ -1261,12 +1261,12 @@ private:
- {
- std::size_t idx = static_cast<std::size_t>(-1);
- if( rId.GetTypeInfo()->IsSame( TypeString ) ) {
- - idx = rTuple.IndexOfKey( rId.GetValue<std::string>() );
- + idx = rTuple.IndexOfKey( rId.template GetValue<std::string>() );
- } else {
- idx = static_cast<std::size_t>(rId.GetAsInteger());
- }
- if( idx == static_cast<std::size_t>(-1) ) {
- - HandleException( std::make_exception_ptr( exception::unknown_identifier( rId.GetValue<std::string>() ) ) );
- + HandleException( std::make_exception_ptr( exception::unknown_identifier( rId.template GetValue<std::string>() ) ) );
- return idx;
- } else if( not rTuple.ContainsIdx( idx ) ) {
- HandleException( std::make_exception_ptr( exception::out_of_range() ) );
- @@ -1301,7 +1301,7 @@ private:
- }
- }
- if( rId.GetTypeInfo()->IsSame( TypeString ) ) {
- - std::string const &identifier = rId.GetValue<std::string>();
- + std::string const &identifier = rId.template GetValue<std::string>();
- if( not rTuple.AppendKeyValue( identifier, as_const ? val.MakeShared().MakeConst() : val.MakeShared() ) ) {
- HandleException( std::make_exception_ptr( exception::redefinition_of_variable( identifier ) ) );
- return idx;
|