Esempio n. 1
0
        private BaseBoundStatement BindAssignmentExpressionStatement(ExpressionStatementSyntax syntax, BoundBinaryExpression assignment)
        {
            switch (assignment.Left)
            {
            case BoundVariableExpression variable:
            {
                return(new BoundVariableAssignmentStatement(syntax, variable, assignment.Right));
            }

            case BoundArrayAccessExpression arrayAccess:
            {
                return(new BoundArrayAssignmentStatement(syntax, arrayAccess, assignment.Right));
            }

            case BoundLibraryPropertyExpression property:
            {
                if (Libraries.Types[property.Library.Name].Properties[property.Name].Setter.IsDefault())
                {
                    this.diagnostics.ReportPropertyHasNoSetter(property.Syntax.Range, property.Library.Name, property.Name);
                }

                return(new BoundPropertyAssignmentStatement(syntax, property, assignment.Right));
            }

            case BoundLibraryEventExpression @event:
            {
                if (assignment.Right is BoundSubModuleExpression subModule)
                {
                    return(new BoundEventAssignmentStatement(syntax, @event, subModule.Name));
                }
                else
                {
                    this.diagnostics.ReportAssigningNonSubModuleToEvent(@event.Syntax.Range);
                    return(new BoundInvalidExpressionStatement(syntax, assignment));
                }
            }

            default:
            {
                this.diagnostics.ReportUnassignedExpressionStatement(syntax.Range);
                return(new BoundInvalidExpressionStatement(syntax, assignment));
            }
            }
        }
 private protected virtual void VisitBinaryExpression(BoundBinaryExpression node)
 {
     this.DefaultVisit(node);
 }