public ElementAccessSharpnode(ElementAccessExpressionSyntax syntax) : base(syntax) { this.eaes = syntax; this.Container = RoslynToSharpnode.MapExpression(syntax.Expression); // Only single-dimensional arrays are supported. this.Index = RoslynToSharpnode.MapExpression(syntax.ArgumentList.Arguments[0].Expression); }
public override void Run(List <ExpressionSharpnode> arguments, SyntaxNode originalNode, TranslationContext context) { if (this.MethodGroup is MemberAccessExpressionSyntax) { MemberAccessExpressionSyntax memberAccess = (MemberAccessExpressionSyntax)this.MethodGroup; var leftExpression = RoslynToSharpnode.MapExpression(memberAccess.Expression); // There are some Viper purity requirements here, but they are checked by the verifier, // so we don't need to check them. var leftExpressionResult = leftExpression.Translate(context); var rightExpressionResult = arguments[0].Translate(context); Silvernode implies = new BinaryExpressionSilvernode( leftExpressionResult.Silvernode, this._operator, rightExpressionResult.Silvernode, originalNode ); this.Errors.AddRange(leftExpressionResult.Errors); this.Errors.AddRange(rightExpressionResult.Errors); this.Prependors.AddRange(leftExpressionResult.PrependTheseSilvernodes); this.Prependors.AddRange(rightExpressionResult.PrependTheseSilvernodes); this.Silvernode = implies; } else { this.Errors.Add(new Error(Diagnostics.SSIL110_InvalidSyntax, originalNode, "member access expression expected")); this.Silvernode = new TextSilvernode(Constants.SilverErrorString, originalNode); } }
public CompoundAssignmentExpressionSharpnode(AssignmentExpressionSyntax syntax, string operation) : base(syntax) { this.operation = operation; this.Left = RoslynToSharpnode.MapExpression(syntax.Left); this.Right = RoslynToSharpnode.MapExpression(syntax.Right); }
public BinaryExpressionSharpnode(BinaryExpressionSyntax syntax, string @operator) : base(syntax) { this._syntax = syntax; this.Operator = @operator; this.Left = RoslynToSharpnode.MapExpression(syntax.Left); this.Right = RoslynToSharpnode.MapExpression(syntax.Right); }
public ReturnStatementSharpnode(ReturnStatementSyntax stmt) : base(stmt) { if (stmt.Expression != null) { this.Expression = RoslynToSharpnode.MapExpression(stmt.Expression); } }
public ObjectCreationExpressionSharpnode(ObjectCreationExpressionSyntax syntax) : base(syntax) { foreach (var argument in syntax.ArgumentList.Arguments) { this.Arguments.Add(RoslynToSharpnode.MapExpression(argument.Expression)); } }
public InvocationExpressionSharpnode(InvocationExpressionSyntax syntax) : base(syntax) { this.MethodGroup = syntax.Expression; this.methodGroupSharpnode = RoslynToSharpnode.MapExpression(syntax.Expression); foreach (var argument in syntax.ArgumentList.Arguments) { this.Arguments.Add(RoslynToSharpnode.MapExpression(argument.Expression)); } }
private void LoadFrom(InitializerExpressionSyntax syntax) { if (syntax == null) { error = new Error(Diagnostics.SSIL108_FeatureNotSupported, this.OriginalNode, "rank-initialized arrays"); return; } foreach (var s in syntax.Expressions) { Arguments.Add(RoslynToSharpnode.MapExpression(s)); } }
public LambdaSharpnode(SimpleLambdaExpressionSyntax syntax) : base(syntax) { this.parameter = new ParameterSharpnode(syntax.Parameter); if (syntax.Body is ExpressionSyntax) { this.body = RoslynToSharpnode.MapExpression((ExpressionSyntax)syntax.Body); } else { this.errorneousResult = new Error( Diagnostics.SSIL126_LambdasMustBeExpressions, syntax.Body); } }
private void Init(VariableDeclarationSyntax syntax) { var typeSyntax = syntax.Type; foreach (var variable in syntax.Variables) { ExpressionSharpnode initialValue = null; if (variable.Initializer != null) { initialValue = RoslynToSharpnode.MapExpression(variable.Initializer.Value); } SimpleLocalDeclarationSharpnode declaration = new SimpleLocalDeclarationSharpnode( typeSyntax, initialValue, variable) ; this.Declarations.Add(declaration); } }
public LambdaSharpnode(ParenthesizedLambdaExpressionSyntax syntax) : base(syntax) { // We only allow for a single kind of lambda expressions: those that fit ForAll and Exists. if (syntax.ParameterList.Parameters.Count != 1) { this.errorneousResult = new Error( Diagnostics.SSIL125_LambdasMustHaveSingleParameter, syntax.ParameterList); return; } this.parameter = new ParameterSharpnode(syntax.ParameterList.Parameters[0]); if (syntax.Body is ExpressionSyntax) { this.body = RoslynToSharpnode.MapExpression((ExpressionSyntax)syntax.Body); } else { this.errorneousResult = new Error( Diagnostics.SSIL126_LambdasMustBeExpressions, syntax.Body); } }
public ForStatementSharpnode(ForStatementSyntax stmt) : base(stmt) { this.Condition = RoslynToSharpnode.MapExpression(stmt.Condition); this.Statement = RoslynToSharpnode.MapStatement(stmt.Statement); // Add declarations if (stmt.Declaration != null) { this.Initializers.Add(new LocalDeclarationSharpnode(stmt.Declaration)); } // Add initializers if (stmt.Initializers != null) { foreach (var initializer in stmt.Initializers) { Initializers.Add(new ExpressionStatementSharpnode(initializer)); } } foreach (var incrementor in stmt.Incrementors) { this.Incrementors.Add(RoslynToSharpnode.MapExpression(incrementor)); } }
public IfStatementSharpnode(IfStatementSyntax stmt) : base(stmt) { this.Condition = RoslynToSharpnode.MapExpression(stmt.Condition); this.Then = RoslynToSharpnode.MapStatement(stmt.Statement); this.Else = stmt.Else != null?RoslynToSharpnode.MapStatement(stmt.Else.Statement) : null; }
public GotoStatementSharpnode(GotoStatementSyntax stmt) : base(stmt) { this.Identifier = RoslynToSharpnode.MapExpression(stmt.Expression); }
public IncrementExpressionSharpnode(PostfixUnaryExpressionSyntax syntax, IncrementExpressionDirection direction) : base(syntax) { this.direction = direction; this.order = IncrementExpressionOrder.Post; this.expression = RoslynToSharpnode.MapExpression(syntax.Operand); }
public SimpleAssignmentExpressionSharpnode(AssignmentExpressionSyntax syntax) : base(syntax) { this.Left = RoslynToSharpnode.MapExpression(syntax.Left); this.Right = RoslynToSharpnode.MapExpression(syntax.Right); }
public PrefixUnaryExpressionSharpnode(PrefixUnaryExpressionSyntax syntax, string @operator) : base(syntax) { this.Operator = @operator; this.Expression = RoslynToSharpnode.MapExpression(syntax.Operand); }
public ConditionalExpressionSharpnode(ConditionalExpressionSyntax syntax) : base(syntax) { this.Condition = RoslynToSharpnode.MapExpression(syntax.Condition); this.WhenTrue = RoslynToSharpnode.MapExpression(syntax.WhenTrue); this.WhenFalse = RoslynToSharpnode.MapExpression(syntax.WhenFalse); }
public ParenthesizedExpressionSharpnode(ParenthesizedExpressionSyntax syntax) : base(syntax) { this.InnerExpression = RoslynToSharpnode.MapExpression(syntax.Expression); }
public ExpressionStatementSharpnode(ExpressionStatementSyntax originalNode) : base(originalNode) { this.Expression = RoslynToSharpnode.MapExpression(originalNode.Expression); }