Skip to content

Commit 7dfbf99

Browse files
committed
Use ParameterSymbol instead of EventTypeParam
1 parent c62fdc9 commit 7dfbf99

File tree

5 files changed

+20
-27
lines changed

5 files changed

+20
-27
lines changed

FanScript.Cli/Program.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ static int runVerb<T>(Func<T, int> action, T arg, string name)
5858
try
5959
{
6060
#endif
61-
return action(arg);
61+
return action(arg);
6262
#if !DEBUG
6363
}
6464
catch (Exception ex)

FanScript.LangServer/Handlers/CompletionHandler.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ internal class CompletionHandler : CompletionHandlerBase
7373
builder.Append(' ');
7474
}
7575

76-
if (param.IsConstant)
76+
if (param.Modifiers.HasFlag(Modifiers.Constant))
7777
builder.Append(param.Name);
7878
}
7979

FanScript/Compiler/Binding/Binder.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -354,7 +354,6 @@ private BoundStatement BindEventStatement(EventStatementSyntax syntax)
354354
ImmutableArray<ParameterSymbol> parameters = type
355355
.GetInfo()
356356
.Parameters
357-
.Select(param => param.ToParameter())
358357
.ToImmutableArray();
359358

360359
enterScope();
@@ -1260,10 +1259,10 @@ private TypeSymbol BindTypeClause(TypeClauseSyntax? syntax)
12601259
diagnostics.ReportArgumentMustHaveModifier(argumentLocation, parameter.Name, Modifiers.Ref);
12611260
else if (parameter.Modifiers.HasFlag(Modifiers.Out) && !argMods.Enum.HasFlag(Modifiers.Out))
12621261
diagnostics.ReportArgumentMustHaveModifier(argumentLocation, parameter.Name, Modifiers.Out);
1263-
else if (argMods.Enum.MakesTargetReference(out Modifiers? makesRefMod) && (argument is not BoundVariableExpression variable ||
1262+
if (argMods.Enum.MakesTargetReference(out Modifiers? makesRefMod) && (argument is not BoundVariableExpression variable ||
12641263
(variable.Variable.IsReadOnly && argument.Syntax.Kind != SyntaxKind.VariableDeclarationExpression && variable.Variable is not NullVariableSymbol)))
12651264
diagnostics.ReportByRefArgMustBeVariable(argumentLocation, makesRefMod.Value);
1266-
else if (parameter.Modifiers.HasFlag(Modifiers.Constant) && argument.ConstantValue is null)
1265+
if (parameter.Modifiers.HasFlag(Modifiers.Constant) && argument.ConstantValue is null)
12671266
diagnostics.ReportValueMustBeConstant(argument.Syntax.Location);
12681267

12691268
boundArguments[i] = BindConversion(argumentLocation, argument, parameter.Type);

FanScript/Compiler/EventType.cs

Lines changed: 14 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -166,27 +166,27 @@ public static class EventTypeE
166166
new EventTypeInfo(EventType.LateUpdate, []),
167167
new EventTypeInfo(EventType.BoxArt, []),
168168
new EventTypeInfo(EventType.Touch, [
169-
new EventTypeParam("screenX", Modifiers.Out, TypeSymbol.Float),
170-
new EventTypeParam("screenY", Modifiers.Out, TypeSymbol.Float),
171-
new EventTypeParam("TOUCH_STATE", 0, TypeSymbol.Float, true),
172-
new EventTypeParam("TOUCH_FINGER", 0, TypeSymbol.Float, true),
169+
new ParameterSymbol("screenX", Modifiers.Out, TypeSymbol.Float),
170+
new ParameterSymbol("screenY", Modifiers.Out, TypeSymbol.Float),
171+
new ParameterSymbol("TOUCH_STATE", Modifiers.Constant, TypeSymbol.Float),
172+
new ParameterSymbol("TOUCH_FINGER", Modifiers.Constant, TypeSymbol.Float),
173173
]),
174174
new EventTypeInfo(EventType.Swipe, [
175-
new EventTypeParam("direction", Modifiers.Out, TypeSymbol.Vector3),
175+
new ParameterSymbol("direction", Modifiers.Out, TypeSymbol.Vector3),
176176
]),
177177
new EventTypeInfo(EventType.Button, [
178-
new EventTypeParam("BUTTON_TYPE", 0, TypeSymbol.Float, true),
178+
new ParameterSymbol("BUTTON_TYPE", Modifiers.Constant, TypeSymbol.Float),
179179
]),
180180
new EventTypeInfo(EventType.Collision, [
181-
new EventTypeParam("object1", 0, TypeSymbol.Object),
182-
new EventTypeParam("object2", Modifiers.Out, TypeSymbol.Object),
183-
new EventTypeParam("impulse", Modifiers.Out, TypeSymbol.Float),
184-
new EventTypeParam("normal", Modifiers.Out, TypeSymbol.Vector3),
181+
new ParameterSymbol("object1", 0, TypeSymbol.Object),
182+
new ParameterSymbol("object2", Modifiers.Out, TypeSymbol.Object),
183+
new ParameterSymbol("impulse", Modifiers.Out, TypeSymbol.Float),
184+
new ParameterSymbol("normal", Modifiers.Out, TypeSymbol.Vector3),
185185
]),
186186
new EventTypeInfo(EventType.Loop, [
187-
new EventTypeParam("start", 0, TypeSymbol.Float),
188-
new EventTypeParam("stop", 0, TypeSymbol.Float),
189-
new EventTypeParam("counter", Modifiers.Out, TypeSymbol.Float),
187+
new ParameterSymbol("start", 0, TypeSymbol.Float),
188+
new ParameterSymbol("stop", 0, TypeSymbol.Float),
189+
new ParameterSymbol("counter", Modifiers.Out, TypeSymbol.Float),
190190
]),
191191
};
192192

@@ -200,7 +200,7 @@ protected override EventType GetKeyForItem(EventTypeInfo item)
200200
}
201201
}
202202

203-
public record EventTypeInfo(EventType Type, ImmutableArray<EventTypeParam> Parameters)
203+
public record EventTypeInfo(EventType Type, ImmutableArray<ParameterSymbol> Parameters)
204204
{
205205
public override string ToString()
206206
{
@@ -232,10 +232,4 @@ public override string ToString()
232232
.ToString();
233233
}
234234
}
235-
236-
public record EventTypeParam(string Name, Modifiers Modifiers, TypeSymbol Type, bool IsConstant = false)
237-
{
238-
public ParameterSymbol ToParameter()
239-
=> new ParameterSymbol(Name, Modifiers, Type);
240-
}
241235
}

FanScript/Compiler/Symbols/BuiltinFunctions.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -503,10 +503,10 @@ public static readonly FunctionSymbol GetObject
503503

504504
[FunctionDoc(
505505
Info = """
506-
Returns the object at (<link type="param">x</>, <link type="param">y</>, <link type="param">z</>).
506+
Returns the object at (<link type="param">X</>, <link type="param">Y</>, <link type="param">Z</>).
507507
""",
508508
ReturnValueInfo = """
509-
The object at (<link type="param">x</>, <link type="param">y</>, <link type="param">z</>).
509+
The object at (<link type="param">X</>, <link type="param">Y</>, <link type="param">Z</>).
510510
""",
511511
ParameterInfos = [
512512
"""

0 commit comments

Comments
 (0)