Make constant declarations local.
All checks were successful
The build was successful.

There are several changes in this commit:
 * first of all constants declared by 'const' statement should be local (declared in current scope / frame),
 * constants are declared by using OP_DECLARE instruction,
 * OP_LOADC browses both global and local constants container,
 * PH7_VmRegisterConstant() allows both global and local declarations.
Since this commit, there are 3 kinds of constants:
 1) global
 2) local (in loop, closure, method)
 3) class members.
Actually there is no way to declare a global constant except the built-in constants.
This commit is contained in:
2019-05-04 13:45:32 +02:00
parent 90b2da7c56
commit ab8bf48485
4 changed files with 111 additions and 67 deletions

View File

@@ -1064,7 +1064,7 @@ int ph7_create_constant(ph7_vm *pVm, const char *zName, void (*xExpand)(ph7_valu
}
#endif
/* Perform the registration */
rc = PH7_VmRegisterConstant(&(*pVm), &sName, xExpand, pUserData);
rc = PH7_VmRegisterConstant(&(*pVm), &sName, xExpand, pUserData, TRUE);
#if defined(PH7_ENABLE_THREADS)
/* Leave VM mutex */
SyMutexLeave(sMPGlobal.pMutexMethods, pVm->pMutex); /* NO-OP if sMPGlobal.nThreadingLevel != PH7_THREAD_LEVEL_MULTI */