fix: call regex constructor correctly
This commit is contained in:
parent
db241919f2
commit
138baebacb
@ -43,7 +43,7 @@ public class InstructionRunner {
|
|||||||
var callArgs = frame.take(instr.get(0));
|
var callArgs = frame.take(instr.get(0));
|
||||||
var funcObj = frame.pop();
|
var funcObj = frame.pop();
|
||||||
|
|
||||||
frame.push(funcObj.construct(env, callArgs));
|
frame.push(funcObj.constructNoSelf(env, callArgs));
|
||||||
|
|
||||||
frame.codePtr++;
|
frame.codePtr++;
|
||||||
return null;
|
return null;
|
||||||
@ -222,7 +222,10 @@ public class InstructionRunner {
|
|||||||
}
|
}
|
||||||
private static Value execLoadRegEx(Environment env, Instruction instr, Frame frame) {
|
private static Value execLoadRegEx(Environment env, Instruction instr, Frame frame) {
|
||||||
if (env.hasNotNull(Value.REGEX_CONSTR)) {
|
if (env.hasNotNull(Value.REGEX_CONSTR)) {
|
||||||
frame.push(env.get(Value.REGEX_CONSTR).construct(env, instr.get(0), instr.get(1)));
|
frame.push(env.get(Value.REGEX_CONSTR).constructNoSelf(env,
|
||||||
|
StringValue.of(instr.get(0)),
|
||||||
|
StringValue.of(instr.get(1))
|
||||||
|
));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
throw EngineException.ofSyntax("Regex is not supported");
|
throw EngineException.ofSyntax("Regex is not supported");
|
||||||
|
@ -89,7 +89,7 @@ public abstract class Value {
|
|||||||
throw EngineException.ofType("Value is not a constructor");
|
throw EngineException.ofType("Value is not a constructor");
|
||||||
}
|
}
|
||||||
|
|
||||||
public final Value construct(Environment env, Value ...args) {
|
public final Value constructNoSelf(Environment env, Value ...args) {
|
||||||
var res = new ObjectValue();
|
var res = new ObjectValue();
|
||||||
var proto = getMember(env, StringValue.of("prototype"));
|
var proto = getMember(env, StringValue.of("prototype"));
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user