Skip to content

Commit c6c944e

Browse files
author
runrevali
committed
[[ StdMlc ]] Added the empty list/array/string/data
1 parent d74e370 commit c6c944e

File tree

14 files changed

+390
-34
lines changed

14 files changed

+390
-34
lines changed

libscript/libscript.xcodeproj/project.pbxproj

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
4D79B6851A273BA000DD750C /* module-encoding.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4D79B65E1A273BA000DD750C /* module-encoding.cpp */; };
2424
4D79B6871A273BA000DD750C /* module-list.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4D79B6601A273BA000DD750C /* module-list.cpp */; };
2525
4D79B6881A273BA000DD750C /* module-logic.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4D79B6611A273BA000DD750C /* module-logic.cpp */; };
26-
4D79B6891A273BA000DD750C /* module-map.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4D79B6621A273BA000DD750C /* module-map.cpp */; };
2726
4D79B68A1A273BA000DD750C /* module-math_foundation.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4D79B6631A273BA000DD750C /* module-math_foundation.cpp */; };
2827
4D79B68B1A273BA000DD750C /* module-math.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4D79B6641A273BA000DD750C /* module-math.cpp */; };
2928
4D79B68C1A273BA000DD750C /* module-sort.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4D79B6651A273BA000DD750C /* module-sort.cpp */; };
@@ -37,7 +36,6 @@
3736
4D79B6951A273BBB00DD750C /* module-char.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4D79B65D1A273BA000DD750C /* module-char.cpp */; };
3837
4D79B6981A273BBB00DD750C /* module-list.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4D79B6601A273BA000DD750C /* module-list.cpp */; };
3938
4D79B6991A273BBB00DD750C /* module-logic.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4D79B6611A273BA000DD750C /* module-logic.cpp */; };
40-
4D79B69A1A273BBB00DD750C /* module-map.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4D79B6621A273BA000DD750C /* module-map.cpp */; };
4139
4D79B69B1A273BBB00DD750C /* module-math_foundation.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4D79B6631A273BA000DD750C /* module-math_foundation.cpp */; };
4240
4D79B69C1A273BBB00DD750C /* module-math.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4D79B6641A273BA000DD750C /* module-math.cpp */; };
4341
4D79B69D1A273BBB00DD750C /* module-sort.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4D79B6651A273BA000DD750C /* module-sort.cpp */; };
@@ -52,7 +50,6 @@
5250
4D79B6D61A27405600DD750C /* item.mlc in Sources */ = {isa = PBXBuildFile; fileRef = 4D79B6711A273BA000DD750C /* item.mlc */; };
5351
4D79B6D81A27405600DD750C /* line.mlc in Sources */ = {isa = PBXBuildFile; fileRef = 4D79B6731A273BA000DD750C /* line.mlc */; };
5452
4D79B6DB1A27405600DD750C /* logic.mlc in Sources */ = {isa = PBXBuildFile; fileRef = 4D79B6761A273BA000DD750C /* logic.mlc */; };
55-
4D79B6DC1A27405600DD750C /* map.mlc in Sources */ = {isa = PBXBuildFile; fileRef = 4D79B6771A273BA000DD750C /* map.mlc */; };
5653
4D79B6DE1A27405600DD750C /* math.mlc in Sources */ = {isa = PBXBuildFile; fileRef = 4D79B6791A273BA000DD750C /* math.mlc */; };
5754
4D79B6DF1A27405600DD750C /* segmentchunk.mlc in Sources */ = {isa = PBXBuildFile; fileRef = 4D79B67A1A273BA000DD750C /* segmentchunk.mlc */; };
5855
4D79B6E01A27405600DD750C /* sort.mlc in Sources */ = {isa = PBXBuildFile; fileRef = 4D79B67B1A273BA000DD750C /* sort.mlc */; };
@@ -62,6 +59,9 @@
6259
4DDA20701A139BC0001B0CA2 /* script-test.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4DDA206F1A139BC0001B0CA2 /* script-test.cpp */; };
6360
766113441A2F298E0042DE7F /* list.mlc in Sources */ = {isa = PBXBuildFile; fileRef = 4D79B6751A273BA000DD750C /* list.mlc */; };
6461
766113541A2F4F720042DE7F /* type-convert.mlc in Sources */ = {isa = PBXBuildFile; fileRef = 766113531A2F4F720042DE7F /* type-convert.mlc */; };
62+
766113891A31FB640042DE7F /* module-array.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 766113881A31FB640042DE7F /* module-array.cpp */; };
63+
7661138A1A31FB690042DE7F /* module-array.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 766113881A31FB640042DE7F /* module-array.cpp */; };
64+
7661138D1A31FE1B0042DE7F /* array.mlc in Sources */ = {isa = PBXBuildFile; fileRef = 7661138C1A31FDFD0042DE7F /* array.mlc */; };
6565
/* End PBXBuildFile section */
6666

