Skip to content

Commit ee93004

Browse files
committed
Refactored repl, added basic array support
1 parent 2830b84 commit ee93004

33 files changed

Lines changed: 1475 additions & 373 deletions

Rhodus_Version_3/RhodusVersionThreeProject.dpr

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,9 @@ uses
8989
uTokenVector in 'uTokenVector.pas',
9090
uScannerTypes in 'uScannerTypes.pas',
9191
uEmbeddAPI in 'uEmbeddAPI.pas',
92-
uRepl in 'uRepl.pas';
92+
uRepl in 'uRepl.pas',
93+
uArrayObject in '..\VirtualMachine\uArrayObject.pas',
94+
uBuiltInArray in 'uBuiltInArray.pas';
9395

9496
var sourceCode : string;
9597
fragment : string;
@@ -204,8 +206,8 @@ begin
204206

205207
if leftStr (src, 5) = 'debug' then
206208
begin
207-
bolShowAssembler := not bolShowAssembler;
208-
if bolShowAssembler then
209+
bolShowByteCode := not bolShowByteCode;
210+
if bolShowByteCode then
209211
writeln ('Debug ON')
210212
else writeln ('Debug OFF');
211213
exit (True);

Rhodus_Version_3/RhodusVersionThreeProject.dproj

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,8 @@
217217
<DCCReference Include="uScannerTypes.pas"/>
218218
<DCCReference Include="uEmbeddAPI.pas"/>
219219
<DCCReference Include="uRepl.pas"/>
220+
<DCCReference Include="..\VirtualMachine\uArrayObject.pas"/>
221+
<DCCReference Include="uBuiltInArray.pas"/>
220222
<BuildConfiguration Include="Base">
221223
<Key>Base</Key>
222224
</BuildConfiguration>
@@ -255,23 +257,23 @@
255257
<Overwrite>true</Overwrite>
256258
</Platform>
257259
</DeployFile>
258-
<DeployFile LocalName="$(BDS)\Redist\osx32\libcgunwind.1.0.dylib" Class="DependencyModule">
259-
<Platform Name="OSX32">
260+
<DeployFile LocalName="$(BDS)\Redist\iossimulator\libcgunwind.1.0.dylib" Class="DependencyModule">
261+
<Platform Name="iOSSimulator">
260262
<Overwrite>true</Overwrite>
261263
</Platform>
262264
</DeployFile>
263-
<DeployFile LocalName="Win32\Release\RhodusVersionThreeProject.exe" Configuration="Release" Class="ProjectOutput">
265+
<DeployFile LocalName="Win32\Debug\RhodusVersionThreeProject.exe" Configuration="Debug" Class="ProjectOutput">
264266
<Platform Name="Win32">
265267
<RemoteName>RhodusVersionThreeProject.exe</RemoteName>
266268
<Overwrite>true</Overwrite>
267269
</Platform>
268270
</DeployFile>
269-
<DeployFile LocalName="$(BDS)\Redist\iossimulator\libcgunwind.1.0.dylib" Class="DependencyModule">
270-
<Platform Name="iOSSimulator">
271+
<DeployFile LocalName="$(BDS)\Redist\osx32\libcgunwind.1.0.dylib" Class="DependencyModule">
272+
<Platform Name="OSX32">
271273
<Overwrite>true</Overwrite>
272274
</Platform>
273275
</DeployFile>
274-
<DeployFile LocalName="Win32\Debug\RhodusVersionThreeProject.exe" Configuration="Debug" Class="ProjectOutput">
276+
<DeployFile LocalName="Win32\Release\RhodusVersionThreeProject.exe" Configuration="Release" Class="ProjectOutput">
275277
<Platform Name="Win32">
276278
<RemoteName>RhodusVersionThreeProject.exe</RemoteName>
277279
<Overwrite>true</Overwrite>
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
2+
import arrays
3+
4+
a1 = arrays.rndu (4,4)
5+
a2 = arrays.rndu (4,4)
6+
7+
a3 = a1 - a2
8+
9+
println (a3+a2-a1)

Rhodus_Version_3/TestScripts/funcCall.rh

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -50,11 +50,11 @@ testUtils.runtestTrue(test_4() == 1.2);
5050
function test_5()
5151
for i = 1 to 10 do
5252
if i == 5 then
53-
return {5, 12345}
53+
return [5, 12345]
5454
end;
5555
end;
5656
end;
57-
testUtils.runtestTrue(test_5() == {5, 12345});
57+
testUtils.runtestTrue(test_5() == [5, 12345]);
5858

