public void Bind(TypeSymbolNode symbol) { IdentifierNode = new BoundIdentifierNode(Identifier, symbol, IdentifierNode.LineNumber, IdentifierNode.Index) { ParentNode = this }; }
private bool BindInIfStatement(IfStatementNode ifStatement, VariableIdentifierMap variableIdentifierMap) { TypeSymbolNode?ifConditionType = BindInExpression(ifStatement.ConditionNode, variableIdentifierMap); if (ifConditionType == null) { return(false); } TypeSymbolNode boolType = typeManager[FrameworkType.Bool]; if (!TypeIsCompatibleWith(ifConditionType, boolType, possiblyOffendingNode: ifStatement.ConditionNode, out ImplicitConversionSymbolNode? conversion)) { return(false); } if (conversion != null) { ifStatement.ConditionNode.SpecifyImplicitConversion(conversion); } bool success = BindInStatementBlock(ifStatement.StatementNodes, variableIdentifierMap); if (!success) { return(false); } foreach (ElseIfPartNode elseIfPart in ifStatement.ElseIfPartNodes) { TypeSymbolNode?elseIfConditionType = BindInExpression(elseIfPart.ConditionNode, variableIdentifierMap); if (elseIfConditionType == null) { return(false); } success = BindInStatementBlock(elseIfPart.StatementNodes, variableIdentifierMap); if (!success) { return(false); } } success = true; if (ifStatement.ElsePartNode != null) { success = BindInStatementBlock(ifStatement.ElsePartNode.StatementNodes, variableIdentifierMap); } return(success); }
public VariableSymbolNode CreateVariable(TypeSymbolNode type) { VariableSymbolNode variable = new VariableSymbolNode(VariableIdentifier, type, isReadOnly: true, VariableIdentifierNode.LineNumber, VariableIdentifierNode.Index); VariableIdentifierNode = new BoundIdentifierNode(VariableIdentifier, variable, VariableIdentifierNode.LineNumber, VariableIdentifierNode.Index) { ParentNode = this }; return(variable); }