diff --git a/SMILEBASIC/builtinfunctions.d b/SMILEBASIC/builtinfunctions.d index 1df09c4..0e9f2a5 100644 --- a/SMILEBASIC/builtinfunctions.d +++ b/SMILEBASIC/builtinfunctions.d @@ -2645,7 +2645,10 @@ class BuiltinFunction switch (ary.type) { case ValueType.String: - throw new IllegalFunctionCall("NOTIMPL:PUSH string"); + if (ary.stringValue.dimCount != 1) + throw new TypeMismatch("PUSH", 1); + ary.stringValue.push(exp.castString); + break; case ValueType.IntegerArray: if (ary.integerArray.dimCount != 1) throw new TypeMismatch("PUSH", 1); @@ -2678,7 +2681,9 @@ class BuiltinFunction switch (ary.type) { case ValueType.String: - throw new IllegalFunctionCall("NOTIMPL:POP string"); + if (ary.stringValue.dimCount != 1) + throw new TypeMismatch("POP", 1); + return Value(ary.stringValue.pop()); case ValueType.IntegerArray: if (ary.integerArray.dimCount != 1) throw new TypeMismatch("POP", 1); diff --git a/SMILEBASIC/type.d b/SMILEBASIC/type.d index 94cf9c9..83648c3 100644 --- a/SMILEBASIC/type.d +++ b/SMILEBASIC/type.d @@ -61,6 +61,11 @@ struct Value this.type = ValueType.String; stringValue = new Array!wchar(value); } + this(wchar value) + { + this.type = ValueType.String; + stringValue = new Array!wchar([value]); + } this(Array!wchar value) { this.type = ValueType.String; @@ -422,6 +427,15 @@ class Array(T) array ~= v; dim[0]++; } + void push(Array!T v) + { + if (dimCount != 1) + { + throw new TypeMismatch(); + } + array ~= v.array; + dim[0] = cast(int)length; + } T pop() { if (dimCount != 1)