MCPcopy Index your code
hub / github.com/GJDuck/e9patch / makeDataEntry

Function makeDataEntry

src/e9patch/e9json.cpp:723–853  ·  view source on GitHub ↗

* Create a data template entry. */

Source from the content-addressed store, hash-verified

721 * Create a data template entry.
722 */
723static Entry makeDataEntry(Parser &parser)
724{
725 expectToken(parser, TOKEN_STRING);
726 Entry entry;
727 memset(&entry, 0x0, sizeof(entry));
728 entry.kind = ENTRY_LABEL;
729
730 switch (parser.s[0])
731 {
732 case 'i':
733 if (strcmp(parser.s, "int8") == 0)
734 entry.kind = ENTRY_INT8;
735 else if (strcmp(parser.s, "int16") == 0)
736 entry.kind = ENTRY_INT16;
737 else if (strcmp(parser.s, "int32") == 0)
738 entry.kind = ENTRY_INT32;
739 else if (strcmp(parser.s, "int64") == 0)
740 entry.kind = ENTRY_INT64;
741 else
742 goto type_error;
743 break;
744 case 'r':
745 if (strcmp(parser.s, "rel8") == 0)
746 entry.kind = ENTRY_REL8;
747 else if (strcmp(parser.s, "rel32") == 0)
748 entry.kind = ENTRY_REL32;
749 else
750 goto type_error;
751 break;
752 case 's':
753 if (strcmp(parser.s, "string") == 0)
754 entry.kind = ENTRY_BYTES;
755 else
756 goto type_error;
757 break;
758 case 'z':
759 if (strcmp(parser.s, "zeroes") == 0)
760 entry.kind = ENTRY_ZEROES;
761 break;
762 default:
763type_error:
764 parse_error(parser, "failed to data type; unknown type name "
765 "\"%s\"", parser.s);
766 }
767
768 expectToken(parser, ':');
769 switch (entry.kind)
770 {
771 case ENTRY_BYTES:
772 {
773 expectToken(parser, TOKEN_STRING);
774 entry.length = strlen(parser.s)+1;
775 entry.bytes = dupBytes(parser.s);
776 break;
777 }
778 case ENTRY_ZEROES:
779 {
780 expectToken(parser, TOKEN_NUMBER);

Callers 1

parseTrampolineFunction · 0.85

Calls 9

expectTokenFunction · 0.85
memsetFunction · 0.85
strcmpFunction · 0.85
dupBytesFunction · 0.85
expectToken2Function · 0.85
dupStringFunction · 0.85
stringToNumberFunction · 0.85
convertIntegerFunction · 0.85
strlenFunction · 0.50

Tested by

no test coverage detected