5959

6060
function test_6()
@@ -68,18 +68,18 @@ end;
6868
testUtils.runtestTrue (test_6() == 123456);
6969

7070
function test_7()
71-
a = {1,2,3,4};
71+
a = [1,2,3,4]
7272
a[2] = 1;
7373
return a
7474
end;
75-
testUtils.runtestTrue (test_7() == {1,2,1,4});
75+
testUtils.runtestTrue (test_7() == [1,2,1,4]);
7676

7777
function test_8()
78-
a = {1,2,3,4,5,{6,7,8}};
78+
a = [1,2,3,4,5,[6,7,8]];
7979
a[5,0] = 99;
8080
return a
8181
end;
82-
testUtils.runtestTrue (test_8() == {1,2,3,4,5,{99,7,8}});
82+
testUtils.runtestTrue (test_8() == [1,2,3,4,5,[99,7,8]]);
8383
testUtils.endTests()
8484

8585
//----------------------------------------------------
@@ -150,7 +150,7 @@ function mean (x)
150150
end
151151
return sum/5
152152
end
153-
testUtils.runtestTrue (mean ({1,2,3,4,5}) == 3)
153+
testUtils.runtestTrue (mean ([1,2,3,4,5]) == 3)
154154

155155
function repeatString(count, text)
156156
ret = "";
@@ -290,12 +290,12 @@ function abc
290290
return 5
291291
end
292292

293-
x = {abc}
293+
x = [abc]
294294
testUtils.runtestTrue (x[0]() == 5)
295295

296-
r = {math.sin (30), math.cos (30), math.tan (30)};
296+
r = [math.sin (30), math.cos (30), math.tan (30)];
297297

298-
x = {math.sin, math.cos, math.tan};
298+
x = [math.sin, math.cos, math.tan];
299299

300300
testUtils.runtestTrue (r[0] == x[0](30));
301301
testUtils.runtestTrue (r[1] == x[1](30));
@@ -313,24 +313,24 @@ end
313313
// And user defined funtions
314314
function test (x) return x*x; end
315315

316-
x = {test}
316+
x = [test]
317317
testUtils.runtestTrue (3*3 == x[0](3));
318318

319319
function runtest (fcn, x)
320320
return fcn (x)
321321
end
322322

323323
function testlog (x)
324-
a = {math.log}
324+
a = [math.log]
325325
return a[0](x)
326326
end
327327

328328
testUtils.runtestTrue (testlog (100) == 2)
329329

330-
function t1 (x) return {1,2,3} + x end
330+
function t1 (x) return [1,2,3] + x end
331331
function t2 (y) return t1 (y) end
332332

333-
testUtils.runtestTrue (t2 (25) == {1,2,3,25})
333+
testUtils.runtestTrue (t2 (25) == [1,2,3,25])
334334

335335
testUtils.endTests()
336336

@@ -356,7 +356,7 @@ testUtils.runtestTrue (True); // just record we did the test
356356

357357
// Memory leak test for lists
358358
function test_10()
359-
a = {1,2,3};
359+
a = [1,2,3];
360360
b = a;
361361
b = 1;
362362
end;

Rhodus_Version_3/TestScripts/global.rh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ testGlobal_2 ()
1717
testUtils.runtestTrue (x == 4.5);
1818

1919
y = 4.5; w = 8.9;
20-
a = "str"; b= {1,2,3};
20+
a = "str"; b= [1,2,3];
2121

2222
function testGlobal_3 ()
2323
x = 4.5;

Rhodus_Version_3/TestScripts/globalBuiltins.rh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ testUtils.runtestTrue (type ("abc") == "string");
2222
testUtils.runtestTrue (type (2.34) == "float");
2323
testUtils.runtestTrue (type (True) == "bool");
2424
testUtils.runtestTrue (type (False) == "bool");
25-
testUtils.runtestTrue (type ({1,2,3}) == "list");
25+
testUtils.runtestTrue (type ([1,2,3]) == "list");
2626

2727

2828
testUtils.endTests()

Rhodus_Version_3/TestScripts/lists.rh

Lines changed: 44 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -6,87 +6,87 @@ println ("---------------------- List Tests ------------------------")
66
setColor ("white")
77

88
testUtils.beginTests ("")
9-
a = {1,2,3,4};
9+
a = [1,2,3,4];
1010
a = 1;
1111
testUtils.runtestTrue(a == 1);
1212

