@@ -16,9 +16,9 @@ typedef struct Printer
1616{
1717 char * Buffer ;
1818 const char * BufferStart ;
19- uint32_t BufferCapacity ;
19+ uint32_t BufferSizeLeft ;
2020
21- uint32_t vIp ;
21+ uint32_t VirualInstructionPointer ;
2222 uint32_t CurrentIndent ;
2323 bool LineIndented ;
2424
@@ -42,9 +42,9 @@ typedef struct Printer
4242 void * getTypeInfoCtx ;
4343} Printer ;
4444
45- void static inline Printer_EnsureCapacity (Printer * self , uint32_t capacity )
45+ void static inline Printer_EnsureSizeLeft (Printer * self , uint32_t shouldBeLeft )
4646{
47- if (self -> BufferCapacity < capacity )
47+ if (self -> BufferSizeLeft < shouldBeLeft )
4848 {
4949 assert (0 ); // we don't support growing yet :->
5050 }
@@ -63,7 +63,7 @@ static inline void Printer_PutIndent(Printer* self)
6363 assert (!self -> LineIndented );
6464 assert ((self -> CurrentIndent * 4 ) <= 128 );
6565
66- Printer_EnsureCapacity (self , 128 );
66+ Printer_EnsureSizeLeft (self , 128 );
6767 for (int i = 0 ; i < self -> CurrentIndent ; i ++ )
6868 {
6969 * self -> Buffer ++ = ' ' ;
@@ -83,12 +83,12 @@ static inline void Printer_PutNewlineIndent(Printer* self)
8383static inline void Printer_PutStr (Printer * self , const char * str )
8484{
8585 uint32_t length = 0 ;
86- Printer_EnsureCapacity (self , 128 );
86+ Printer_EnsureSizeLeft (self , 128 );
8787
8888 if (!self -> LineIndented )
8989 {
9090 Printer_PutIndent (self );
91- Printer_EnsureCapacity (self , 128 );
91+ Printer_EnsureSizeLeft (self , 128 );
9292 }
9393 char c ;
9494 if (str )
@@ -101,14 +101,14 @@ static inline void Printer_PutStr(Printer* self, const char* str)
101101
102102 if (length & 128 )
103103 {
104- self -> BufferCapacity -= 128 ;
104+ self -> BufferSizeLeft -= 128 ;
105105 length -= 128 ;
106- Printer_EnsureCapacity (self , 128 );
106+ Printer_EnsureSizeLeft (self , 128 );
107107 }
108108 }
109109 }
110110
111- self -> BufferCapacity -= length ;
111+ self -> BufferSizeLeft -= length ;
112112}
113113
114114static inline void Printer_PutChar (Printer * self , char c )
@@ -118,10 +118,10 @@ static inline void Printer_PutChar(Printer *self, char c)
118118 Printer_PutIndent (self );
119119 }
120120
121- assert (self -> BufferCapacity >= 1 );
121+ assert (self -> BufferSizeLeft >= 1 );
122122
123123 * self -> Buffer ++ = c ;
124- self -> BufferCapacity -- ;
124+ self -> BufferSizeLeft -- ;
125125}
126126
127127static inline void Printer_PutQuotedStr (Printer * self , const char * str )
@@ -183,11 +183,11 @@ static inline void Printer_DecreaseIndent(Printer* self)
183183
184184static inline void Printer_PutDouble (Printer * self , double d )
185185{
186- Printer_EnsureCapacity (self , 24 );
186+ Printer_EnsureSizeLeft (self , 24 );
187187
188188 uint32_t sz = fpconv_dtoa (d , self -> Buffer );
189189 self -> Buffer += sz ;
190- self -> BufferCapacity -= sz ;
190+ self -> BufferSizeLeft -= sz ;
191191}
192192
193193static inline void Printer_PutFloat (Printer * self , float f )
@@ -437,14 +437,14 @@ extern void Printer_StreamToFile(Printer* self, FILE* fd)
437437 assert (sz == bytes_written );
438438
439439 self -> Buffer = cast (char * )self -> BufferStart ;
440- self -> BufferCapacity += sz ;
440+ self -> BufferSizeLeft += sz ;
441441}
442442
443443static inline void Printer_Op3 (Printer * self ,
444444 const BCValue * result , const BCValue * lhs , const BCValue * rhs
445445 , const char * inst )
446446{
447- self -> vIp += 2 ;
447+ self -> VirualInstructionPointer += 2 ;
448448 Printer_PutStr (self , inst );
449449 Printer_PutChar (self , '(' );
450450
@@ -472,7 +472,7 @@ static inline void Printer_Op2(Printer* self,
472472 const BCValue * lhs , const BCValue * rhs
473473 , const char * inst )
474474{
475- self -> vIp += 2 ;
475+ self -> VirualInstructionPointer += 2 ;
476476
477477 Printer_PutStr (self , inst );
478478 Printer_PutChar (self , '(' );
@@ -491,7 +491,7 @@ static inline void Printer_Op1(Printer* self,
491491 const BCValue * lhs
492492 , const char * inst )
493493{
494- self -> vIp += 2 ;
494+ self -> VirualInstructionPointer += 2 ;
495495
496496 Printer_PutStr (self , inst );
497497
@@ -899,25 +899,25 @@ static inline void Printer_PrintLabel(Printer* self, const BCLabel* label)
899899
900900static inline BCLabel Printer_GenLabel (Printer * self )
901901{
902- BCLabel result = {{self -> vIp }};
903- if (self -> LastLabel != self -> vIp )
902+ BCLabel result = {{self -> VirualInstructionPointer }};
903+ if (self -> LastLabel != self -> VirualInstructionPointer )
904904 {
905905
906906 Printer_PrintLabel (self , & result );
907907 Printer_PutStr (self , " = GenLabel();" );
908908 Printer_PutNewline (self );
909- self -> LastLabel = self -> vIp ;
909+ self -> LastLabel = self -> VirualInstructionPointer ;
910910 }
911911 return result ;
912912}
913913
914914static inline BCAddr Printer_BeginJmp (Printer * self )
915915{
916- BCAddr result = {self -> vIp };
916+ BCAddr result = {self -> VirualInstructionPointer };
917917
918918 Printer_PutStr (self , "BCAddr jmp" );
919919 Printer_PutU32 (self , result .addr );
920- self -> vIp += 2 ;
920+ self -> VirualInstructionPointer += 2 ;
921921
922922 Printer_PutStr (self , " = BeginJmp();" );
923923 Printer_PutNewline (self );
@@ -956,14 +956,14 @@ static inline CndJmpBegin Printer_BeginCndJmp(Printer* self, const BCValue* cond
956956{
957957 CndJmpBegin result ;
958958
959- BCAddr at = {self -> vIp };
959+ BCAddr at = {self -> VirualInstructionPointer };
960960 result .at = at ;
961961 result .cond = cast (BCValue * )cond ;
962962 result .ifTrue = ifTrue ;
963963
964964 Printer_PutStr (self , "CndJmpBegin " );
965965 Printer_PrintCndJmp (self , & result );
966- self -> vIp += 2 ;
966+ self -> VirualInstructionPointer += 2 ;
967967
968968 Printer_PutStr (self , " = BeginCndJmp(" );
969969
@@ -1010,7 +1010,7 @@ PR_OP3(Realloc)
10101010
10111011static inline void Printer_ReadI32 (Printer * self , const BCValue * val , const ReadI32_cb_t readCb , void * userCtx )
10121012{
1013- self -> vIp += 2 ;
1013+ self -> VirualInstructionPointer += 2 ;
10141014
10151015 Printer_PutStr (self , "ReadI32(" );
10161016 Printer_PrintBCValue (self , val );
@@ -1054,7 +1054,7 @@ static inline void Printer_init_instance(Printer* instance)
10541054
10551055 instance -> BufferStart = instance -> Buffer = cast (char * )
10561056 instance -> allocMemory (instance -> allocCtx , initialSize , 0 );
1057- instance -> BufferCapacity = initialSize ;
1057+ instance -> BufferSizeLeft = initialSize ;
10581058 instance -> ErrorInfoCount = 0 ;
10591059 instance -> ErrorInfoCapacity = 1024 ;
10601060 instance -> ErrorInfos = cast (ErrorInfo * )
0 commit comments