private LanguageExpression ConvertArrayAccess(ArrayAccessSyntax arrayAccess) { // if there is an array access on a resource/module reference, we have to generate differently // when constructing the reference() function call, the resource name expression needs to have its local // variable replaced with <loop array expression>[this array access' index expression] if (arrayAccess.BaseExpression is VariableAccessSyntax || arrayAccess.BaseExpression is ResourceAccessSyntax) { if (context.SemanticModel.ResourceMetadata.TryLookup(arrayAccess.BaseExpression) is { } resource&& resource.Symbol.IsCollection) { var movedSyntax = context.Settings.EnableSymbolicNames ? resource.Symbol.NameSyntax : resource.NameSyntax; return(this.CreateConverterForIndexReplacement(movedSyntax, arrayAccess.IndexExpression, arrayAccess) .GetReferenceExpression(resource, arrayAccess.IndexExpression, true)); } switch (this.context.SemanticModel.GetSymbolInfo(arrayAccess.BaseExpression)) { case ModuleSymbol { IsCollection: true } moduleSymbol: var moduleConverter = this.CreateConverterForIndexReplacement(ExpressionConverter.GetModuleNameSyntax(moduleSymbol), arrayAccess.IndexExpression, arrayAccess); // TODO: Can this return a language expression? return(moduleConverter.ToFunctionExpression(arrayAccess.BaseExpression)); } } return(AppendProperties( ToFunctionExpression(arrayAccess.BaseExpression), ConvertExpression(arrayAccess.IndexExpression))); }
public void EmitResourceIdReference(ModuleSymbol moduleSymbol, SyntaxBase?indexExpression, SyntaxBase newContext) { var converterForContext = this.converter.CreateConverterForIndexReplacement(ExpressionConverter.GetModuleNameSyntax(moduleSymbol), indexExpression, newContext); var resourceIdExpression = converterForContext.GetFullyQualifiedResourceId(moduleSymbol); var serialized = ExpressionSerializer.SerializeExpression(resourceIdExpression); writer.WriteValue(serialized); }