feat: some behavioral fixes

This commit is contained in:
TopchetoEU 2024-12-28 13:19:35 +02:00
parent 6c8c329992
commit 4c53689d9c
Signed by: topchetoeu
GPG Key ID: 6531B8583E5F6ED4
3 changed files with 16 additions and 2 deletions

View File

@ -30,9 +30,22 @@ public class VariableDeclareNode extends Node {
}
@Override public void compile(CompileResult target, boolean pollute) {
for (var entry : values) {
var index = target.scope.get(entry.var.name, false);
if (entry.value != null) {
entry.value.compile(target, true);
target.add(VariableNode.toSet(target, loc(), entry.var.name, false, true)).setLocation(loc());
}
if (index == null) {
if (entry.value == null) {
target.add(Instruction.globDef(entry.var.name));
}
else {
target.add(Instruction.globSet(entry.var.name, false, true));
}
}
else if (entry.value != null) {
target.add(index.index().toSet(false));
}
}

View File

@ -32,6 +32,7 @@ public class RegexNode extends Node {
var inBrackets = false;
loop: while (true) {
if (i + n >= src.size()) break;
switch (src.at(i + n)) {
case '[':
inBrackets = true;

View File

@ -115,7 +115,7 @@ public abstract class FunctionValue extends ObjectValue {
this.length = length;
this.name = name;
prototype.defineOwnField(null, "constructor", this);
prototype.defineOwnField(null, "constructor", this, true, false, true);
}
}