@@ -282,14 +282,14 @@ void OMInterpreter::execute(std::shared_ptr<OMClass> clazz, std::shared_ptr<OMMe
282282
283283 default : {
284284 tower.debugStackStatus ();
285- throw err::OMValidationError{err::Instructions, " instructions not implemented " ,
285+ throw err::OMValidationError{err::Instructions, " we hitted the azure bounary (unknown instruction) " ,
286286 fetchCurrentPosition (frame)};
287287 }
288288 }
289289 }
290290 }
291291
292- throw err::OMValidationError{err::Instructions, " code heap overflow! " , fetchCurrentPosition (frame)};
292+ throw err::OMValidationError{err::Instructions, " what are you executing? " , fetchCurrentPosition (frame)};
293293}
294294void OMInterpreter::checkType (std::shared_ptr<OMFrameMetadata> frame, std::any data, std::string desc)
295295{
@@ -495,24 +495,47 @@ std::string OMInterpreter::fetchName(OMArrayType type)
495495 return " ref" ;
496496 }
497497}
498- // TODO: other types
499498void OMInterpreter::writeStackTop (void *target, std::string desc, std::shared_ptr<OMFrameMetadata> frame)
500499{
501500 STACK_CHECK ;
502501 auto it = std::type_index (STACK_ACCESS .top ().type ());
503502
504- if (it == std::type_index (typeid (int )))
503+ int temp = 0 ;
504+ auto descparsed = bytecode::descriptor::decodeType (desc, &temp);
505+ if (descparsed.type == util::Err)
505506 {
506- *((int *)target) = std::any_cast<int >(STACK_ACCESS .top ());
507+ throw err::OMValidationError{err::Instructions,
508+ fmt::format (" unknown field descriptor, {}" , descparsed.unwrap_err ()),
509+ fetchCurrentPosition (frame)};
507510 }
508- else if (it == std::type_index (typeid (void *)))
511+
512+ checkType (frame, STACK_ACCESS .top (), descparsed.unwrap ());
513+
514+ switch (hash_compile_time (descparsed.unwrap ().c_str ()))
509515 {
516+ case " boolean" _hash:
517+ case " char" _hash:
518+ case " byte" _hash:
519+ *((char *)target) = std::any_cast<int >(STACK_ACCESS .top ());
520+ break ;
521+ case " short" _hash:
522+ *((short *)target) = std::any_cast<int >(STACK_ACCESS .top ());
523+ break ;
524+ case " int" _hash:
525+ *((int *)target) = std::any_cast<int >(STACK_ACCESS .top ());
526+ break ;
527+ case " long" _hash:
528+ *((int64_t *)target) = std::any_cast<int64_t >(STACK_ACCESS .top ());
529+ break ;
530+ case " float" _hash:
531+ *((float *)target) = std::any_cast<float >(STACK_ACCESS .top ());
532+ break ;
533+ case " double" _hash:
534+ *((double *)target) = std::any_cast<double >(STACK_ACCESS .top ());
535+ break ;
536+ default :
510537 *((void **)target) = std::any_cast<void *>(STACK_ACCESS .top ());
511- }
512- else
513- {
514- throw err::OMValidationError{err::Instructions, fmt::format (" unknown stack top data" ),
515- fetchCurrentPosition (frame)};
538+ break ;
516539 }
517540
518541 SAFE_STACK_POP ;
0 commit comments