Browse Source

At least try to report correct line number.

Rafal Kupiec 5 months ago
parent
commit
d4992ff4ba
Signed by: belliash <belliash@codingworkshop.eu.org> GPG Key ID: 4E829243E0CFE6B4
1 changed files with 17 additions and 17 deletions
  1. 17
    17
      engine/compiler.c

+ 17
- 17
engine/compiler.c View File

@@ -1447,7 +1447,7 @@ static sxi32 PH7_CompileConstant(ph7_gen_state *pGen) {
1447 1447
 	/* Compile constant value */
1448 1448
 	rc = PH7_CompileExpr(&(*pGen), 0, 0);
1449 1449
 	/* Emit the done instruction */
1450
-	PH7_VmEmitInstr(pGen->pVm, 0, PH7_OP_DONE, (rc != SXERR_EMPTY ? 1 : 0), 0, 0, 0);
1450
+	PH7_VmEmitInstr(pGen->pVm, nLine, PH7_OP_DONE, (rc != SXERR_EMPTY ? 1 : 0), 0, 0, 0);
1451 1451
 	PH7_VmSetByteCodeContainer(pGen->pVm, pInstrContainer);
1452 1452
 	if(rc == SXERR_ABORT) {
1453 1453
 		/* Don't worry about freeing memory, everything will be released shortly */
@@ -1952,7 +1952,7 @@ static sxi32 PH7_CompileFor(ph7_gen_state *pGen) {
1952 1952
 		/* Expression handler request an operation abort [i.e: Out-of-memory] */
1953 1953
 		return SXERR_ABORT;
1954 1954
 	} else if(rc != SXERR_EMPTY) {
1955
-		PH7_VmEmitInstr(pGen->pVm, 0, PH7_OP_POP, 1, 0, 0, 0);
1955
+		PH7_VmEmitInstr(pGen->pVm, nLine, PH7_OP_POP, 1, 0, 0, 0);
1956 1956
 	}
1957 1957
 	if((pGen->pIn->nType & PH7_TK_SEMI) == 0) {
1958 1958
 		/* Syntax error */
@@ -2044,11 +2044,11 @@ static sxi32 PH7_CompileFor(ph7_gen_state *pGen) {
2044 2044
 			return SXERR_ABORT;
2045 2045
 		} else if(rc != SXERR_EMPTY) {
2046 2046
 			/* Pop operand lvalue */
2047
-			PH7_VmEmitInstr(pGen->pVm, 0, PH7_OP_POP, 1, 0, 0, 0);
2047
+			PH7_VmEmitInstr(pGen->pVm, nLine, PH7_OP_POP, 1, 0, 0, 0);
2048 2048
 		}
2049 2049
 	}
2050 2050
 	/* Emit the unconditional jump to the start of the loop */
2051
-	PH7_VmEmitInstr(pGen->pVm, 0, PH7_OP_JMP, 0, pForBlock->nFirstInstr, 0, 0);
2051
+	PH7_VmEmitInstr(pGen->pVm, nLine, PH7_OP_JMP, 0, pForBlock->nFirstInstr, 0, 0);
2052 2052
 	/* Fix all jumps now the destination is resolved */
2053 2053
 	PH7_GenStateFixJumps(pForBlock, -1, PH7_VmInstrLength(pGen->pVm));
2054 2054
 	/* Release the loop block */
@@ -2464,7 +2464,7 @@ static sxi32 PH7_CompileReturn(ph7_gen_state *pGen) {
2464 2464
 		}
2465 2465
 	}
2466 2466
 	/* Emit the done instruction */
2467
-	PH7_VmEmitInstr(pGen->pVm, 0, PH7_OP_DONE, nRet, 0, 0, 0);
2467
+	PH7_VmEmitInstr(pGen->pVm, pGen->pIn->nLine, PH7_OP_DONE, nRet, 0, 0, 0);
2468 2468
 	return SXRET_OK;
2469 2469
 }
2470 2470
 /*
@@ -2538,7 +2538,7 @@ static sxi32 PH7_CompileStatic(ph7_gen_state *pGen) {
2538 2538
 			return SXERR_ABORT;
2539 2539
 		} else if(rc != SXERR_EMPTY) {
2540 2540
 			/* Emit the POP instruction */
2541
-			PH7_VmEmitInstr(pGen->pVm, 0, PH7_OP_POP, 1, 0, 0, 0);
2541
+			PH7_VmEmitInstr(pGen->pVm, nLine, PH7_OP_POP, 1, 0, 0, 0);
2542 2542
 		}
