protected override void InternalVerify(VerificationContext context, ASTNode node) { base.InternalVerify(context, node); var child = node.Children[0]; var intervalType = child.ResultType as IntervalType; if (intervalType != null) { var lengthOperator = context.ResolveCall("Subtract", new Signature(new DataType[] { intervalType.PointType, intervalType.PointType })); node.ResultType = lengthOperator.ResultType; } else { context.VerifyType(child.ResultType, DataTypes.String); node.ResultType = DataTypes.Integer; } }
protected override void InternalVerify(VerificationContext context, ASTNode node) { base.InternalVerify(context, node); var leftType = node.Children[0].ResultType; var rightType = node.Children[1].ResultType; if (leftType is ScalarType || rightType is ScalarType) { var op = context.ResolveCall(GetOperatorName(), new Signature(new[] { leftType, rightType })); node.ResultType = op.ResultType; } else { if (DataTypes.Equal(leftType, rightType)) { node.ResultType = DataTypes.Boolean; } else { throw new InvalidOperationException ( String.Format ( "Cannot resolve operator {0} for operands of type {1} and {2}", GetOperatorName(), leftType != null ? leftType.Name : "<unknown>", rightType != null ? rightType.Name : "<unknown>" ) ); } } }
protected override DataType GetResultType(VerificationContext context, ListType listType) { var addOperator = context.ResolveCall("Add", new Signature(new[] { listType.ElementType, listType.ElementType })); var divideOperator = context.ResolveCall("Divide", new Signature(new[] { listType.ElementType, listType.ElementType })); return divideOperator.ResultType; }
protected override void InternalVerify(VerificationContext context, ASTNode node) { base.InternalVerify(context, node); var dataTypes = new List<DataType>(); foreach (var child in node.Children) { if (child.ResultType == null) { throw new InvalidOperationException(String.Format("Could not determine type of '{0}' expression.", child.Name)); } dataTypes.Add(child.ResultType); } var op = context.ResolveCall(GetOperatorName(node), new Signature(dataTypes)); node.ResultType = op.ResultType; }
protected override DataType GetResultType(VerificationContext context, ListType listType) { var greaterOperator = context.ResolveCall("Greater", new Signature(new[] { listType.ElementType, listType.ElementType })); return listType.ElementType; }