Compare commits

...

3 Commits

Author SHA1 Message Date
b33325a98d fix: clear buffer of line writer file 2024-03-05 17:10:06 +02:00
ccf75d6066 fix: don't use Context.NULL in global scope 2024-03-05 16:51:50 +02:00
662dcc1ac1 bump 2024-03-05 16:30:13 +02:00
5 changed files with 12 additions and 6 deletions

View File

@@ -1,4 +1,4 @@
project_group = me.topchetoeu
project_name = jscript
project_version = 0.8.6-beta
project_version = 0.9.6-beta
main_class = me.topchetoeu.jscript.utils.JScriptRepl

View File

@@ -24,6 +24,11 @@ public class Buffer {
return n;
}
public void clear() {
data = new byte[128];
length = 0;
}
public void append(byte b) {
write(length, new byte[] { b });
}

View File

@@ -24,12 +24,12 @@ public class GlobalScope {
}
public Object define(Context ctx, String name) {
if (Values.hasMember(Context.NULL, obj, name, false)) return name;
obj.defineProperty(Context.NULL, name, null);
if (Values.hasMember(ctx, obj, name, false)) return name;
obj.defineProperty(ctx, name, null);
return name;
}
public void define(Context ctx, String name, Variable val) {
obj.defineProperty(Context.NULL, name,
obj.defineProperty(ctx, name,
new NativeFunction("get " + name, args -> val.get(args.ctx)),
new NativeFunction("set " + name, args -> { val.set(args.ctx, args.get(0)); return null; }),
true, true
@@ -42,7 +42,7 @@ public class GlobalScope {
for (var n : names) define(ctx, n);
}
public void define(Context ctx, boolean readonly, FunctionValue val) {
define(null, val.name, readonly, val);
define(ctx, val.name, readonly, val);
}
public Object get(Context ctx, String name) {

View File

@@ -8,7 +8,7 @@ public class NativeWrapper extends ObjectValue {
@Override
public ObjectValue getPrototype(Context ctx) {
if (prototype == NATIVE_PROTO) return ctx.environment.wrappers.getProto(wrapped.getClass());
if (ctx.environment != null && prototype == NATIVE_PROTO) return ctx.environment.wrappers.getProto(wrapped.getClass());
else return super.getPrototype(ctx);
}

View File

@@ -99,6 +99,7 @@ public interface File {
if (b == '\n') {
try {
writer.writeLine(new String(buff.data()));
buff.clear();
}
catch (IOException e) {
throw new FilesystemException(ErrorReason.UNKNOWN, e.getMessage());