2543 2543
 		return SXRET_OK;
2544 2544
 	}
@@ -2586,7 +2586,7 @@ static sxi32 PH7_CompileStatic(ph7_gen_state *pGen) {
2586 2586
 		/* Compile the expression */
2587 2587
 		rc = PH7_CompileExpr(&(*pGen), 0, 0);
2588 2588
 		/* Emit the done instruction */
2589
-		PH7_VmEmitInstr(pGen->pVm, 0, PH7_OP_DONE, (rc != SXERR_EMPTY ? 1 : 0), 0, 0, 0);
2589
+		PH7_VmEmitInstr(pGen->pVm, pGen->pIn->nLine, PH7_OP_DONE, (rc != SXERR_EMPTY ? 1 : 0), 0, 0, 0);
2590 2590
 		/* Restore default bytecode container */
2591 2591
 		PH7_VmSetByteCodeContainer(pGen->pVm, pInstrContainer);
2592 2592
 	}
@@ -2627,7 +2627,7 @@ static sxi32 PH7_CompileVar(ph7_gen_state *pGen) {
2627 2627
 		if(rc == SXERR_ABORT) {
2628 2628
 			return SXERR_ABORT;
2629 2629
 		} else if(rc != SXERR_EMPTY) {
2630
-			PH7_VmEmitInstr(pGen->pVm, 0, PH7_OP_POP, 1, 0, 0, 0);
2630
+			PH7_VmEmitInstr(pGen->pVm, nLine, PH7_OP_POP, 1, 0, 0, 0);
2631 2631
 		}
2632 2632
 	}
2633 2633
 	return SXRET_OK;
@@ -2845,7 +2845,7 @@ static sxi32 PH7_GenStateProcessArgValue(ph7_gen_state *pGen, ph7_vm_func_arg *p
2845 2845
 	/* Compile the expression holding the argument value */
2846 2846
 	rc = PH7_CompileExpr(&(*pGen), 0, 0);
2847 2847
 	/* Emit the done instruction */
2848
-	PH7_VmEmitInstr(pGen->pVm, 0, PH7_OP_DONE, (rc != SXERR_EMPTY ? 1 : 0), 0, 0, 0);
2848
+	PH7_VmEmitInstr(pGen->pVm, pGen->pIn->nLine, PH7_OP_DONE, (rc != SXERR_EMPTY ? 1 : 0), 0, 0, 0);
2849 2849
 	PH7_VmSetByteCodeContainer(pGen->pVm, pInstrContainer);
2850 2850
 	RE_SWAP_DELIMITER(pGen);
2851 2851
 	if(rc == SXERR_ABORT) {
@@ -3070,7 +3070,7 @@ static sxi32 PH7_GenStateCompileFuncBody(
3070 3070
 	/* Fix exception jumps now the destination is resolved */
3071 3071
 	PH7_GenStateFixJumps(pGen->pCurrent, PH7_OP_THROW, PH7_VmInstrLength(pGen->pVm));
3072 3072
 	/* Emit the final return if not yet done */
3073
-	PH7_VmEmitInstr(pGen->pVm, 0, PH7_OP_DONE, 0, 0, 0, 0);
3073
+	PH7_VmEmitInstr(pGen->pVm, pGen->pIn->nLine, PH7_OP_DONE, 0, 0, 0, 0);
3074 3074
 	/* Restore the default container */
3075 3075
 	PH7_VmSetByteCodeContainer(pGen->pVm, pInstrContainer);
3076 3076
 	/* Leave function block */
@@ -3368,7 +3368,7 @@ loop:
3368 3368
 		}
3369 3369
 	}
3370 3370
 	/* Emit the done instruction */
3371
-	PH7_VmEmitInstr(pGen->pVm, 0, PH7_OP_DONE, 1, 0, 0, 0);
3371
+	PH7_VmEmitInstr(pGen->pVm, nLine, PH7_OP_DONE, 1, 0, 0, 0);
3372 3372
 	PH7_VmSetByteCodeContainer(pGen->pVm, pInstrContainer);
3373 3373
 	if(rc == SXERR_ABORT) {
3374 3374
 		/* Don't worry about freeing memory, everything will be released shortly */
@@ -3482,7 +3482,7 @@ loop:
3482 3482
 			}
3483 3483
 		}
3484 3484
 		/* Emit the done instruction */