13-
testUtils.runtestTrue({} == {});
14-
testUtils.runtestTrue({1} == {1});
15-
testUtils.runtestTrue({1,2,3} == {1,2,3});
16-
testUtils.runtestTrue({1,2,3} + 4 == {1,2,3,4});
17-
testUtils.runtestTrue({1,2,3} + 3.14 == {1,2,3,3.14});
13+
testUtils.runtestTrue([] == []);
14+
testUtils.runtestTrue([1] == [1]);
15+
testUtils.runtestTrue([1,2,3] == [1,2,3]);
16+
testUtils.runtestTrue([1,2,3] + 4 == [1,2,3,4]);
17+
testUtils.runtestTrue([1,2,3] + 3.14 == [1,2,3,3.14]);
1818

19-
testUtils.runtestTrue({1,2,3} + True == {1,2,3,True});
20-
testUtils.runtestTrue({1,2,3} + "string" == {1,2,3,"string"});
19+
testUtils.runtestTrue([1,2,3] + True == [1,2,3,True]);
20+
testUtils.runtestTrue([1,2,3] + "string" == [1,2,3,"string"]);
2121

22-
testUtils.runtestTrue({1,2,3} + {4} == {1,2,3,4});
23-
testUtils.runtestTrue({1,2,3} + {{4}} == {1,2,3,{4}});
22+
testUtils.runtestTrue([1,2,3] + [4] == [1,2,3,4]);
23+
testUtils.runtestTrue([1,2,3] + [[4]] == [1,2,3,[4]]);
2424

25-
testUtils.runtestTrue ({1,2,3} + 3.14 == {1,2,3,3.14});
26-
testUtils.runtestTrue ({1,2,3} + True == {1,2,3,True});
25+
testUtils.runtestTrue ([1,2,3] + 3.14 == [1,2,3,3.14]);
26+
testUtils.runtestTrue ([1,2,3] + True == [1,2,3,True]);
2727

28-
testUtils.runtestTrue ({1,2,3} + {"string"} == {1,2,3,"string"});
28+
testUtils.runtestTrue ([1,2,3] + ["string"] == [1,2,3,"string"]);
2929

30-
testUtils.runtestTrue ({1,2,3} + {4,True,2.81,"string"} == {1,2,3,4,True,2.81,"string"});
30+
testUtils.runtestTrue ([1,2,3] + [4,True,2.81,"string"] == [1,2,3,4,True,2.81,"string"]);
3131

32-
testUtils.runtestTrue ({1,2,3} + {{4,True,2.81,"string"}} == {1,2,3,{4,True,2.81,"string"}});
32+
testUtils.runtestTrue ([1,2,3] + [[4,True,2.81,"string"]] == [1,2,3,[4,True,2.81,"string"]]);
3333

34-
testUtils.runtestTrue ({1,2,3} + {{4,5,{6,{7}}}} == {1,2,3,{4,5,{6,{7}}}});
34+
testUtils.runtestTrue ([1,2,3] + [[4,5,[6,[7]]]] == [1,2,3,[4,5,[6,[7]]]]);
3535
testUtils.endTests()
3636

3737

3838
testUtils.beginTests ("")
39-
a = {1};
40-
testUtils.runtestTrue (3*a == {1,1,1});
39+
a = [1];
40+
testUtils.runtestTrue (3*a == [1,1,1]);
4141

42-
a = {1,2};
43-
testUtils.runtestTrue (3*a == {1,2,1,2,1,2});
42+
a = [1,2];
43+
testUtils.runtestTrue (3*a == [1,2,1,2,1,2]);
4444

45-
a = {1,{2}};
46-
testUtils.runtestTrue (a*3 == {1,{2},1,{2},1,{2}});
45+
a = [1,[2]];
46+
testUtils.runtestTrue (a*3 == [1,[2],1,[2],1,[2]]);
4747

4848
a = True;
49-
alist = {1,2,3};
49+
alist = [1,2,3];
5050
alist[1] = a;
51-
testUtils.runtestTrue (alist == {1, True, 3});
51+
testUtils.runtestTrue (alist == [1, True, 3]);
5252
testUtils.endTests()
5353

5454
testUtils.beginTests ("")
55-
alist = {1,2,3,4};
55+
alist = [1,2,3,4];
5656
testUtils.runtestTrue (alist[1] == 2);
5757
testUtils.runtestTrue (alist[2] == 3);
5858

59-
alist = {1,2,3,{4,5},6};
60-
testUtils.runtestTrue (alist[3] == {4,5});
59+
alist = [1,2,3,[4,5],6];
60+
testUtils.runtestTrue (alist[3] == [4,5]);
6161

