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

Method Init

NULLC/Compiler.cpp:63–112  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

61}
62
63void CompilerError::Init(const char* errStr, const char* apprPos)
64{
65 empty = 0;
66 unsigned int len = (unsigned int)strlen(errStr) < NULLC_ERROR_BUFFER_SIZE ? (unsigned int)strlen(errStr) : NULLC_ERROR_BUFFER_SIZE - 1;
67 memcpy(errLocal, errStr, len);
68 errLocal[len] = 0;
69 const char *intStart = codeStart, *intEnd = codeEnd;
70 if(apprPos < intStart || apprPos > intEnd)
71 {
72 for(unsigned i = 1; i < NULLC::codeSourceRange->size(); i++)
73 {
74 if(apprPos >= (*NULLC::codeSourceRange)[i].start && apprPos <= (*NULLC::codeSourceRange)[i].end)
75 {
76 intStart = (*NULLC::codeSourceRange)[i].start;
77 intEnd = (*NULLC::codeSourceRange)[i].end;
78 break;
79 }
80 }
81 }
82 if(apprPos && apprPos >= intStart && apprPos <= intEnd)
83 {
84 const char *begin = apprPos;
85 while((begin >= intStart) && (*begin != '\n') && (*begin != '\r'))
86 begin--;
87 if(begin < apprPos)
88 begin++;
89
90 lineNum = 1;
91 const char *scan = intStart;
92 while(*scan && scan < begin)
93 if(*(scan++) == '\n')
94 lineNum++;
95
96 const char *end = apprPos;
97 while((*end != '\r') && (*end != '\n') && (*end != 0))
98 end++;
99 len = (unsigned int)(end - begin) < 128 ? (unsigned int)(end - begin) : 127;
100 memcpy(line, begin, len);
101 for(unsigned int k = 0; k < len; k++)
102 if((unsigned char)line[k] < 0x20)
103 line[k] = ' ';
104 line[len] = 0;
105 shift = (unsigned int)(apprPos-begin);
106 shift = shift > 128 ? 0 : shift;
107 }else{
108 line[0] = 0;
109 shift = 0;
110 lineNum = 0;
111 }
112}
113
114const char *CompilerError::codeStart = NULL;
115const char *CompilerError::codeEnd = NULL;

Callers 4

AddModuleFunctionMethod · 0.80
ImportModuleMethod · 0.80
BuildModuleMethod · 0.80
CompileMethod · 0.80

Calls 1

sizeMethod · 0.45

Tested by

no test coverage detected