Some tests for PSharp/psharp#2
This commit is contained in:
parent
f8cf602b91
commit
4fa254c4eb
5
.vscode/launch.json
vendored
5
.vscode/launch.json
vendored
@ -9,11 +9,10 @@
|
|||||||
"type": "cppvsdbg",
|
"type": "cppvsdbg",
|
||||||
"request": "launch",
|
"request": "launch",
|
||||||
"program": "${workspaceFolder}/psharp.exe",
|
"program": "${workspaceFolder}/psharp.exe",
|
||||||
"args": [],
|
"args": [ "test/main.php" ],
|
||||||
"stopAtEntry": false,
|
"stopAtEntry": false,
|
||||||
"cwd": "${workspaceFolder}",
|
"cwd": "${workspaceFolder}",
|
||||||
"environment": [],
|
"environment": []
|
||||||
"externalConsole": true
|
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
5
.vscode/settings.json
vendored
5
.vscode/settings.json
vendored
@ -36,5 +36,8 @@
|
|||||||
"cSpell.userWords": [
|
"cSpell.userWords": [
|
||||||
"belliash",
|
"belliash",
|
||||||
"codingworkshop",
|
"codingworkshop",
|
||||||
]
|
],
|
||||||
|
"files.associations": {
|
||||||
|
"ph7int.h": "c"
|
||||||
|
}
|
||||||
}
|
}
|
@ -179,6 +179,10 @@ int main(int argc, char **argv) {
|
|||||||
Output_Consumer, /* Output Consumer callback */
|
Output_Consumer, /* Output Consumer callback */
|
||||||
0 /* Callback private data */
|
0 /* Callback private data */
|
||||||
);
|
);
|
||||||
|
rc = ph7_vm_config(pVm,
|
||||||
|
PH7_VM_CONFIG_IMPORT_PATH,
|
||||||
|
"test"
|
||||||
|
);
|
||||||
if(rc != PH7_OK) {
|
if(rc != PH7_OK) {
|
||||||
Fatal("Error while installing the VM output consumer callback");
|
Fatal("Error while installing the VM output consumer callback");
|
||||||
}
|
}
|
||||||
|
5
test/a.php
Normal file
5
test/a.php
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
echo '[a] file: ' . __FILE__ . ', line: ' . __LINE__ . ', dir: ' . __DIR__ . PHP_EOL;
|
||||||
|
require_once 'b.php';
|
||||||
|
echo '[a] file: ' . __FILE__ . ', line: ' . __LINE__ . ', dir: ' . __DIR__ . PHP_EOL;
|
6
test/b.php
Normal file
6
test/b.php
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
|
||||||
|
echo '[b] file: ' . __FILE__ . ', line: ' . __LINE__ . ', dir: ' . __DIR__ . PHP_EOL;
|
||||||
|
require_once 'c.php';
|
||||||
|
echo '[b] file: ' . __FILE__ . ', line: ' . __LINE__ . ', dir: ' . __DIR__ . PHP_EOL;
|
7
test/c.php
Normal file
7
test/c.php
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
echo '[c] file: ' . __FILE__ . ', line: ' . __LINE__ . ', dir: ' . __DIR__ . PHP_EOL;
|
||||||
|
require_once 'more/a.php';
|
||||||
|
echo '[c] file: ' . __FILE__ . ', line: ' . __LINE__ . ', dir: ' . __DIR__ . PHP_EOL;
|
4
test/main.php
Normal file
4
test/main.php
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
<?php
|
||||||
|
echo '[main] file: ' . __FILE__ . ', line: ' . __LINE__ . ', dir: ' . __DIR__ . PHP_EOL;
|
||||||
|
require_once 'a.php';
|
||||||
|
echo '[main] file: ' . __FILE__ . ', line: ' . __LINE__ . ', dir: ' . __DIR__ . PHP_EOL;
|
8
test/more/a.php
Normal file
8
test/more/a.php
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
echo '[more/a] file: ' . __FILE__ . ', line: ' . __LINE__ . ', dir: ' . __DIR__ . PHP_EOL;
|
||||||
|
require_once 'b.php';
|
||||||
|
echo '[more/a] file: ' . __FILE__ . ', line: ' . __LINE__ . ', dir: ' . __DIR__ . PHP_EOL;
|
2
vfs.c
2
vfs.c
@ -2907,7 +2907,7 @@ PH7_PRIVATE void *PH7_StreamOpenHandle(ph7_vm *pVm, const ph7_io_stream *pStream
|
|||||||
if(rc == PH7_OK) {
|
if(rc == PH7_OK) {
|
||||||
if(bPushInclude) {
|
if(bPushInclude) {
|
||||||
/* Mark as included */
|
/* Mark as included */
|
||||||
PH7_VmPushFilePath(pVm, (const char *)SyBlobData(&sWorker), SyBlobLength(&sWorker), FALSE, pNew);
|
//PH7_VmPushFilePath(pVm, (const char *)SyBlobData(&sWorker), SyBlobLength(&sWorker), FALSE, pNew);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
7
vm.c
7
vm.c
@ -10489,6 +10489,7 @@ static int VmIsIncludedFile(ph7_vm *pVm, SyString *pFile) {
|
|||||||
}
|
}
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
#include <stdio.h>
|
||||||
/*
|
/*
|
||||||
* Push a file path in the appropriate VM container.
|
* Push a file path in the appropriate VM container.
|
||||||
*/
|
*/
|
||||||
@ -10532,6 +10533,7 @@ PH7_PRIVATE sxi32 PH7_VmPushFilePath(ph7_vm *pVm, const char *zPath, int nLen, s
|
|||||||
/* Already included */
|
/* Already included */
|
||||||
*pNew = 0;
|
*pNew = 0;
|
||||||
} else {
|
} else {
|
||||||
|
//printf("its not new\n");
|
||||||
/* Insert in the corresponding container */
|
/* Insert in the corresponding container */
|
||||||
rc = SySetPut(&pVm->aIncluded, (const void *)&sPath);
|
rc = SySetPut(&pVm->aIncluded, (const void *)&sPath);
|
||||||
if(rc != SXRET_OK) {
|
if(rc != SXRET_OK) {
|
||||||
@ -10541,6 +10543,7 @@ PH7_PRIVATE sxi32 PH7_VmPushFilePath(ph7_vm *pVm, const char *zPath, int nLen, s
|
|||||||
*pNew = 1;
|
*pNew = 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
printf("push file = %s\n", sPath.zString);
|
||||||
SySetPut(&pVm->aFiles, (const void *)&sPath);
|
SySetPut(&pVm->aFiles, (const void *)&sPath);
|
||||||
return SXRET_OK;
|
return SXRET_OK;
|
||||||
}
|
}
|
||||||
@ -10578,6 +10581,7 @@ static sxi32 VmExecIncludedFile(
|
|||||||
* Open the file or the URL [i.e: http://ph7.symisc.net/example/hello.php"]
|
* Open the file or the URL [i.e: http://ph7.symisc.net/example/hello.php"]
|
||||||
* in a read-only mode.
|
* in a read-only mode.
|
||||||
*/
|
*/
|
||||||
|
printf("eval file: %s\n", pPath->zString);
|
||||||
pHandle = PH7_StreamOpenHandle(pVm, pStream, pPath->zString, PH7_IO_OPEN_RDONLY, TRUE, 0, TRUE, &isNew);
|
pHandle = PH7_StreamOpenHandle(pVm, pStream, pPath->zString, PH7_IO_OPEN_RDONLY, TRUE, 0, TRUE, &isNew);
|
||||||
if(pHandle == 0) {
|
if(pHandle == 0) {
|
||||||
return SXERR_IO;
|
return SXERR_IO;
|
||||||
@ -10596,8 +10600,9 @@ static sxi32 VmExecIncludedFile(
|
|||||||
VmEvalChunk(pCtx->pVm, &(*pCtx), &sScript, 0, TRUE);
|
VmEvalChunk(pCtx->pVm, &(*pCtx), &sScript, 0, TRUE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
printf("pop file = %s\n", ((SyString*)SySetPop(&pVm->aFiles))->zString);
|
||||||
/* Pop from the set of included file */
|
/* Pop from the set of included file */
|
||||||
(void)SySetPop(&pVm->aFiles);
|
//(void)SySetPop(&pVm->aFiles);
|
||||||
/* Close the handle */
|
/* Close the handle */
|
||||||
PH7_StreamCloseHandle(pStream, pHandle);
|
PH7_StreamCloseHandle(pStream, pHandle);
|
||||||
/* Release the working buffer */
|
/* Release the working buffer */
|
||||||
|
Loading…
Reference in New Issue
Block a user