62-
alist = {1,2,3,{4,5},6};
62+
alist = [1,2,3,[4,5],6];
6363
alist[0] = 99;
6464
testUtils.runtestTrue (alist[0] == 99);
6565

66-
alist = {1,2,3,{4,5},6};
67-
alist[0] = {"ab","xy"};
68-
testUtils.runtestTrue (alist[0] == {"ab","xy"});
66+
alist = [1,2,3,[4,5],6];
67+
alist[0] = ["ab","xy"];
68+
testUtils.runtestTrue (alist[0] == ["ab","xy"]);
6969

70-
a = {3,4};
71-
a = {1,2};
72-
a = {1,2,3,4,5};
70+
a = [3,4];
71+
a = [1,2];
72+
a = [1,2,3,4,5];
7373
testUtils.runtestTrue (a[1] + a[3] == 6);
7474

75-
a = {1,2,{3,{4,5}}};
76-
testUtils.runtestTrue (a[2,1] == {4,5});
75+
a = [1,2,[3,[4,5]]];
76+
testUtils.runtestTrue (a[2,1] == [4,5]);
7777
a[2,1,0] = 99;
78-
testUtils.runtestTrue (a == {1,2,{3,{99,5}}});
78+
testUtils.runtestTrue (a == [1,2,[3,[99,5]]]);
7979
testUtils.endTests()
8080

8181
testUtils.beginTests ("")
8282
// Memmory leak tests for multipying lists
83-
a = {1,2,3};
83+
a = [1,2,3];
8484
b = 3*a;
85-
testUtils.runtestTrue (b == {1,2,3,1,2,3,1,2,3});
85+
testUtils.runtestTrue (b == [1,2,3,1,2,3,1,2,3]);
8686

87-
a = {1,2,3,{7,8,9,{56,78}}};
87+
a = [1,2,3,[7,8,9,[56,78]]];
8888
x = a[3,3];
89-
testUtils.runtestTrue (x == {56,78});
89+
testUtils.runtestTrue (x == [56,78]);
9090
testUtils.endTests()
9191

9292

@@ -95,9 +95,9 @@ testUtils.beginTests ("")
9595
// --------------------------------------------------------
9696
// Test period syntax and index of lists containing methods
9797
//println ("\nList containing methods")
98-
r = {math.sin (30), math.cos (30), math.tan (30)};
98+
r = [math.sin (30), math.cos (30), math.tan (30)];
9999

100-
x = {math.sin, math.cos, math.tan};
100+
x = [math.sin, math.cos, math.tan];
101101

102102
testUtils.runtestTrue (r[0] == x[0](30));
103103
testUtils.runtestTrue (r[1] == x[1](30));
@@ -113,7 +113,7 @@ testUtils.beginTests ("")
113113
// And user defined funtions
114114
function test (x) return x*x; end
115115

116-
x = {test}
116+
x = [test]
117117
testUtils.runtestTrue (3*3 == x[0](3));
118118

119119
function runtest (fcn, x)

Rhodus_Version_3/TestScripts/loops.rh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ testUtils.beginTests ("Repeat/Until Tests")
1111
// ----------------------------------------------
1212

1313
i = 0;
14-
alist = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
14+
alist = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9];
1515
repeat
1616
testUtils.runtestTrue (i == alist[i]);
1717
i = i + 1;
@@ -97,7 +97,7 @@ testUtils.endTests()
9797

9898
testUtils.beginTests ("For Loop Tests")
9999

100-
alist = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
100+
alist = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
101101
for i = 1 to 10 do
102102
testUtils.runtestTrue (i == alist[i]);
103103
end;

Rhodus_Version_3/TestScripts/simpleFunc.rh

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,14 +42,14 @@ testUtils.runtestTrue (test_6() == False)
4242

4343

4444
function test_7
45-
return {1,2,3}
45+
return [1,2,3]
4646
end
47-
testUtils.runtestTrue (test_7() == {1,2,3})
47+
testUtils.runtestTrue (test_7() == [1,2,3])
4848

4949
function test_8
50-
return {1,2,3,{4,5}}
50+
return [1,2,3,[4,5]]
5151
end
52-
testUtils.runtestTrue (test_8() == {1,2,3,{4,5}})
52+
testUtils.runtestTrue (test_8() == [1,2,3,[4,5]])
5353

5454

5555
function test_9

Rhodus_Version_3/Win32/Debug/rhodus.ini

Lines changed: 0 additions & 12 deletions
This file was deleted.

0 commit comments

Comments
 (0)