Exemplo n.º 1
0
        /// <summary>
        ///     Determine if contains keyword and if it's possible to convert non-keyword types to keyword type
        ///     ie. monday = 4 or month in (may,...,december)
        /// </summary>
        /// <param name="left">Node do check.</param>
        /// <param name="right">Node do check.</param>
        /// <returns>true if can be generalized, else false.</returns>
        private static bool CanBeGeneralized(RdlSyntaxNode left, RdlSyntaxNode right)
        {
            if (right.Token.Value == null)
            {
                return(false);
            }

            if (right.Token.Value.IsKeyword() &&
                RdlMetadata.IsTypePossibleToConvert(left.ReturnType, typeof(int)))
            {
                return(true);
            }

            if (left.Token.Value == null)
            {
                return(false);
            }

            if (left.Token.Value.IsKeyword() &&
                RdlMetadata.IsTypePossibleToConvert(typeof(int), right.ReturnType))
            {
                return(true);
            }

            return(false);
        }
Exemplo n.º 2
0
        public override void Visit(InNode node)
        {
            try
            {
                var dstType = node.Left.ReturnType.GetUnderlyingNullable();

                var hasMixedTypes = false;
                foreach (var desc in node.Right.Descendants)
                {
                    if ((dstType == desc.ReturnType || CanBeGeneralized(node.Left, desc)) ||
                        RdlMetadata.IsTypePossibleToConvert(dstType, desc.ReturnType))
                    {
                        continue;
                    }

                    hasMixedTypes = true;
                    break;
                }

                if (hasMixedTypes)
                {
                    ReportHasMixedTypes(node);
                }
            }
            catch (Exception e)
            {
                _criticalErrors.Add(e);
            }
        }
Exemplo n.º 3
0
 /// <summary>
 ///     Instantiate code generator object with custom startAt
 /// </summary>
 /// <param name="metadatas">Metadata manager with functions registered.</param>
 /// <param name="startAt">Starting from parameter.</param>
 /// <param name="callMethodContext">Object that contains methods to invoke.</param>
 /// <param name="functionOccurences"></param>
 private CodeGenerator(RdlMetadata metadatas, DateTimeOffset startAt, object callMethodContext, IReadOnlyDictionary <string, int> functionOccurences)
 {
     _functions = new Stack <List <IRdlInstruction> >();
     _functions.Push(new List <IRdlInstruction>());
     _stopAt             = null;
     _labels             = new Dictionary <string, int>();
     _metadatas          = metadatas;
     _startAt            = startAt;
     _callMethodContext  = callMethodContext;
     _functionOccurences = functionOccurences;
 }
Exemplo n.º 4
0
        private void ReportReturnTypesAreNotSame(BinaryNode node, string nodeName)
        {
            var left  = node.Left.ReturnType.GetUnderlyingNullable();
            var right = node.Right.ReturnType.GetUnderlyingNullable();

            if (!RdlMetadata.IsTypePossibleToConvert(left, right) && !CanBeGeneralized(node))
            {
                AddSyntaxError(node.FullSpan,
                               string.Format(AnalysisMessage.ReturnTypesAreNotTheSame, nodeName, left.Name, right.Name),
                               SyntaxErrorKind.ImproperType);
            }
        }
Exemplo n.º 5
0
 public RdlQueryValidator(RdlMetadata metadatas)
 {
     _criticalErrors = new List <Exception>();
     _errors         = new List <VisitationMessage>();
     _metadatas      = metadatas;
 }
Exemplo n.º 6
0
 public void Initialize()
 {
     _manager = new RdlMetadata();
     _manager.RegisterMethods <TestMethodClass>(nameof(TestMethodClass.MethodA));
 }
Exemplo n.º 7
0
 public DebuggerSymbolGenerator(RdlMetadata gm, object callMethodContext, IReadOnlyDictionary <string, int> functionOccurences)
     : base(gm, callMethodContext, functionOccurences)
 {
 }
Exemplo n.º 8
0
 /// <summary>
 ///     Instantiate code generator instance.
 /// </summary>
 /// <param name="metadatas">Metadata manager with functions registered.</param>
 /// <param name="callMethodContext">object that contains methods to invoke.</param>
 /// <param name="functionOccurences">Function occurence table.</param>
 public CodeGenerator(RdlMetadata metadatas, object callMethodContext, IReadOnlyDictionary <string, int> functionOccurences)
     : this(metadatas, DateTimeOffset.UtcNow, callMethodContext, functionOccurences)
 {
 }