+ int32_t ann_cnt;
+ ION_CHECK(ion_reader_get_annotation_count(ser->reader, &ann_cnt));
+ for (int32_t i = 0; i < ann_cnt; ++i) {
+ ION_STRING ann_str;
+ ION_CHECK(ion_reader_get_an_annotation(ser->reader, i, &ann_str));
+
+ if (ann_str.length != 1) {
+ continue;
+ }
+
+ switch (*ann_str.value) {
+ case 'R':
+ if (ser->annotations.makeref) {
+ zend_throw_exception_ex(spl_ce_RuntimeException, IERR_INVALID_SYNTAX,
+ "Invalid multiple reference annotations");
+ return;
+ }
+ ser->annotations.makeref = true;
+ break;
+
+ case 'r':
+ if (ser->annotations.backref) {
+ zend_throw_exception_ex(spl_ce_RuntimeException, IERR_INVALID_SYNTAX,
+ "Invalid multiple back reference annotations");
+ return;
+ }
+ ser->annotations.backref = true;
+ break;
+
+ case 'p':
+ if (ser->annotations.object_prop) {
+ zend_throw_exception_ex(spl_ce_RuntimeException, IERR_INVALID_SYNTAX,
+ "Invalid multiple object property annotations");
+ return;
+ }
+ ser->annotations.object_prop = true;
+
+ ION_STRING prop_class;
+ ION_CHECK(ion_reader_get_an_annotation(ser->reader, ++i, &prop_class));
+ ser->annotations.property_class = zend_string_from_ion(&prop_class);
+
+ zval zptmp;
+ ZVAL_STR(&zptmp, ser->annotations.property_class);
+ zend_hash_next_index_insert(ser->tmp, &zptmp);
+ break;
+
+ case 'E':
+ case 'S':
+ case 'O':
+ case 'C':
+ case 'o':
+ case 'c':
+ if (ser->annotations.object_type) {
+ zend_throw_exception_ex(spl_ce_RuntimeException, IERR_INVALID_SYNTAX,
+ "Invalid multiple object type annotations: %c::%c",
+ ser->annotations.object_type, *ann_str.value);
+ return;
+ }
+ if ('o' != (ser->annotations.object_type = *ann_str.value)) {
+ ION_STRING class_name;
+ ION_CHECK(ion_reader_get_an_annotation(ser->reader, ++i, &class_name));
+ ser->annotations.object_class = zend_string_from_ion(&class_name);
+
+ zval zctmp;
+ ZVAL_STR(&zctmp, ser->annotations.object_class);
+ zend_hash_next_index_insert(ser->tmp, &zctmp);
+ }
+ break;
+ }