/// <summary> /// </summary> /// <param name="metadata"></param> /// <param name="codeGenerator"></param> /// <param name="functionDeclaration"></param> /// <param name="parameters"></param> /// <returns></returns> public ExpressionSyntax Generate(IStandardFunctionMetadata metadata, MsilBinGenerator codeGenerator, FunctionDeclaration functionDeclaration, IReadOnlyList <Expression> parameters) { var reference = (VariableReferenceExpression)parameters[0]; // generates {reference} = System.{type}.Parse(Console.ReadLine()) return(SyntaxFactory.AssignmentExpression( SyntaxKind.SimpleAssignmentExpression, codeGenerator.CompileExpression(reference), SyntaxFactory.InvocationExpression( SyntaxFactory.MemberAccessExpression( SyntaxKind.SimpleMemberAccessExpression, SyntaxFactory.MemberAccessExpression( SyntaxKind.SimpleMemberAccessExpression, MsilBinGenerator.MapIdentifierName("System"), MsilBinGenerator.MapIdentifierName(MapTypeNames[functionDeclaration.Name])), MsilBinGenerator.MapIdentifierName("Parse"))) .WithArgumentList( SyntaxFactory.ArgumentList( SyntaxFactory.SingletonSeparatedList( SyntaxFactory.Argument( SyntaxFactory.InvocationExpression( SyntaxFactory.MemberAccessExpression( SyntaxKind.SimpleMemberAccessExpression, MsilBinGenerator.MapIdentifierName("Console"), MsilBinGenerator.MapIdentifierName("ReadLine"))))))))); }
public ExpressionSyntax Generate(IStandardFunctionMetadata metadata, MsilBinGenerator codeGenerator, FunctionDeclaration functionDeclaration, IReadOnlyList <Expression> parameters) { return(SyntaxFactory.InvocationExpression( SyntaxFactory.MemberAccessExpression( SyntaxKind.SimpleMemberAccessExpression, MsilBinGenerator.MapIdentifierName("Math"), MsilBinGenerator.MapIdentifierName("Abs"))) .WithArgumentList( SyntaxFactory.ArgumentList( SyntaxFactory.SingletonSeparatedList( SyntaxFactory.Argument(codeGenerator.CompileExpression(parameters[0])))))); }