public TO2Type FindVariableLocal(IBlockContext context, string name) { for (int i = 0; i < declarations.Count; i++) { DeclarationParameter declaration = declarations[i]; if (declaration.IsPlaceholder || name != declaration.target) { continue; } if (declaration.type != null) { return(declaration.type); } RealizedType elementType = sourceExpression.ResultType(context) ?.ForInSource(context.ModuleContext, null).ElementType; if (elementType == null) { return(null); } switch (elementType) { case TupleType tupleType: return(i < tupleType.itemTypes.Count ? tupleType.itemTypes[i] : null); case RecordType recordType: return(recordType.ItemTypes.Get(declaration.source)); } } return(null); }
public VariableDeclaration(DeclarationParameter declaration, bool isConst, Expression expression, Position start = new Position(), Position end = new Position()) : base(start, end) { this.declaration = declaration; this.isConst = isConst; this.expression = expression; this.expression.TypeHint = context => this.declaration.type?.UnderlyingType(context.ModuleContext); }