MCPcopy Create free account
hub / github.com/WheretIB/nullc / AddStringNode

Function AddStringNode

NULLC/Callbacks.cpp:715–763  ·  view source on GitHub ↗

Function that places string on stack, using list of NodeNumber in NodeExpressionList

Source from the content-addressed store, hash-verified

713
714// Function that places string on stack, using list of NodeNumber in NodeExpressionList
715void AddStringNode(const char* s, const char* e, bool unescaped)
716{
717 CodeInfo::lastKnownStartPos = s;
718
719 const char *curr = s + 1, *end = e - 1;
720 unsigned int len = 0;
721 // Find the length of the string with collapsed escape-sequences
722 for(; curr < end; curr++, len++)
723 {
724 if(*curr == '\\' && !unescaped)
725 curr++;
726 }
727 curr = s + 1;
728 end = e - 1;
729
730 CodeInfo::nodeList.push_back(new NodeZeroOP());
731 TypeInfo *targetType = CodeInfo::GetArrayType(typeChar, len + 1);
732 CodeInfo::nodeList.push_back(new NodeExpressionList(targetType));
733
734 NodeZeroOP* temp = CodeInfo::nodeList.back();
735 CodeInfo::nodeList.pop_back();
736
737 NodeExpressionList *arrayList = static_cast<NodeExpressionList*>(temp);
738
739 while(end-curr > 0)
740 {
741 char clean[4];
742 *(int*)clean = 0;
743
744 for(int i = 0; i < 4 && curr < end; i++, curr++)
745 {
746 clean[i] = *curr;
747 if(*curr == '\\' && !unescaped)
748 {
749 curr++;
750 CodeInfo::lastKnownStartPos = curr;
751 clean[i] = UnescapeSybmol(*curr);
752 }
753 }
754 CodeInfo::nodeList.push_back(new NodeNumber(*(int*)clean, typeInt));
755 arrayList->AddNode();
756 }
757 if(len % 4 == 0)
758 {
759 CodeInfo::nodeList.push_back(new NodeNumber(0, typeInt));
760 arrayList->AddNode();
761 }
762 CodeInfo::nodeList.push_back(temp);
763}
764
765// Function that creates node that removes value on top of the stack
766void AddPopNode(const char* pos)

Callers 1

ParseStringFunction · 0.85

Calls 4

UnescapeSybmolFunction · 0.85
AddNodeMethod · 0.80
push_backMethod · 0.45
pop_backMethod · 0.45

Tested by

no test coverage detected