1
0

DATA,READを実装.

This commit is contained in:
otya128
2015-08-19 13:02:02 +09:00
parent 190e655b90
commit 4c7487bb31
6 changed files with 111 additions and 5 deletions

View File

@@ -32,6 +32,7 @@ class DataTable
{
Value[] data;
int[wstring] label;
int dataIndex;
void addData(Value data)
{
this.data ~= data;
@@ -40,6 +41,13 @@ class DataTable
{
this.label[label] = data.length;
}
void read(out Value value, VM vm)
{
if(dataIndex >= data.length)
throw new OutOfDATA();
value = data[dataIndex];
dataIndex++;
}
}
class Function
{
@@ -618,6 +626,14 @@ class Compiler
compilePopVar(i, sc);
}
}
void compileRead(Read read, Scope sc)
{
genCode(new ReadCode(read.variables.length));
foreach_reverse(i; read.variables)
{
compilePopVar(i, sc);
}
}
void compileStatement(Statement i, Scope s)
{
switch(i.type)
@@ -781,6 +797,9 @@ class Compiler
s.data.addData(j);
}
break;
case NodeType.Read:
compileRead(cast(Read)i, s);
break;
case NodeType.On:
compileOn(cast(On)i, s);
break;
@@ -854,7 +873,7 @@ class Compiler
}
}
}
return new VM(code, globalIndex + 1, global, functions);
return new VM(code, globalIndex + 1, global, functions, s.data);
}
}