wstring => Array!wchar
This commit is contained in:
@@ -325,7 +325,7 @@ class PrintCode : Code
|
|||||||
case ValueType.String:
|
case ValueType.String:
|
||||||
//write(arg.stringValue);
|
//write(arg.stringValue);
|
||||||
if(vm.petitcomputer)
|
if(vm.petitcomputer)
|
||||||
vm.petitcomputer.console.printString(arg.stringValue);
|
vm.petitcomputer.console.printString(arg.castDString);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
//type mismatch
|
//type mismatch
|
||||||
@@ -556,10 +556,10 @@ class Operate : Code
|
|||||||
}
|
}
|
||||||
if(l.type == ValueType.String)
|
if(l.type == ValueType.String)
|
||||||
{
|
{
|
||||||
wstring ls = l.stringValue;
|
wchar[] ls = l.stringValue.array;
|
||||||
if(r.type == ValueType.String)
|
if(r.type == ValueType.String)
|
||||||
{
|
{
|
||||||
wstring rs = r.stringValue;
|
wchar[] rs = r.stringValue.array;
|
||||||
switch(operator)
|
switch(operator)
|
||||||
{
|
{
|
||||||
case TokenType.Plus:
|
case TokenType.Plus:
|
||||||
@@ -866,11 +866,11 @@ class GotoExpr : Code
|
|||||||
int pc;
|
int pc;
|
||||||
if (sc && sc.func)
|
if (sc && sc.func)
|
||||||
{
|
{
|
||||||
pc = sc.func.label.get(label.castString, int.min);
|
pc = sc.func.label.get(label.castDString, int.min);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
pc = vm.currentSlot.globalLabel.get(label.castString, int.min);
|
pc = vm.currentSlot.globalLabel.get(label.castDString, int.min);
|
||||||
}
|
}
|
||||||
if (pc == int.min)
|
if (pc == int.min)
|
||||||
{
|
{
|
||||||
@@ -931,16 +931,16 @@ class GosubExpr : Code
|
|||||||
vm.pop(label);
|
vm.pop(label);
|
||||||
if(label.isString)
|
if(label.isString)
|
||||||
{
|
{
|
||||||
vm.pushBackTrace(label.castString);
|
vm.pushBackTrace(label.castDString);
|
||||||
vm.pushpc;
|
vm.pushpc;
|
||||||
int pc;
|
int pc;
|
||||||
if (sc && sc.func)
|
if (sc && sc.func)
|
||||||
{
|
{
|
||||||
pc = sc.func.label.get(label.castString, int.min);
|
pc = sc.func.label.get(label.castDString, int.min);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
pc = vm.currentSlot.globalLabel.get(label.castString, int.min);
|
pc = vm.currentSlot.globalLabel.get(label.castDString, int.min);
|
||||||
}
|
}
|
||||||
if (pc == int.min)
|
if (pc == int.min)
|
||||||
{
|
{
|
||||||
@@ -1040,7 +1040,7 @@ class NewArray : Code
|
|||||||
break;
|
break;
|
||||||
case ValueType.String:
|
case ValueType.String:
|
||||||
array.type = ValueType.StringArray;
|
array.type = ValueType.StringArray;
|
||||||
array.stringArray = new Array!wstring(dim);
|
array.stringArray = new Array!(Array!wchar)(dim);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
throw new TypeMismatch();
|
throw new TypeMismatch();
|
||||||
@@ -1434,7 +1434,7 @@ class CallFunctionS : Code
|
|||||||
{
|
{
|
||||||
throw new TypeMismatch();
|
throw new TypeMismatch();
|
||||||
}
|
}
|
||||||
auto name = vname.castString.toUpper;
|
auto name = vname.castDString.toUpper;
|
||||||
Function func = vm.currentSlot.functions.get(name, null);
|
Function func = vm.currentSlot.functions.get(name, null);
|
||||||
if(!func)
|
if(!func)
|
||||||
{
|
{
|
||||||
@@ -1748,13 +1748,13 @@ class RestoreExprCode : Code
|
|||||||
vm.pop(label);
|
vm.pop(label);
|
||||||
if(!label.isString)
|
if(!label.isString)
|
||||||
throw new TypeMismatch();
|
throw new TypeMismatch();
|
||||||
if (label.stringValue in datatable.label)
|
if (label.castDString in datatable.label)
|
||||||
{
|
{
|
||||||
datatable.dataIndex = datatable.label[label.stringValue];
|
datatable.dataIndex = datatable.label[label.castDString];
|
||||||
}
|
}
|
||||||
else if (label.stringValue in vm.currentSlot.globalDataTable.label)
|
else if (label.castDString in vm.currentSlot.globalDataTable.label)
|
||||||
{
|
{
|
||||||
datatable.dataIndex = vm.currentSlot.globalDataTable.label[label.stringValue];
|
datatable.dataIndex = vm.currentSlot.globalDataTable.label[label.castDString];
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -1875,7 +1875,7 @@ class IncRef : Code
|
|||||||
}
|
}
|
||||||
if (refv.reference.isString && v.isString)
|
if (refv.reference.isString && v.isString)
|
||||||
{
|
{
|
||||||
refv.reference.stringValue~= v.stringValue;
|
refv.reference.stringValue.append(v.stringValue);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1905,7 +1905,7 @@ class IncRef : Code
|
|||||||
|
|
||||||
class SwapCode : Code
|
class SwapCode : Code
|
||||||
{
|
{
|
||||||
void getPointer(ref Value v, out int* ip, out double* dp, out wstring* sp)
|
void getPointer(ref Value v, out int* ip, out double* dp, out Array!(wchar)* sp)
|
||||||
{
|
{
|
||||||
ip = null;
|
ip = null;
|
||||||
dp = null;
|
dp = null;
|
||||||
@@ -1952,7 +1952,7 @@ class SwapCode : Code
|
|||||||
vm.pop(refitem1);
|
vm.pop(refitem1);
|
||||||
double* dp1, dp2;
|
double* dp1, dp2;
|
||||||
int* ip1, ip2;
|
int* ip1, ip2;
|
||||||
wstring* sp1, sp2;
|
Array!(wchar)* sp1, sp2;
|
||||||
getPointer(refitem1, ip1, dp1, sp1);
|
getPointer(refitem1, ip1, dp1, sp1);
|
||||||
getPointer(refitem2, ip2, dp2, sp2);
|
getPointer(refitem2, ip2, dp2, sp2);
|
||||||
if ((sp1 && (dp2 || ip2)) || (sp2 && (dp1 || ip1)))
|
if ((sp1 && (dp2 || ip2)) || (sp2 && (dp1 || ip1)))
|
||||||
@@ -1999,7 +1999,7 @@ class PushVarRefExpression : Code
|
|||||||
{
|
{
|
||||||
Value valv;
|
Value valv;
|
||||||
vm.pop(valv);
|
vm.pop(valv);
|
||||||
auto name = valv.castString;
|
auto name = valv.castDString;
|
||||||
|
|
||||||
VMVariable vmv = VMVariable(int.min);
|
VMVariable vmv = VMVariable(int.min);
|
||||||
if (sc.func)
|
if (sc.func)
|
||||||
@@ -2031,7 +2031,7 @@ class PushVarExpression : Code
|
|||||||
{
|
{
|
||||||
Value valv;
|
Value valv;
|
||||||
vm.pop(valv);
|
vm.pop(valv);
|
||||||
auto name = valv.castString;
|
auto name = valv.castDString;
|
||||||
|
|
||||||
VMVariable vmv = VMVariable(int.min);
|
VMVariable vmv = VMVariable(int.min);
|
||||||
if (sc.func)
|
if (sc.func)
|
||||||
@@ -2065,7 +2065,7 @@ class PopVarExpression : Code
|
|||||||
vm.pop(valv);
|
vm.pop(valv);
|
||||||
Value expr;
|
Value expr;
|
||||||
vm.pop(expr);
|
vm.pop(expr);
|
||||||
auto name = valv.castString;
|
auto name = valv.castDString;
|
||||||
|
|
||||||
VMVariable vmv = VMVariable(int.min);
|
VMVariable vmv = VMVariable(int.min);
|
||||||
if (sc.func)
|
if (sc.func)
|
||||||
|
|||||||
@@ -527,7 +527,7 @@ class BuiltinFunction
|
|||||||
}
|
}
|
||||||
else if (str.isString)
|
else if (str.isString)
|
||||||
{
|
{
|
||||||
p.graphic.gputchr(p.graphic.useGRP, x, y, str.castString, scalex, scaley, color);
|
p.graphic.gputchr(p.graphic.useGRP, x, y, str.castDString, scalex, scaley, color);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -1181,11 +1181,11 @@ class BuiltinFunction
|
|||||||
if(alen.isNumber)
|
if(alen.isNumber)
|
||||||
{
|
{
|
||||||
len = alen.castInteger;
|
len = alen.castInteger;
|
||||||
replace = areplace.castString;
|
replace = areplace.castDString;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
replace = alen.castString;
|
replace = alen.castDString;
|
||||||
//省略されたらi以降の全文字を置換
|
//省略されたらi以降の全文字を置換
|
||||||
return str[0..i] ~ replace;
|
return str[0..i] ~ replace;
|
||||||
}
|
}
|
||||||
@@ -1203,13 +1203,13 @@ class BuiltinFunction
|
|||||||
if(!vstr2.isDefault)
|
if(!vstr2.isDefault)
|
||||||
{
|
{
|
||||||
start = vstart.castInteger;
|
start = vstart.castInteger;
|
||||||
str1 = vstr1.castString;
|
str1 = vstr1.castDString;
|
||||||
str2 = cast(wstring)vstr2;
|
str2 = cast(wstring)vstr2;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
str1 = vstart.castString;
|
str1 = vstart.castDString;
|
||||||
str2 = vstr1.castString;
|
str2 = vstr1.castDString;
|
||||||
}
|
}
|
||||||
return cast(int)(str1[start..$].indexOf(str2, CaseSensitive.no));
|
return cast(int)(str1[start..$].indexOf(str2, CaseSensitive.no));
|
||||||
}
|
}
|
||||||
@@ -1383,9 +1383,9 @@ class BuiltinFunction
|
|||||||
{
|
{
|
||||||
VM vm = p.vm;
|
VM vm = p.vm;
|
||||||
vm.pushDataIndex();
|
vm.pushDataIndex();
|
||||||
vm.restoreData(args[2].castString);
|
vm.restoreData(args[2].castDString);
|
||||||
int keyframe = vm.readData.castInteger;
|
int keyframe = vm.readData.castInteger;
|
||||||
auto target = p.sprite.getSpriteAnimTarget(args[1].castString);
|
auto target = p.sprite.getSpriteAnimTarget(args[1].castDString);
|
||||||
int item = 2;
|
int item = 2;
|
||||||
if((target & 7) == SpriteAnimTarget.XY || (target & 7) == SpriteAnimTarget.UV) item++;
|
if((target & 7) == SpriteAnimTarget.XY || (target & 7) == SpriteAnimTarget.UV) item++;
|
||||||
animdata = new double[item * keyframe + 1];
|
animdata = new double[item * keyframe + 1];
|
||||||
@@ -1412,7 +1412,7 @@ class BuiltinFunction
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(args[1].isString)
|
if(args[1].isString)
|
||||||
p.sprite.spanim(no, args[1].castString, animdata);
|
p.sprite.spanim(no, args[1].castDString, animdata);
|
||||||
if(args[1].isNumber)
|
if(args[1].isNumber)
|
||||||
p.sprite.spanim(no, cast(SpriteAnimTarget)(args[1].castInteger), animdata);
|
p.sprite.spanim(no, cast(SpriteAnimTarget)(args[1].castInteger), animdata);
|
||||||
}
|
}
|
||||||
@@ -1440,7 +1440,7 @@ class BuiltinFunction
|
|||||||
{
|
{
|
||||||
VM vm = p.vm;
|
VM vm = p.vm;
|
||||||
vm.pushDataIndex();
|
vm.pushDataIndex();
|
||||||
vm.restoreData(va_args[0].castString);
|
vm.restoreData(va_args[0].castDString);
|
||||||
auto count = vm.readData().castInteger;//読み込むスプライト数
|
auto count = vm.readData().castInteger;//読み込むスプライト数
|
||||||
int defno = 0;//?
|
int defno = 0;//?
|
||||||
for(int i = 0; i < count; i++)
|
for(int i = 0; i < count; i++)
|
||||||
@@ -1614,7 +1614,7 @@ class BuiltinFunction
|
|||||||
{
|
{
|
||||||
alias retro!(Value[]) VaArgs;
|
alias retro!(Value[]) VaArgs;
|
||||||
auto args = retro(va_args);
|
auto args = retro(va_args);
|
||||||
auto format = args[0].castString;
|
auto format = args[0].castDString;
|
||||||
import std.array : appender;
|
import std.array : appender;
|
||||||
import std.format;
|
import std.format;
|
||||||
FixedBuffer!(wchar, 1024) buffer;//String too long
|
FixedBuffer!(wchar, 1024) buffer;//String too long
|
||||||
@@ -1962,7 +1962,7 @@ class BuiltinFunction
|
|||||||
|
|
||||||
//DATAから
|
//DATAから
|
||||||
VM vm = p.vm;
|
VM vm = p.vm;
|
||||||
vm.restoreData(args[sourceArrayIndex].castString);
|
vm.restoreData(args[sourceArrayIndex].castDString);
|
||||||
for(int i = 0; i < len; i++)
|
for(int i = 0; i < len; i++)
|
||||||
{
|
{
|
||||||
Value data = vm.readData();
|
Value data = vm.readData();
|
||||||
@@ -2103,9 +2103,9 @@ class BuiltinFunction
|
|||||||
}
|
}
|
||||||
throw new CantUseInProgram("PROJECT");
|
throw new CantUseInProgram("PROJECT");
|
||||||
}
|
}
|
||||||
static void PROJECT(PetitComputer p, out wstring name)
|
static void PROJECT(PetitComputer p, out Array!wchar name)
|
||||||
{
|
{
|
||||||
name = p.currentProject;
|
name = new Array!wchar(cast(wchar[])p.currentProject.dup);
|
||||||
}
|
}
|
||||||
//FILES TYPE$
|
//FILES TYPE$
|
||||||
//((TXT|DAT):)?\w+/?
|
//((TXT|DAT):)?\w+/?
|
||||||
@@ -2215,7 +2215,7 @@ class BuiltinFunction
|
|||||||
{
|
{
|
||||||
int[] integerArray;
|
int[] integerArray;
|
||||||
double[] doubleArray;
|
double[] doubleArray;
|
||||||
wstring[] stringArray;
|
Array!wchar[] stringArray;
|
||||||
}
|
}
|
||||||
this(ref Value v)
|
this(ref Value v)
|
||||||
{
|
{
|
||||||
@@ -2455,7 +2455,7 @@ class BuiltinFunction
|
|||||||
|
|
||||||
int[] iarray;
|
int[] iarray;
|
||||||
double[] darray;
|
double[] darray;
|
||||||
wstring[] sarray;
|
Array!wchar[] sarray;
|
||||||
if (args[0].type == ValueType.IntegerArray)
|
if (args[0].type == ValueType.IntegerArray)
|
||||||
{
|
{
|
||||||
iarray = args[0].integerArray.array[start..start + count];
|
iarray = args[0].integerArray.array[start..start + count];
|
||||||
@@ -2466,7 +2466,7 @@ class BuiltinFunction
|
|||||||
}
|
}
|
||||||
if (args[0].type == ValueType.StringArray)
|
if (args[0].type == ValueType.StringArray)
|
||||||
{
|
{
|
||||||
sarray = args[0].stringArray.array[start..start + count];
|
sarray = args[0].stringArray.array[start..start + count].array;
|
||||||
}
|
}
|
||||||
if (args.length > 1)
|
if (args.length > 1)
|
||||||
{
|
{
|
||||||
@@ -2510,7 +2510,7 @@ class BuiltinFunction
|
|||||||
|
|
||||||
int[] iarray;
|
int[] iarray;
|
||||||
double[] darray;
|
double[] darray;
|
||||||
wstring[] sarray;
|
Array!wchar[] sarray;
|
||||||
if (args[0].type == ValueType.IntegerArray)
|
if (args[0].type == ValueType.IntegerArray)
|
||||||
{
|
{
|
||||||
iarray = args[0].integerArray.array[start..start + count];
|
iarray = args[0].integerArray.array[start..start + count];
|
||||||
@@ -2521,7 +2521,7 @@ class BuiltinFunction
|
|||||||
}
|
}
|
||||||
if (args[0].type == ValueType.StringArray)
|
if (args[0].type == ValueType.StringArray)
|
||||||
{
|
{
|
||||||
sarray = args[0].stringArray.array[start..start + count];
|
sarray = args[0].stringArray.array[start..start + count].array;
|
||||||
}
|
}
|
||||||
if (args.length > 1)
|
if (args.length > 1)
|
||||||
{
|
{
|
||||||
@@ -2737,7 +2737,7 @@ class BuiltinFunction
|
|||||||
alias BFD = BuiltinFunctionData!(BuiltinFunction, name, i);
|
alias BFD = BuiltinFunctionData!(BuiltinFunction, name, i);
|
||||||
wstring name2 = getBasicName!BFD(name ~ suffix);
|
wstring name2 = getBasicName!BFD(name ~ suffix);
|
||||||
auto func = builtinFunctions.get(name2, null);
|
auto func = builtinFunctions.get(name2, null);
|
||||||
pragma(msg, AddFunc!BFD);
|
//pragma(msg, AddFunc!BFD);
|
||||||
auto f = new BuiltinFunction(
|
auto f = new BuiltinFunction(
|
||||||
GetFunctionParamType!(BFD),
|
GetFunctionParamType!(BFD),
|
||||||
GetFunctionReturnType!(BFD),
|
GetFunctionReturnType!(BFD),
|
||||||
@@ -2842,6 +2842,10 @@ template GetBuiltinFunctionArgment(P...)
|
|||||||
{
|
{
|
||||||
const string arg = "ValueType.String, false";
|
const string arg = "ValueType.String, false";
|
||||||
}
|
}
|
||||||
|
else static if(is(P[0] == Array!wchar))
|
||||||
|
{
|
||||||
|
const string arg = "ValueType.String, false";
|
||||||
|
}
|
||||||
else static if(is(P[0] == DefaultValue!int))
|
else static if(is(P[0] == DefaultValue!int))
|
||||||
{
|
{
|
||||||
const string arg = "ValueType.Integer, true";
|
const string arg = "ValueType.Integer, true";
|
||||||
@@ -3030,14 +3034,14 @@ DefaultValue!(double, false) fromDoubleToSkip(Value v)
|
|||||||
DefaultValue!wstring fromStringToDefault(Value v)
|
DefaultValue!wstring fromStringToDefault(Value v)
|
||||||
{
|
{
|
||||||
if(v.type == ValueType.String)
|
if(v.type == ValueType.String)
|
||||||
return DefaultValue!wstring(v.castString());
|
return DefaultValue!wstring(v.castDString());
|
||||||
else
|
else
|
||||||
return DefaultValue!wstring(true);
|
return DefaultValue!wstring(true);
|
||||||
}
|
}
|
||||||
DefaultValue!(wstring, false) fromStringToSkip(Value v)
|
DefaultValue!(wstring, false) fromStringToSkip(Value v)
|
||||||
{
|
{
|
||||||
if(v.type == ValueType.String)
|
if(v.type == ValueType.String)
|
||||||
return DefaultValue!(wstring, false)(v.castString());
|
return DefaultValue!(wstring, false)(v.castDString());
|
||||||
else
|
else
|
||||||
return DefaultValue!(wstring, false)(true);
|
return DefaultValue!(wstring, false)(true);
|
||||||
}
|
}
|
||||||
@@ -3195,6 +3199,19 @@ template AddFuncArg(int L, int N, int M, int O, BFD, P...)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
else static if(is(P[0] == wstring))
|
else static if(is(P[0] == wstring))
|
||||||
|
{
|
||||||
|
static if(storage & ParameterStorageClass.out_)
|
||||||
|
{
|
||||||
|
static assert(false, "Invalid argument out wstring");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
enum add = 1;
|
||||||
|
enum outadd = 0;
|
||||||
|
const string arg = "arg[" ~ I.to!string ~ "].castDString";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else static if(is(P[0] == Array!wchar))
|
||||||
{
|
{
|
||||||
static if(storage & ParameterStorageClass.out_)
|
static if(storage & ParameterStorageClass.out_)
|
||||||
{
|
{
|
||||||
@@ -3332,6 +3349,10 @@ template OutArgsInit(BFD, int I = 0, int J = 0)
|
|||||||
{
|
{
|
||||||
enum ret2 = "ValueType.String;";
|
enum ret2 = "ValueType.String;";
|
||||||
}
|
}
|
||||||
|
else static if(is(param[I] == Array!wchar))
|
||||||
|
{
|
||||||
|
enum ret2 = "ValueType.String;";
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
static assert(false, "invalid type " ~ param[I].stringof);
|
static assert(false, "invalid type " ~ param[I].stringof);
|
||||||
|
|||||||
@@ -30,15 +30,15 @@ struct Value
|
|||||||
int integerValue;
|
int integerValue;
|
||||||
double doubleValue;
|
double doubleValue;
|
||||||
//TODO:Array!wchar stringValue;にしたい
|
//TODO:Array!wchar stringValue;にしたい
|
||||||
wstring stringValue;
|
Array!wchar stringValue;
|
||||||
Array!int integerArray;
|
Array!int integerArray;
|
||||||
Array!double doubleArray;
|
Array!double doubleArray;
|
||||||
Array!wstring stringArray;
|
Array!(Array!wchar) stringArray;
|
||||||
VMAddress internalAddress;
|
VMAddress internalAddress;
|
||||||
Value* reference;
|
Value* reference;
|
||||||
int* integerReference;
|
int* integerReference;
|
||||||
double* doubleReference;
|
double* doubleReference;
|
||||||
wstring* stringReference;
|
Array!(wchar)* stringReference;
|
||||||
}
|
}
|
||||||
this(int value)
|
this(int value)
|
||||||
{
|
{
|
||||||
@@ -51,6 +51,16 @@ struct Value
|
|||||||
doubleValue = value;
|
doubleValue = value;
|
||||||
}
|
}
|
||||||
this(wstring value)
|
this(wstring value)
|
||||||
|
{
|
||||||
|
this.type = ValueType.String;
|
||||||
|
stringValue = new Array!wchar(cast(wchar[])value.dup);
|
||||||
|
}
|
||||||
|
this(wchar[] value)
|
||||||
|
{
|
||||||
|
this.type = ValueType.String;
|
||||||
|
stringValue = new Array!wchar(value);
|
||||||
|
}
|
||||||
|
this(Array!wchar value)
|
||||||
{
|
{
|
||||||
this.type = ValueType.String;
|
this.type = ValueType.String;
|
||||||
stringValue = value;
|
stringValue = value;
|
||||||
@@ -60,7 +70,7 @@ struct Value
|
|||||||
this.type = type;
|
this.type = type;
|
||||||
if(type == ValueType.String)
|
if(type == ValueType.String)
|
||||||
{
|
{
|
||||||
stringValue = "";
|
stringValue = new Array!wchar(0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
this(Value* r)
|
this(Value* r)
|
||||||
@@ -78,7 +88,7 @@ struct Value
|
|||||||
this.type = ValueType.DoubleReference;
|
this.type = ValueType.DoubleReference;
|
||||||
doubleReference = r;
|
doubleReference = r;
|
||||||
}
|
}
|
||||||
this(wstring* r)
|
this(Array!(wchar)* r)
|
||||||
{
|
{
|
||||||
this.type = ValueType.StringReference;
|
this.type = ValueType.StringReference;
|
||||||
stringReference = r;
|
stringReference = r;
|
||||||
@@ -158,12 +168,18 @@ struct Value
|
|||||||
}
|
}
|
||||||
throw new TypeMismatch();
|
throw new TypeMismatch();
|
||||||
}
|
}
|
||||||
wstring castString()
|
Array!wchar castString()
|
||||||
{
|
{
|
||||||
if (this.type == ValueType.String)
|
if (this.type == ValueType.String)
|
||||||
return this.stringValue;
|
return this.stringValue;
|
||||||
throw new TypeMismatch();
|
throw new TypeMismatch();
|
||||||
}
|
}
|
||||||
|
wstring castDString()
|
||||||
|
{
|
||||||
|
if (this.type == ValueType.String)
|
||||||
|
return cast(immutable)this.stringValue.array;
|
||||||
|
throw new TypeMismatch();
|
||||||
|
}
|
||||||
string toString()
|
string toString()
|
||||||
{
|
{
|
||||||
import std.conv;
|
import std.conv;
|
||||||
@@ -202,7 +218,7 @@ struct Value
|
|||||||
//とりあえず破壊的に書き換えた
|
//とりあえず破壊的に書き換えた
|
||||||
//どのみちこれだと文字数を増やすことができないのでArray!wcharで管理させたい
|
//どのみちこれだと文字数を増やすことができないのでArray!wcharで管理させたい
|
||||||
case ValueType.String:
|
case ValueType.String:
|
||||||
(cast(wchar[])stringValue)[i] = v.castString[0];
|
stringValue[i] = v.castString;
|
||||||
break;
|
break;
|
||||||
case ValueType.IntegerArray:
|
case ValueType.IntegerArray:
|
||||||
integerArray.array[i] = v.castInteger;
|
integerArray.array[i] = v.castInteger;
|
||||||
@@ -278,6 +294,18 @@ class Array(T)
|
|||||||
}
|
}
|
||||||
dimCount = 1;
|
dimCount = 1;
|
||||||
}
|
}
|
||||||
|
static if (!is(T == int))
|
||||||
|
{
|
||||||
|
this(T[] array)
|
||||||
|
{
|
||||||
|
dim[0] = array.length;
|
||||||
|
dim[1] = 0;
|
||||||
|
dim[2] = 0;
|
||||||
|
dim[3] = 0;
|
||||||
|
this.array = array;
|
||||||
|
dimCount = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
@property size_t length()
|
@property size_t length()
|
||||||
{
|
{
|
||||||
return array.length;
|
return array.length;
|
||||||
@@ -408,5 +436,28 @@ class Array(T)
|
|||||||
array.length = size;
|
array.length = size;
|
||||||
dim[0] = size;
|
dim[0] = size;
|
||||||
}
|
}
|
||||||
|
void append(Array!T input)
|
||||||
|
{
|
||||||
|
if (dimCount != 1 || input.dimCount != 1)
|
||||||
|
{
|
||||||
|
throw new TypeMismatch();
|
||||||
|
}
|
||||||
|
array ~= input.array;
|
||||||
|
dim[0] = array.length;
|
||||||
|
}
|
||||||
|
void opIndexAssign(Array!T v, int i1)
|
||||||
|
{
|
||||||
|
if(dimCount != 1 || v.dimCount != 1 ) throw new SyntaxError();
|
||||||
|
if(i1 >= dim[0]) throw new SubscriptOutOfRange();
|
||||||
|
array = array[0..i1] ~ v.array ~ array[i1..$];
|
||||||
|
dim[0] = array.length;
|
||||||
|
}
|
||||||
|
Array!T opOpAssign(string op = "~")(Array!T v)
|
||||||
|
{
|
||||||
|
if(dimCount != 1 || v.dimCount != 1 ) throw new SyntaxError();
|
||||||
|
array ~= v.array;
|
||||||
|
dim[0] = array.length;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user