879
879
//TODO: Implement"corresponding"
880
//TODO: Implement "MOVE SPACES..."
881
if (move.From.IsSpaces)
883
//TODO: Type checking
884
//TODO: Line number in exception
885
//TODO: Look variable up in definitions and get size, then move n spaces into it.
886
foreach (Identifier toIdentifier in move.To)
880
//TODO: Implement "MOVE SPACES..."
881
if (move.From.GetType() == typeof(FigurativeConstant))
883
FigurativeConstant constant = move.From as FigurativeConstant;
884
if (constant.Type == FigurativeConstantType.Spaces)
888
int size = toIdentifier.Definition.Size;
889
//Console.WriteLine("MOVE SPACES TO variable of size "+size);
891
r += ILAddress(1) + "ldarg.0"; //Hidden pointer to 'this'
893
Literal literal = new Literal();
894
literal.Type = VariableType.String;
896
for (int i = 0; i < size; i++)
886
//TODO: Type checking
887
//TODO: Line number in exception
888
//TODO: Look variable up in definitions and get size, then move n spaces into it.
889
foreach (Identifier toIdentifier in move.To)
898
literal.Value += " ";
900
r += EmitLiteral(literal);
901
r += EmitStore(toIdentifier); //TODO: This needs changed for subscripts
891
int size = toIdentifier.Definition.Size;
892
//Console.WriteLine("MOVE SPACES TO variable of size "+size);
894
r += ILAddress(1) + "ldarg.0"; //Hidden pointer to 'this'
896
Literal literal = new Literal();
897
literal.Type = VariableType.String;
899
for (int i = 0; i < size; i++)
901
literal.Value += " ";
903
r += EmitLiteral(literal);
904
r += EmitStore(toIdentifier); //TODO: This needs changed for subscripts
905
if (IsGroup(toIdentifier))
907
r += " " + ILAddress(1) + "ldarg.0\n"; //Hidden pointer to 'this'
908
r += " " + ILAddress(1) + "ldc.i4.0\n"; //Zero, used for 'false'
909
r += " " + ILAddress(5) + "stfld bool __CobolProgram::_hasData_"+toIdentifier.Definition.Name+"\n";
913
Console.WriteLine("TODO: Other figurative constants not supported yet");
1308
1320
//Call substring:
1309
1321
// IL_0011: callvirt instance string string::Substring(int32, int32)
1310
r += " " + ILAddress(5) + "callvirt instance string string::Substring(int32, int32)\n";
1322
r += " " + ILAddress(5) + "callvirt instance string string::Substring(int32, int32)\n";
1312
1324
//Store result:
1313
1325
// IL_0016: stfld string WorkingStorageTest.Program::bb1
1417
if (id.Definition.IsGroup)
1429
if (id.Definition.IsGroup && !id.Definition.IsAnonymous)
1419
1431
//TODO: Make this work
1420
Console.WriteLine("EmitLoadField Groups/Records not supported yet");
1432
//Console.WriteLine("EmitLoadField Groups/Records not supported yet");
1434
r += " " + ILAddress(1) + "pop\n";
1436
//Build the format string...
1437
List<DataDescription> ddes = ListElements(id.Definition);
1440
foreach (DataDescription dd in ddes)
1442
fmt += "{" + obj + ",-" + dd.Size + "}";
1445
//Load the format string...
1446
r += " " + ILAddress(5);
1447
r += "ldstr \"" + fmt + "\"\n";
1448
Console.WriteLine("fmt = "+fmt);
1422
1450
//Create an array
1423
List<DataDescription> ddes = ListElements(id.Definition);
1424
r += " " + ILAddress(1) + "pop\n";
1425
1451
r += " " + ILAddress(5);
1426
1452
r += "ldc.i4 " + ddes.Count + "\n";
1427
1453
r += " " + ILAddress(5);
1428
1454
r += "newarr [mscorlib]System.Object\n";
1430
1456
//Load elements into array
1432
1458
foreach (DataDescription dd in ddes)
1434
1460
Identifier tmp = new Identifier();
1437
1463
r += " " + ILAddress(1) + "dup\n";
1438
1464
r += " " + ILAddress(5) + "ldc.i4 "+obj+"\n";
1439
1465
r += EmitLoadSource(tmp as Source, false, true);
1440
if (tmp.Definition.Type == DataType.Integer){
1441
//TODO: Do this for boolean as well?
1442
r += " " + ILAddress(5) + "call instance string int32::ToString()\n";
1444
1466
r += " " + ILAddress(1) + "stelem.ref\n";
1447
r += " " + ILAddress(5) + "call string string::Concat(string[])\n";
1469
r += " " + ILAddress(5) + "call string string::Format(string,object[])\n";
1449
1471
string typ = null;