@@ -72,14 +72,14 @@ void runtimeError(VM* pvm, const char* format, ...) {
7272 reportRuntimeError (pvm -> source , line , message );
7373
7474 for (int i = pvm -> frameCount - 1 ; i >= 0 ; i -- ) {
75- CallFrame * frame = & pvm -> frames [i ];
76- ObjFunction * function = frame -> closure -> function ;
77- size_t instruction = frame -> ip - function -> chunk .code - 1 ;
78- fprintf (stderr , " [line %d] in " , function -> chunk .lines [instruction ]);
79- if (function -> name == NULL ) {
75+ CallFrame * f = & pvm -> frames [i ];
76+ ObjFunction * fn = f -> closure -> function ;
77+ size_t inst = f -> ip - fn -> chunk .code - 1 ;
78+ fprintf (stderr , " [line %d] in " , fn -> chunk .lines [inst ]);
79+ if (fn -> name == NULL ) {
8080 fprintf (stderr , "script\n" );
8181 } else {
82- fprintf (stderr , "%s()\n" , function -> name -> chars );
82+ fprintf (stderr , "%s()\n" , fn -> name -> chars );
8383 }
8484 }
8585
@@ -113,9 +113,9 @@ bool isFalsey(Value value) {
113113 return IS_NULL (value ) || (IS_BOOL (value ) && !AS_BOOL (value ));
114114}
115115
116- static bool performTensorArithmetic (VM * vm , char op ) {
117- Value bVal = peek (vm , 0 );
118- Value aVal = peek (vm , 1 );
116+ static bool performTensorArithmetic (VM * pvm , char op ) {
117+ Value bVal = peek (pvm , 0 );
118+ Value aVal = peek (pvm , 1 );
119119
120120 // Case 1: Tensor op Tensor
121121 if (IS_TENSOR (aVal ) && IS_TENSOR (bVal )) {
@@ -124,23 +124,23 @@ static bool performTensorArithmetic(VM* vm, char op) {
124124
125125 // Element-wise arithmetic requires matching size
126126 if (a -> size != b -> size ) {
127- runtimeError (vm , "Tensor size mismatch: %d vs %d." , a -> size , b -> size );
127+ runtimeError (pvm , "Tensor size mismatch: %d vs %d." , a -> size , b -> size );
128128 return true;
129129 }
130130
131131 if (a -> dimCount != b -> dimCount ) {
132- runtimeError (vm , "Tensor rank mismatch." );
132+ runtimeError (pvm , "Tensor rank mismatch." );
133133 return true;
134134 }
135135 for (int i = 0 ; i < a -> dimCount ; i ++ ) {
136136 if (a -> dims [i ] != b -> dims [i ]) {
137- runtimeError (vm , "Tensor dimension mismatch at axis %d: %d vs %d." , i , a -> dims [i ], b -> dims [i ]);
137+ runtimeError (pvm , "Tensor dimension mismatch at axis %d: %d vs %d." , i , a -> dims [i ], b -> dims [i ]);
138138 return true;
139139 }
140140 }
141141
142142 ObjTensor * res = newTensor (a -> dimCount , a -> dims , NULL );
143- push (vm , OBJ_VAL (res ));
143+ push (pvm , OBJ_VAL (res ));
144144
145145 for (int i = 0 ; i < a -> size ; i ++ ) {
146146 double vA = a -> data [i ];
@@ -153,10 +153,10 @@ static bool performTensorArithmetic(VM* vm, char op) {
153153 }
154154 }
155155
156- Value resVal = pop (vm );
157- pop (vm ); // b
158- pop (vm ); // a
159- push (vm , resVal );
156+ Value resVal = pop (pvm );
157+ pop (pvm ); // b
158+ pop (pvm ); // a
159+ push (pvm , resVal );
160160 return true;
161161 }
162162
@@ -166,7 +166,7 @@ static bool performTensorArithmetic(VM* vm, char op) {
166166 double b = AS_NUMBER (bVal );
167167
168168 ObjTensor * res = newTensor (a -> dimCount , a -> dims , NULL );
169- push (vm , OBJ_VAL (res ));
169+ push (pvm , OBJ_VAL (res ));
170170
171171 for (int i = 0 ; i < a -> size ; i ++ ) {
172172 double vA = a -> data [i ];
@@ -177,8 +177,8 @@ static bool performTensorArithmetic(VM* vm, char op) {
177177 case '/' : res -> data [i ] = vA / b ; break ;
178178 }
179179 }
180- Value resVal = pop (vm );
181- pop (vm ); pop (vm ); push (vm , resVal );
180+ Value resVal = pop (pvm );
181+ pop (pvm ); pop (pvm ); push (pvm , resVal );
182182 return true;
183183 }
184184
@@ -188,7 +188,7 @@ static bool performTensorArithmetic(VM* vm, char op) {
188188 ObjTensor * b = AS_TENSOR (bVal );
189189
190190 ObjTensor * res = newTensor (b -> dimCount , b -> dims , NULL );
191- push (vm , OBJ_VAL (res ));
191+ push (pvm , OBJ_VAL (res ));
192192
193193 for (int i = 0 ; i < b -> size ; i ++ ) {
194194 double vB = b -> data [i ];
@@ -199,8 +199,8 @@ static bool performTensorArithmetic(VM* vm, char op) {
199199 case '/' : res -> data [i ] = a / vB ; break ;
200200 }
201201 }
202- Value resVal = pop (vm );
203- pop (vm ); pop (vm ); push (vm , resVal );
202+ Value resVal = pop (pvm );
203+ pop (pvm ); pop (pvm ); push (pvm , resVal );
204204 return true;
205205 }
206206
@@ -1730,7 +1730,7 @@ static InterpretResult run(VM* vm) {
17301730 ObjTensor * tensor = newTensor (dimCount , dims , NULL );
17311731 if (elementCount == 0 && totalSize > 0 ) {
17321732 memset (tensor -> data , 0 , totalSize * sizeof (double ));
1733- } else if (elementCount == totalSize ) {
1733+ } else if (elementCount == ( uint32_t ) totalSize ) {
17341734 // Pop elements (reverse order as they were pushed in order, stack top is last)
17351735 for (int i = totalSize - 1 ; i >= 0 ; i -- ) {
17361736 Value val = pop (vm );
0 commit comments