Skip to content

Commit ad18044

Browse files
committed
Add constant modifiers to built in function parameters
1 parent 9ee4cda commit ad18044

File tree

1 file changed

+35
-35
lines changed

1 file changed

+35
-35
lines changed

FanScript/Compiler/Symbols/BuiltinFunctions.cs

Lines changed: 35 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -206,25 +206,25 @@ private static class Game
206206
[FunctionDoc(
207207
ParameterInfos = [
208208
"""
209-
Time to win (in frames), must be constant.
209+
Time to win (in frames).
210210
"""
211211
]
212212
)]
213213
public static readonly FunctionSymbol Win
214214
= new BuiltinFunctionSymbol(gameNamespace, "win", [
215-
new ParameterSymbol("DELAY", TypeSymbol.Float),
215+
new ParameterSymbol("DELAY", Modifiers.Constant, TypeSymbol.Float),
216216
], TypeSymbol.Void, (call, context) => emitAX0(call, context, Blocks.Game.Win, constantTypes: [typeof(byte)]));
217217

218218
[FunctionDoc(
219219
ParameterInfos = [
220220
"""
221-
Time to lose (in frames), must be constant.
221+
Time to lose (in frames).
222222
"""
223223
]
224224
)]
225225
public static readonly FunctionSymbol Lose
226226
= new BuiltinFunctionSymbol(gameNamespace, "lose", [
227-
new ParameterSymbol("DELAY", TypeSymbol.Float),
227+
new ParameterSymbol("DELAY", Modifiers.Constant, TypeSymbol.Float),
228228
], TypeSymbol.Void, (call, context) => emitAX0(call, context, Blocks.Game.Lose, constantTypes: [typeof(byte)]));
229229

