1
0

Implement PUSH/POP STR$

This commit is contained in:
otya128
2016-12-17 16:07:03 +09:00
parent ffd8743ed6
commit 5c594daba7
2 changed files with 21 additions and 2 deletions

View File

@@ -2645,7 +2645,10 @@ class BuiltinFunction
switch (ary.type) switch (ary.type)
{ {
case ValueType.String: 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: case ValueType.IntegerArray:
if (ary.integerArray.dimCount != 1) if (ary.integerArray.dimCount != 1)
throw new TypeMismatch("PUSH", 1); throw new TypeMismatch("PUSH", 1);
@@ -2678,7 +2681,9 @@ class BuiltinFunction
switch (ary.type) switch (ary.type)
{ {
case ValueType.String: 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: case ValueType.IntegerArray:
if (ary.integerArray.dimCount != 1) if (ary.integerArray.dimCount != 1)
throw new TypeMismatch("POP", 1); throw new TypeMismatch("POP", 1);

View File

@@ -61,6 +61,11 @@ struct Value
this.type = ValueType.String; this.type = ValueType.String;
stringValue = new Array!wchar(value); stringValue = new Array!wchar(value);
} }
this(wchar value)
{
this.type = ValueType.String;
stringValue = new Array!wchar([value]);
}
this(Array!wchar value) this(Array!wchar value)
{ {
this.type = ValueType.String; this.type = ValueType.String;
@@ -422,6 +427,15 @@ class Array(T)
array ~= v; array ~= v;
dim[0]++; dim[0]++;
} }
void push(Array!T v)
{
if (dimCount != 1)
{
throw new TypeMismatch();
}
array ~= v.array;
dim[0] = cast(int)length;
}
T pop() T pop()
{ {
if (dimCount != 1) if (dimCount != 1)