6767
/* Begin PBXBuildRule section */
@@ -171,7 +171,6 @@
171171
4D79B65E1A273BA000DD750C /* module-encoding.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = "module-encoding.cpp"; path = "src/module-encoding.cpp"; sourceTree = "<group>"; };
172172
4D79B6601A273BA000DD750C /* module-list.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = "module-list.cpp"; path = "src/module-list.cpp"; sourceTree = "<group>"; };
173173
4D79B6611A273BA000DD750C /* module-logic.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = "module-logic.cpp"; path = "src/module-logic.cpp"; sourceTree = "<group>"; };
174-
4D79B6621A273BA000DD750C /* module-map.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = "module-map.cpp"; path = "src/module-map.cpp"; sourceTree = "<group>"; };
175174
4D79B6631A273BA000DD750C /* module-math_foundation.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = "module-math_foundation.cpp"; path = "src/module-math_foundation.cpp"; sourceTree = "<group>"; };
176175
4D79B6641A273BA000DD750C /* module-math.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = "module-math.cpp"; path = "src/module-math.cpp"; sourceTree = "<group>"; };
177176
4D79B6651A273BA000DD750C /* module-sort.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = "module-sort.cpp"; path = "src/module-sort.cpp"; sourceTree = "<group>"; };
@@ -188,7 +187,6 @@
188187
4D79B6731A273BA000DD750C /* line.mlc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = line.mlc; path = src/line.mlc; sourceTree = "<group>"; };
189188
4D79B6751A273BA000DD750C /* list.mlc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = list.mlc; path = src/list.mlc; sourceTree = "<group>"; };
190189
4D79B6761A273BA000DD750C /* logic.mlc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = logic.mlc; path = src/logic.mlc; sourceTree = "<group>"; };
191-
4D79B6771A273BA000DD750C /* map.mlc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = map.mlc; path = src/map.mlc; sourceTree = "<group>"; };
192190
4D79B6781A273BA000DD750C /* math-foundation.mlc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = "math-foundation.mlc"; path = "src/math-foundation.mlc"; sourceTree = "<group>"; };
193191
4D79B6791A273BA000DD750C /* math.mlc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = math.mlc; path = src/math.mlc; sourceTree = "<group>"; };
194192
4D79B67A1A273BA000DD750C /* segmentchunk.mlc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = segmentchunk.mlc; path = src/segmentchunk.mlc; sourceTree = "<group>"; };
@@ -201,6 +199,8 @@
201199
4DDA20661A139BA1001B0CA2 /* libscript-test */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = "libscript-test"; sourceTree = BUILT_PRODUCTS_DIR; };
202200
4DDA206F1A139BC0001B0CA2 /* script-test.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = "script-test.cpp"; path = "src/script-test.cpp"; sourceTree = "<group>"; };
203201
766113531A2F4F720042DE7F /* type-convert.mlc */ = {isa = PBXFileReference; lastKnownFileType = text; name = "type-convert.mlc"; path = "src/type-convert.mlc"; sourceTree = "<group>"; };
202+
766113881A31FB640042DE7F /* module-array.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = "module-array.cpp"; path = "src/module-array.cpp"; sourceTree = "<group>"; };
203+
7661138C1A31FDFD0042DE7F /* array.mlc */ = {isa = PBXFileReference; lastKnownFileType = text; name = array.mlc; path = src/array.mlc; sourceTree = "<group>"; };
204204
/* End PBXFileReference section */
205205