230230
[FunctionDoc(
@@ -239,15 +239,15 @@ public static readonly FunctionSymbol Lose
239239
The new amount of coins.
240240
""",
241241
"""
242-
How players are ranked, one of <link type="con">RANKING</>, must be constant.
242+
How players are ranked, one of <link type="con">RANKING</>.
243243
"""
244244
]
245245
)]
246246
public static readonly FunctionSymbol SetScore
247247
= new BuiltinFunctionSymbol(gameNamespace, "setScore", [
248248
new ParameterSymbol("score", TypeSymbol.Float),
249249
new ParameterSymbol("coins", TypeSymbol.Float),
250-
new ParameterSymbol("RANKING", TypeSymbol.Float),
250+
new ParameterSymbol("RANKING", Modifiers.Constant, TypeSymbol.Float),
251251
], TypeSymbol.Void, (call, context) => emitAX0(call, context, Blocks.Game.SetScore, constantTypes: [typeof(byte)]));
252252

253253
[FunctionDoc(
@@ -277,7 +277,7 @@ public static readonly FunctionSymbol SetCamera
277277
new ParameterSymbol("position", TypeSymbol.Vector3),
278278
new ParameterSymbol("rotation", TypeSymbol.Rotation),
279279
new ParameterSymbol("range", TypeSymbol.Float),
280-
new ParameterSymbol("PERSPECTIVE", TypeSymbol.Bool),
280+
new ParameterSymbol("PERSPECTIVE", Modifiers.Constant, TypeSymbol.Bool),
281281
], TypeSymbol.Void, (call, context) => emitAX0(call, context, Blocks.Game.SetCamera, constantTypes: [typeof(byte)]));
282282

283283
[FunctionDoc(
@@ -388,7 +388,7 @@ public static readonly FunctionSymbol GetCurrentFrame
388388
""",
389389
ParameterInfos = [
390390
"""
391-
The name of this section, will be shown as a header above the items, must be constant.
391+
The name of this section, will be shown as a header above the items.
392392
"""
393393
],
394394
Related = [
@@ -399,7 +399,7 @@ public static readonly FunctionSymbol GetCurrentFrame
399399
)]
400400
public static readonly FunctionSymbol ShopSection
401401
= new BuiltinFunctionSymbol(gameNamespace, "shopSection", [
402-
new ParameterSymbol("NAME", TypeSymbol.String),
402+
new ParameterSymbol("NAME", Modifiers.Constant, TypeSymbol.String),
403403
], TypeSymbol.Void, (call, context) =>
404404
{
405405
object?[]? constants = context.ValidateConstants(call.Arguments.AsMemory(), true);
@@ -426,13 +426,13 @@ public static readonly FunctionSymbol ShopSection
426426
Which object to display for the item.
427427
""",
428428
"""
429-
Name of the item, must be constant.
429+
Name of the item.
430430
""",
431431
"""
432-
Maximum number of times the item can be bought, can be 2-100 or one of <link type="con">MAX_ITEMS</>, must be constant.
432+
Maximum number of times the item can be bought, can be 2-100 or one of <link type="con">MAX_ITEMS</>.
433433
""",
434434
"""
435-
Specifies what the initial price is and how it increases, one of <link type="con">PRICE_INCREASE</>, must be constant.
435+
Specifies what the initial price is and how it increases, one of <link type="con">PRICE_INCREASE</>.
436436
"""
437437
],
438438
Related = [
@@ -445,9 +445,9 @@ public static readonly FunctionSymbol MenuItem
445445
= new BuiltinFunctionSymbol(gameNamespace, "menuItem", [
446446
new ParameterSymbol("variable", Modifiers.Ref, TypeSymbol.Float),
447447
new ParameterSymbol("picture", TypeSymbol.Object),
448-
new ParameterSymbol("NAME", TypeSymbol.String),
449-
new ParameterSymbol("MAX_ITEMS", TypeSymbol.Float),
450-
new ParameterSymbol("PRICE_INCREASE", TypeSymbol.Float),
448+
new ParameterSymbol("NAME", Modifiers.Constant, TypeSymbol.String),
449+
new ParameterSymbol("MAX_ITEMS", Modifiers.Constant, TypeSymbol.Float),
450+
new ParameterSymbol("PRICE_INCREASE", Modifiers.Constant, TypeSymbol.Float),
451451
], TypeSymbol.Void, (call, context) => emitAX0(call, context, Blocks.Game.MenuItem, constantTypes: [typeof(string), typeof(byte), typeof(byte)]));
452452
}
453453

@@ -457,14 +457,14 @@ private static class Objects
457457

458458
[FunctionDoc(
459459
Info = """
460-
Returns the object at <link type="param">position</>.
460+
Returns the object at <link type="param">POSITION</>.
461461
""",
462462
ReturnValueInfo = """
463-
The object at <link type="param">position</>.
463+
The object at <link type="param">POSITION</>.
464464
""",
465465
ParameterInfos = [
466466
"""
467-
Position of the object, must be constant.
467+
Position of the object.
468468
"""
469469
],
470470
Related = [
@@ -475,7 +475,7 @@ private static class Objects
475475
)]
476476
public static readonly FunctionSymbol GetObject
477477
= new BuiltinFunctionSymbol(objectNamespace, "getObject", [
478-
new ParameterSymbol("position", TypeSymbol.Vector3),
478+
new ParameterSymbol("POSITION", Modifiers.Constant, TypeSymbol.Vector3),
479479
], TypeSymbol.Object, (call, context) =>
480480
{
481481
BoundConstant? constant = call.Arguments[0].ConstantValue;
@@ -510,13 +510,13 @@ The object at (<link type="param">x</>, <link type="param">y</>, <link type="par
510510
""",
511511
ParameterInfos = [
512512
"""
513-
X position of the object, must be constant.
513+
X position of the object.
514514
""",
515515
"""
516-
Y position of the object, must be constant.
516+
Y position of the object.
517517
""",
518518
"""
519-
Z position of the object, must be constant.
519+
Z position of the object.
520520
"""
521521
],
522522
Related = [
@@ -527,9 +527,9 @@ The object at (<link type="param">x</>, <link type="param">y</>, <link type="par
527527
)]
528528
public static readonly FunctionSymbol GetObject2
529529
= new BuiltinFunctionSymbol(objectNamespace, "getObject", [
530-
new ParameterSymbol("x", TypeSymbol.Float),
531-
new ParameterSymbol("y", TypeSymbol.Float),
532-
new ParameterSymbol("z", TypeSymbol.Float),
530+
new ParameterSymbol("X", Modifiers.Constant, TypeSymbol.Float),
531+
new ParameterSymbol("Y", Modifiers.Constant, TypeSymbol.Float),
532+
new ParameterSymbol("Z", Modifiers.Constant, TypeSymbol.Float),
533533
], TypeSymbol.Object, (call, context) =>
534534
{
535535
object?[]? args = context.ValidateConstants(call.Arguments.AsMemory(), true);
@@ -820,10 +820,10 @@ Pitch of the sound (0 - 4).
820820
The channel at which the sound is playing (0 - 9, or -1 if all other channels are used).
821821
""",
822822
"""
823-
If the sound should loop, must be constant.
823+
If the sound should loop.
824824
""",
825825
"""
826-
Which sound to play, one of <link type="con">SOUND</>, must be constant.
826+
Which sound to play, one of <link type="con">SOUND</>.
827827
"""
828828
],
829829
Related = [
@@ -841,8 +841,8 @@ public static readonly FunctionSymbol PlaySound
841841
new ParameterSymbol("volume", TypeSymbol.Float),
842842
new ParameterSymbol("pitch", TypeSymbol.Float),
843843
new ParameterSymbol("channel", Modifiers.Out, TypeSymbol.Float),
844-
new ParameterSymbol("LOOP", TypeSymbol.Bool),
845-
new ParameterSymbol("SOUND", TypeSymbol.Float),
844+
new ParameterSymbol("LOOP", Modifiers.Constant, TypeSymbol.Bool),
845+
new ParameterSymbol("SOUND", Modifiers.Constant, TypeSymbol.Float),
846846
], TypeSymbol.Void, (call, context) =>
847847
{
848848
object?[]? values = context.ValidateConstants(call.Arguments.AsMemory(^2..), true);
@@ -1396,15 +1396,15 @@ Creates a joystick on screen and outputs the direction in which it is held.
13961396
The direction which the joystick is held.
13971397
""",
13981398
"""
1399-
One of <link type="con">JOYSTICK_TYPE</>, must be constant.
1399+
One of <link type="con">JOYSTICK_TYPE</>.
14001400
"""
14011401
]
14021402
)]
14031403
public static readonly FunctionSymbol Joystick
14041404
= new BuiltinFunctionSymbol(controlNamespace, "joystick",
14051405
[
14061406
new ParameterSymbol("joyDir", Modifiers.Out, TypeSymbol.Vector3),
1407-
new ParameterSymbol("JOYSTICK_TYPE", TypeSymbol.Float),
1407+
new ParameterSymbol("JOYSTICK_TYPE", Modifiers.Constant, TypeSymbol.Float),
14081408
], TypeSymbol.Void, (call, context) =>
14091409
{
14101410
object?[]? values = context.ValidateConstants(call.Arguments.AsMemory(Range.StartAt(1)), true);
@@ -2360,7 +2360,7 @@ public static readonly FunctionSymbol Ptr_SetValue
23602360
""",
23612361
ParameterInfos = [
23622362
"""
2363-
The text of the comment, must be constant.
2363+
The text of the comment.
23642364
"""
23652365
],
23662366
Examples = """
@@ -2373,7 +2373,7 @@ public static readonly FunctionSymbol Ptr_SetValue
23732373
public static readonly FunctionSymbol FcComment
23742374
= new BuiltinFunctionSymbol(builtinNamespace, "fcComment",
23752375
[
2376-
new ParameterSymbol("TEXT", TypeSymbol.String)
2376+
new ParameterSymbol("TEXT", Modifiers.Constant, TypeSymbol.String)
23772377
], TypeSymbol.Void, (call, context) =>
23782378
{
23792379
object?[]? constants = context.ValidateConstants(call.Arguments.AsMemory(), true);
@@ -2394,7 +2394,7 @@ Returns a block with the specified id.
23942394
""",
23952395
ParameterInfos = [
23962396
"""
2397-
Id of the block, one of <link type="con">BLOCK</>, must be constant.
2397+
Id of the block, one of <link type="con">BLOCK</>.
23982398
"""
23992399
],
24002400
Remarks = [
@@ -2414,7 +2414,7 @@ The id of a block can be get by placing the block at (0, 0, 0) and running log(g
24142414
public static readonly FunctionSymbol GetBlockById
24152415
= new BuiltinFunctionSymbol(builtinNamespace, "getBlockById",
24162416
[
2417-
new ParameterSymbol("BLOCK", TypeSymbol.Float)
2417+
new ParameterSymbol("BLOCK", Modifiers.Constant, TypeSymbol.Float)
24182418
], TypeSymbol.Object, (call, context) =>
24192419
{
24202420
object?[]? constants = context.ValidateConstants(call.Arguments.AsMemory(), true);

0 commit comments

Comments
 (0)