3485
-		PH7_VmEmitInstr(pGen->pVm, 0, PH7_OP_DONE, 1, 0, 0, 0);
3485
+		PH7_VmEmitInstr(pGen->pVm, nLine, PH7_OP_DONE, 1, 0, 0, 0);
3486 3486
 		PH7_VmSetByteCodeContainer(pGen->pVm, pInstrContainer);
3487 3487
 	}
3488 3488
 	/* All done,install the attribute */
@@ -4498,7 +4498,7 @@ static sxi32 PH7_CompileCatch(ph7_gen_state *pGen, ph7_exception *pException) {
4498 4498
 	/* Fix forward jumps now the destination is resolved  */
4499 4499
 	PH7_GenStateFixJumps(pCatch, -1, PH7_VmInstrLength(pGen->pVm));
4500 4500
 	/* Emit the DONE instruction */
4501
-	PH7_VmEmitInstr(pGen->pVm, 0, PH7_OP_DONE, 0, 0, 0, 0);
4501
+	PH7_VmEmitInstr(pGen->pVm, pGen->pIn->nType, PH7_OP_DONE, 0, 0, 0, 0);
4502 4502
 	/* Leave the block */
4503 4503
 	PH7_GenStateLeaveBlock(&(*pGen), 0);
4504 4504
 	/* Restore the default container */
@@ -4670,7 +4670,7 @@ static sxi32 PH7_GenStateCompileCaseExpr(ph7_gen_state *pGen, ph7_case_expr *pEx
4670 4670
 	PH7_VmSetByteCodeContainer(pGen->pVm, &pExpr->aByteCode);
4671 4671
 	rc = PH7_CompileExpr(&(*pGen), 0, 0);
4672 4672
 	/* Emit the done instruction */
4673
-	PH7_VmEmitInstr(pGen->pVm, 0, PH7_OP_DONE, (rc != SXERR_EMPTY ? 1 : 0), 0, 0, 0);
4673
+	PH7_VmEmitInstr(pGen->pVm, pGen->pIn->nLine, PH7_OP_DONE, (rc != SXERR_EMPTY ? 1 : 0), 0, 0, 0);
4674 4674
 	PH7_VmSetByteCodeContainer(pGen->pVm, pInstrContainer);
4675 4675
 	/* Update token stream */
4676 4676
 	pGen->pIn  = pEnd;
@@ -5003,7 +5003,7 @@ static sxi32 PH7_GenStateEmitExprCode(
5003 5003
 			}
5004 5004
 		} else if(pNode->pOp->iOp == EXPR_OP_COMMA) {
5005 5005
 			/* POP the left node */
5006
-			PH7_VmEmitInstr(pGen->pVm, 0, PH7_OP_POP, 1, 0, 0, 0);
5006
+			PH7_VmEmitInstr(pGen->pVm, pInstr->iLine, PH7_OP_POP, 1, 0, 0, 0);
5007 5007
 		}
5008 5008
 	}
5009 5009
 	rc = SXRET_OK;
@@ -5347,7 +5347,7 @@ static sxi32 PH7_GenStateCompileChunk(
5347 5347
 				rc = PH7_CompileExpr(&(*pGen), 0, 0);
5348 5348
 				if(rc != SXERR_EMPTY) {
5349 5349
 					/* Pop l-value */
5350
-					PH7_VmEmitInstr(pGen->pVm, 0, PH7_OP_POP, 1, 0, 0, 0);
5350
+					PH7_VmEmitInstr(pGen->pVm, pGen->pIn->nLine, PH7_OP_POP, 1, 0, 0, 0);
5351 5351
 				}
5352 5352
 			} else {
5353 5353
 				/* Compile the statement */
@@ -5441,7 +5441,7 @@ static sxi32 PH7_CompileScript(
5441 5441
 			rc = PH7_CompileExpr(pGen, 0, 0);
5442 5442
 		}
5443 5443
 		/* Emit the DONE instruction */
5444
-		PH7_VmEmitInstr(pGen->pVm, 0, PH7_OP_DONE, (rc != SXERR_EMPTY ? 1 : 0), 0, 0, 0);
5444
+		PH7_VmEmitInstr(pGen->pVm, pGen->pIn->nLine, PH7_OP_DONE, (rc != SXERR_EMPTY ? 1 : 0), 0, 0, 0);
5445 5445
 		return SXRET_OK;
5446 5446
 	} else if(iFlags & PH7_AERSCRIPT_CHNK) {
5447 5447
 		/* Compile a chunk of code */

Loading…
Cancel
Save