206206
/* Begin PBXFrameworksBuildPhase section */
@@ -308,21 +308,22 @@
308308
isa = PBXGroup;
309309
children = (
310310
4D79B6591A273BA000DD750C /* module-arithmetic.cpp */,
311+
766113881A31FB640042DE7F /* module-array.cpp */,
311312
4D79B65A1A273BA000DD750C /* module-binary.cpp */,
312313
4D79B65B1A273BA000DD750C /* module-bitwise.cpp */,
313314
4D79B65C1A273BA000DD750C /* module-byte.cpp */,
314315
4D79B65D1A273BA000DD750C /* module-char.cpp */,
315316
4D79B65E1A273BA000DD750C /* module-encoding.cpp */,
316317
4D79B6601A273BA000DD750C /* module-list.cpp */,
317318
4D79B6611A273BA000DD750C /* module-logic.cpp */,
318-
4D79B6621A273BA000DD750C /* module-map.cpp */,
319319
4D79B6631A273BA000DD750C /* module-math_foundation.cpp */,
320320
4D79B6641A273BA000DD750C /* module-math.cpp */,
321321
4D79B6651A273BA000DD750C /* module-sort.cpp */,
322322
4D79B6661A273BA000DD750C /* module-string.cpp */,
323323
4D79B6671A273BA000DD750C /* module-type_convert.cpp */,
324324
4D79B6681A273BA000DD750C /* module-type.cpp */,
325325
4D79B66A1A273BA000DD750C /* arithmetic.mlc */,
326+
7661138C1A31FDFD0042DE7F /* array.mlc */,
326327
4D79B66B1A273BA000DD750C /* binary.mlc */,
327328
4D79B66C1A273BA000DD750C /* bitwise.mlc */,
328329
4D79B66D1A273BA000DD750C /* byte.mlc */,
@@ -332,7 +333,6 @@
332333
4D79B6731A273BA000DD750C /* line.mlc */,
333334
4D79B6751A273BA000DD750C /* list.mlc */,
334335
4D79B6761A273BA000DD750C /* logic.mlc */,
335-
4D79B6771A273BA000DD750C /* map.mlc */,
336336
4D79B6781A273BA000DD750C /* math-foundation.mlc */,
337337
4D79B6791A273BA000DD750C /* math.mlc */,
338338
4D79B67A1A273BA000DD750C /* segmentchunk.mlc */,
@@ -520,10 +520,10 @@
520520
4D79B6851A273BA000DD750C /* module-encoding.cpp in Sources */,
521521
4D21B60119E3DFED00B64BEF /* script-package.cpp in Sources */,
522522
4D79B68F1A273BA000DD750C /* module-type.cpp in Sources */,
523+
766113891A31FB640042DE7F /* module-array.cpp in Sources */,
523524
4D79B6811A273BA000DD750C /* module-binary.cpp in Sources */,
524525
4D79B6841A273BA000DD750C /* module-char.cpp in Sources */,
525526
4D79B68A1A273BA000DD750C /* module-math_foundation.cpp in Sources */,
526-
4D79B6891A273BA000DD750C /* module-map.cpp in Sources */,
527527
4D79B68D1A273BA000DD750C /* module-string.cpp in Sources */,
528528
);
529529
runOnlyForDeploymentPostprocessing = 0;
@@ -532,8 +532,10 @@
532532
isa = PBXSourcesBuildPhase;
533533
buildActionMask = 2147483647;
534534
files = (
535+
7661138D1A31FE1B0042DE7F /* array.mlc in Sources */,
535536
766113541A2F4F720042DE7F /* type-convert.mlc in Sources */,
536537
766113441A2F298E0042DE7F /* list.mlc in Sources */,
538+
7661138A1A31FB690042DE7F /* module-array.cpp in Sources */,
537539
4D79B6CF1A27405600DD750C /* arithmetic.mlc in Sources */,
538540
4D79B6D01A27405600DD750C /* binary.mlc in Sources */,
539541
4D79B6D11A27405600DD750C /* bitwise.mlc in Sources */,
@@ -542,7 +544,6 @@
542544
4D79B6D61A27405600DD750C /* item.mlc in Sources */,
543545
4D79B6D81A27405600DD750C /* line.mlc in Sources */,
544546
4D79B6DB1A27405600DD750C /* logic.mlc in Sources */,
545-
4D79B6DC1A27405600DD750C /* map.mlc in Sources */,
546547
4D79B6DE1A27405600DD750C /* math.mlc in Sources */,
547548
4D79B6DF1A27405600DD750C /* segmentchunk.mlc in Sources */,
548549
4D79B6E01A27405600DD750C /* sort.mlc in Sources */,
@@ -555,7 +556,6 @@
555556
4D79B6951A273BBB00DD750C /* module-char.cpp in Sources */,
556557
4D79B6981A273BBB00DD750C /* module-list.cpp in Sources */,
557558
4D79B6991A273BBB00DD750C /* module-logic.cpp in Sources */,
558-
4D79B69A1A273BBB00DD750C /* module-map.cpp in Sources */,
559559
4D79B69B1A273BBB00DD750C /* module-math_foundation.cpp in Sources */,
560560
4D79B69C1A273BBB00DD750C /* module-math.cpp in Sources */,
561561
4D79B69D1A273BBB00DD750C /* module-sort.cpp in Sources */,

libscript/src/arithmetic.mlc

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
/*
2+
This library consists of the basic arithmetic operations of standard library of modular LiveCode.
3+
*/
4+
15
module com.livecode.arithmetic
26

37
--
@@ -6,7 +10,7 @@ public foreign handler MCArithmeticExecAddIntegerToInteger(in Value as int, inou
610
public foreign handler MCArithmeticExecAddRealToReal(in Value as double, inout Target as double) as undefined binds to "<builtin>"
711
public foreign handler MCArithmeticExecAddNumberToNumber(in Value as number, inout Target as number) as undefined binds to "<builtin>"
812
public foreign handler MCArithmeticExecSubtractIntegerFromInteger(in Value as int, inout Target as int) as undefined binds to "<builtin>"
9-
public foreign handler MCArithmeticExecSubtractRealFromReal(in Value as real, inout Target as real) as undefined binds to "<builtin>"
13+
public foreign handler MCArithmeticExecSubtractRealFromReal(in Value as double, inout Target as double) as undefined binds to "<builtin>"
1014
public foreign handler MCArithmeticExecSubtractNumberFromNumber(in Value as number, inout Target as number) as undefined binds to "<builtin>"
1115
public foreign handler MCArithmeticExecMultiplyIntegerByInteger(inout Target as int, in Value as int) as undefined binds to "<builtin>"
1216
public foreign handler MCArithmeticExecMultiplyRealByReal(inout Target as double, in Value as double) as undefined binds to "<builtin>"
@@ -57,7 +61,7 @@ public foreign handler MCArithmeticEvalNumberIsLessThanOrEqualToNumber(in Left a
5761

5862

5963
public foreign handler MCArithmeticEvalEqualToInteger(in Left as int, in Right as int, out Value as bool) as undefined binds to "<builtin>"
60-
public foreign handler MCArithmeticEvalEqualToReal(in Left as real, in Right as real, out Value as bool) as undefined binds to "<builtin>"
64+
public foreign handler MCArithmeticEvalEqualToReal(in Left as double, in Right as double, out Value as bool) as undefined binds to "<builtin>"
6165
public foreign handler MCArithmeticEvalEqualToNumber(in Left as number, in Right as number, out Value as bool) as undefined binds to "<builtin>"
6266
--
6367

@@ -175,6 +179,9 @@ Summary: Unary plus operator.
175179
Operand: An expression that evaluates to a number.
176180
output: The result of evaluating <Operand>.
177181

182+
Description:
183+
The unary plus operator is a no-op on the predefined numeric types.
184+
178185
*/
179186

180187
syntax PlusUnaryOperator is prefix operator with precedence 1
@@ -283,6 +290,21 @@ end syntax
283290
Summary: Wrap operator.
284291
Left: An expression that evaluates to a number.
285292
Right: An expression that evaluates to a number.
293+
output: If x >= 0, then x wrap y returns ((x-1) mod abs(y)) + 1.
294+
If x < 0, then x wrap y returns -((x-1) mod abs(y)) + 1.
295+
296+
Example:
297+
variable tVar as int
298+
put 5 wrap 3 into tVar -- tVar contains 2
299+
300+
Example:
301+
variable tVar as int
302+
put -3 wrap 3 into tVar -- tVar contains -3
303+
304+
Description:
305+
Use wrap to ensure the value of a variable stays within a specified range. For x,y > 0,
306+
successive values of x wrap y cycle through the sequence 1, 2, ..., y.
307+
286308
*/
287309

288310
syntax WrapOperator is neutral binary operator with precedence 1
@@ -365,7 +387,6 @@ Right: An expression that evaluates to a number.
365387
output: True if <Left> is equal to <Right>, and false otherwise.
366388
*/
367389

368-
369390
syntax IsEqualTo is neutral binary operator with precedence 4
370391
<Left: Expression> "=" <Right: Expression>
371392
begin
@@ -374,11 +395,10 @@ begin
374395
MCArithmeticEvalEqualToNumber(Left, Right, output)
375396
end syntax
376397

377-
378398
syntax IsNumber is neutral binary operator with precedence 5
379399
<Left: Expression> "is" <Right: Expression>
380400
begin
381-
--MCArithmeticEvalEqualToInteger(Left, Right, output)
401+
MCArithmeticEvalEqualToInteger(Left, Right, output)
382402
MCArithmeticEvalEqualToReal(Left, Right, output)
383403
MCArithmeticEvalEqualToNumber(Left, Right, output)
384404
end syntax

0 commit comments

Comments
 (0)