Пример #1
0
		protected override void InternalVerify(VerificationContext context, ASTNode node, ObjectType dataType)
		{
			base.InternalVerify(context, node, dataType);

			// codeProperty - If present, must reference a property of type Code on the resolved model type.
			var codeProperty = node.GetAttribute<string>("codeProperty");
			if (!String.IsNullOrEmpty(codeProperty))
			{
				var codePropertyType = context.ResolveProperty(dataType, codeProperty);
				context.VerifyType(codePropertyType, DataTypes.Code);
			}

			// dateProperty - If present, must reference a property of type Timestamp on the resolved model type. (TODO: Handle Interval<Timestamp>?)
			var dateProperty = node.GetAttribute<string>("dateProperty");
			if (!String.IsNullOrEmpty(dateProperty))
			{
				var datePropertyType = context.ResolveProperty(dataType, dateProperty);
				context.VerifyType(datePropertyType, DataTypes.DateTime);
			}

			// codes - If present, must evaluate to a value of type List<Code>
			var codes = node.Children.Where(n => n.Name == "codes").FirstOrDefault();
			if (codes != null)
			{
				Verifier.Verify(context, codes);
				context.VerifyType(codes.ResultType, DataTypes.CodeList);
			}

			// dateRange - If present, must evaluate to a value of type Interval<Timestamp>
			var dateRange = node.Children.Where(n => n.Name == "dateRange").FirstOrDefault();
			if (dateRange != null)
			{
				Verifier.Verify(context, dateRange);
				context.VerifyType(dateRange.ResultType, DataTypes.DateTimeInterval);
			}
		}
Пример #2
0
		protected override void InternalVerify(VerificationContext context, ASTNode node)
		{
			base.InternalVerify(context, node);

			var source = node.Children[0];
			var sourceListType = source.ResultType as ListType;
			if (sourceListType == null)
			{
				throw new InvalidOperationException("Source must be a list value.");
			}

			node.ResultType = sourceListType.ElementType;

            var orderBy = node.GetAttribute<string>("orderBy");
            if (!String.IsNullOrEmpty(orderBy))
            {
                context.ResolveProperty(node.ResultType, orderBy);
            }
		}
Пример #3
0
		public void Verify(VerificationContext context, ASTNode node)
		{
			// Verify source
			Verifier.Verify(context, node.Children[0]);

			var objectType = node.Children[0].ResultType as ObjectType;
			if (objectType == null)
			{
				throw new InvalidOperationException("The source expression for an object redefine must evaluate to a value of a structured type.");
			}

			// Push the source into context as a symbol
			context.PushSymbol(new Symbol(node.GetAttribute<string>("Scope", VerificationContext.Current), objectType));
			try
			{
				// foreach property
				for (int i = 1; i < ((Node)node).Children.Count; i++)
				{
					// Verify the property exists
					var child = ((Node)node).Children[i];
					var childPropertyType = context.ResolveProperty(objectType, child.GetAttribute<string>("name"));

					// Verify the value
					var value = (ASTNode)child.Children[0];
					Verifier.Verify(context, value);

					// Verify the value type is appropriate for the property type
					context.VerifyType(value.ResultType, childPropertyType);
				}
			}
			finally
			{
				context.PopSymbol();
			}

			node.ResultType = objectType;
		}
Пример #4
0
		protected virtual void InternalVerify(VerificationContext context, ASTNode node, ObjectType dataType)
		{
			// idProperty - If present, must reference a property of type String (or explicitly convertible to string) on the resolved model type.
			var idProperty = node.GetAttribute<string>("idProperty");
			if (!String.IsNullOrEmpty(idProperty))
			{
				var idPropertyType = context.ResolveProperty(dataType, idProperty);
				if (!(DataTypes.Equivalent(idPropertyType, DataTypes.ResolveType(typeof(II))) || DataTypes.Equal(idPropertyType, DataTypes.String)))
				{
					throw new InvalidOperationException("Id property must be either an Identifier or a String.");
				}
			}

			// Validate children
			// timeOffset - If present, must evaluate to a value of type PIVL_TS
			var timeOffset = node.Children.Where(n => n.Name == "timeOffset").FirstOrDefault();
			if (timeOffset != null)
			{
				Verifier.Verify(context, timeOffset);
				context.VerifyType(timeOffset.ResultType, DataTypes.ResolveType(typeof(PIVL_TS)));
			}
		}
Пример #5
0
		public void Verify(VerificationContext context, ASTNode node)
		{
			DataType sourceType = null;
			if (node.Children.Count > 0)
			{
				Verifier.Verify(context, node.Children[0]);
				sourceType = node.Children[0].ResultType;
			}
			else
			{
				var symbol = context.ResolveSymbol(node.GetAttribute<string>("scope", VerificationContext.Current));
				sourceType = symbol.DataType;
			}

			node.ResultType = context.ResolveProperty(sourceType, node.GetAttribute<string>("path"));

			// Save sourceType for use in translation and/or evaluation
			node.Attributes.Add("sourceType", sourceType);
		}
Пример #6
0
		protected override void InternalVerify(VerificationContext context, ASTNode node)
		{
			base.InternalVerify(context, node);

			var source = node.Children[0];
			var sourceListType = source.ResultType as ListType;
			if (sourceListType == null)
			{
				throw new InvalidOperationException("List type expected.");
			}

			var path = node.GetAttribute<string>("path");
			if (!String.IsNullOrEmpty(path))
			{
				var sourceObjectType = sourceListType.ElementType as ObjectType;
				if (sourceObjectType == null)
				{
					throw new InvalidOperationException("List of object type expected for aggregate expression with path reference.");
				}

				context.ResolveProperty(sourceObjectType, path);
			}

			node.ResultType = GetResultType(context, sourceListType);
		}
Пример #7
0
		public void Verify(VerificationContext context, ASTNode node)
		{
			// objectType
            var objectTypeName = node.GetAttribute<string>("classType");
            if (objectTypeName != null)
            {
			    var objectType = context.ResolveType(node.GetAttribute<string>("classType")) as ObjectType;

			    // foreach property
			    foreach (var child in ((Node)node).Children)
			    {
					if (child.Name == "element") 
					{
						// Verify the property exists
						var childPropertyType = context.ResolveProperty(objectType, child.GetAttribute<string>("name"));

						// Verify the value
						var value = (ASTNode)child.Children[0];
						Verifier.Verify(context, value);

						// Verify the value type is appropriate for the property type
						context.VerifyType(value.ResultType, childPropertyType);
					}
			    }

			    node.ResultType = objectType;
            }
            else
            {
                var propertyList = new List<PropertyDef>();

                foreach (var child in ((Node)node).Children)
                {
					if (child.Name == "element")
					{
						var value = (ASTNode)child.Children[0];
						Verifier.Verify(context, value);

						var property = new PropertyDef(child.GetAttribute<string>("name"), value.ResultType);
						propertyList.Add(property);
					}
                }

                var objectType = new ObjectType(Guid.NewGuid().ToString(), propertyList);

                node.ResultType = objectType;
            }
		}