Better support for userdata bound types
This commit is contained in:
parent
4fa0ad9f70
commit
a4ad57e3f7
|
@ -283,6 +283,13 @@ namespace Upsilon.Binder
|
||||||
{
|
{
|
||||||
return ((TableVariableSymbol)indexerVariable).Variables[fullStopIndexExpression.Index];
|
return ((TableVariableSymbol)indexerVariable).Variables[fullStopIndexExpression.Index];
|
||||||
}
|
}
|
||||||
|
if (indexerVariable.Type == Type.UserData)
|
||||||
|
{
|
||||||
|
var bDefProperty = ((UserDataBoundTypeDefinition) ((FunctionParameterSymbol) indexerVariable)
|
||||||
|
.BoundTypeDefinition).Properties[fullStopIndexExpression.Index];
|
||||||
|
var boundDef = BoundTypeHandler.GetTypeDefinition(bDefProperty.ActualType);
|
||||||
|
return new FunctionParameterSymbol(fullStopIndexExpression.Index, boundDef);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
|
@ -495,13 +495,17 @@ namespace Upsilon.Parser
|
||||||
private ExpressionSyntax ParseFullStopIndexExpression(ExpressionSyntax expression)
|
private ExpressionSyntax ParseFullStopIndexExpression(ExpressionSyntax expression)
|
||||||
{
|
{
|
||||||
var fullStop = MatchToken(SyntaxKind.FullStop);
|
var fullStop = MatchToken(SyntaxKind.FullStop);
|
||||||
var index = MatchToken(SyntaxKind.Identifier);
|
if (Current.Kind == SyntaxKind.Identifier)
|
||||||
if (index is IdentifierToken identifier)
|
|
||||||
{
|
{
|
||||||
return new FullStopIndexExpressionSyntax(expression, fullStop, identifier);
|
var index = NextToken();
|
||||||
|
return new FullStopIndexExpressionSyntax(expression, fullStop, (IdentifierToken) index);
|
||||||
|
|
||||||
}
|
}
|
||||||
_diagnostics.LogBadCharacter(expression.Span, SyntaxKind.Identifier);
|
_diagnostics.LogBadCharacter(expression.Span, SyntaxKind.Identifier);
|
||||||
return new BadExpressionSyntax();
|
// We'll still want to return a index expression, but we just express that the identifier is empty.
|
||||||
|
// This is helpful for tools, etc
|
||||||
|
return new FullStopIndexExpressionSyntax(expression, fullStop,
|
||||||
|
new IdentifierToken(string.Empty, fullStop.Span.End));
|
||||||
}
|
}
|
||||||
|
|
||||||
private ExpressionSyntax ParseParenthesizedExpression()
|
private ExpressionSyntax ParseParenthesizedExpression()
|
||||||
|
|
Loading…
Reference in New Issue