mirror of
https://github.com/curioustorvald/tsvm.git
synced 2026-03-07 19:51:51 +09:00
basic: on DEFUN, unknown variables will be regarded as a global
This commit is contained in:
@@ -1995,12 +1995,11 @@ bF._executeSyntaxTree = function(lnum, syntaxTree, recDepth) {
|
||||
bF._recurseApplyAST(exprTree, (it) => {
|
||||
if (it.astType == "lit") {
|
||||
// check if parametre name is valid
|
||||
if (defunRenamingMap[it.astValue] === undefined) {
|
||||
throw lang.refError(lnum, it.astValue);
|
||||
// if the name is invalid, regard it as a global variable (i.e. do nothing)
|
||||
if (defunRenamingMap[it.astValue] !== undefined) {
|
||||
it.astType = "defun_args";
|
||||
it.astValue = defunRenamingMap[it.astValue];
|
||||
}
|
||||
|
||||
it.astType = "defun_args";
|
||||
it.astValue = defunRenamingMap[it.astValue];
|
||||
}
|
||||
// decrease the recursion counter while we're looping
|
||||
it.astDepth -= 2;
|
||||
|
||||
3
assets/emit.bas
Normal file
3
assets/emit.bas
Normal file
@@ -0,0 +1,3 @@
|
||||
10 for k=0 to 1024
|
||||
20 emit(k mod 1024;)
|
||||
30 next
|
||||
4
assets/facrec.bas
Normal file
4
assets/facrec.bas
Normal file
@@ -0,0 +1,4 @@
|
||||
10 DEFUN FAC(N)=IF N==0 THEN 1 ELSE N*FAC(N-1)
|
||||
20 FOR K=1 TO 6
|
||||
30 PRINT FAC(K)
|
||||
40 NEXT
|
||||
Reference in New Issue
Block a user