Exemplo n.º 1
0
        private void VerifyParamCompatibility(FunctionSignature func, int paramIndex, FunctionParam param, IRValue value)
        {
            if (param.Type.IntrinsicTypeId != value.Type.IntrinsicTypeId)
            {
                object paramName = (param.Name != null) ? (object)param.Name : paramIndex;
                Context.Log.Error(value.Location,
                                  DiagnosticCode.LocalTypeMismatch,
                                  "Parameter {0} of {1} \"{2}\" expects {3}; {4} specified",
                                  paramName, func.Type, func.Name, param.Type.Name, value.Type.Name);
                return;
            }

            if (IsGuidAliasToAliasCast(param.Type, value.Type))
            {
                object paramName = (param.Name != null) ? (object)param.Name : paramIndex;
                Context.Log.Error(value.Location,
                                  DiagnosticCode.GuidAliasMismatch,
                                  "Parameter {0} of {1} \"{2}\" has GUID type {3}; {4} specified",
                                  paramName, func.Type, func.Name, param.Type.Name, value.Type.Name);
                return;
            }
        }
Exemplo n.º 2
0
        private void PropagateRuleTypesFromParamList(IRRule rule, List<IRValue> parameters, FunctionSignature signature)
        {
            Int32 index = 0;
            foreach (var param in parameters)
            {
                if (param is IRVariable)
                {
                    var irVar = param as IRVariable;
                    PropagateIRVariableType(rule, param as IRVariable, signature.Params[index].Type);
                }

                index++;
            }
        }
Exemplo n.º 3
0
        private void VerifyIRVariableCall(IRRule rule, IRVariable variable, FunctionSignature signature, Int32 parameterIndex, 
            Int32 conditionIndex, bool not)
        {
            var ruleVar = rule.Variables[variable.Index];
            var param = signature.Params[parameterIndex];

            if (param.Direction == ParamDirection.Out && !not)
            {
                Debug.Assert(conditionIndex != -1);
                if (ruleVar.FirstBindingIndex == -1)
                {
                    ruleVar.FirstBindingIndex = conditionIndex;
                }
            }
            else if (
                // We're in the THEN section of a rule, so we cannot bind here
                conditionIndex == -1 
                // NOT conditions never bind, but they allow unbound unused variables
                || (!ruleVar.IsUnused() && not)
                || (
                    // Databases and events always bind
                    signature.Type != FunctionType.Database
                    && signature.Type != FunctionType.Event
                    // PROC/QRYs bind if they're the first condition in a rule
                    && !(rule.Type == RuleType.Proc && conditionIndex == 0 && signature.Type == FunctionType.Proc)
                    && !(rule.Type == RuleType.Query && conditionIndex == 0 && signature.Type == FunctionType.UserQuery)
                    && param.Direction != ParamDirection.Out
                )
            ) {

                if (
                    // The variable was never bound
                    ruleVar.FirstBindingIndex == -1
                    // The variable was bound after this node (so it is still unbound here)
                    || (conditionIndex != -1 && ruleVar.FirstBindingIndex >= conditionIndex)
                ) {
                    object paramName = (param.Name != null) ? (object)param.Name : (parameterIndex + 1);
                    if (!ruleVar.IsUnused())
                    {
                        Context.Log.Error(variable.Location,
                            DiagnosticCode.ParamNotBound,
                            "Variable {0} is not bound here (when used as parameter {1} of {2} \"{3}\")",
                            ruleVar.Name, paramName, signature.Type, signature.GetNameAndArity());
                    }
                    else
                    {
                        Context.Log.Error(variable.Location,
                            DiagnosticCode.ParamNotBound,
                            "Parameter {0} of {1} \"{2}\" requires a variable or constant, not a placeholder",
                            paramName, signature.Type, signature.GetNameAndArity());
                    }
                }
            }
            else
            {
                if (conditionIndex != -1 && ruleVar.FirstBindingIndex == -1 && !not)
                {
                    ruleVar.FirstBindingIndex = conditionIndex;
                }
            }
        }
Exemplo n.º 4
0
        private bool PropagateRuleTypesFromParamList(IRRule rule, List <IRValue> parameters, FunctionSignature signature)
        {
            bool  updated = false;
            Int32 index   = 0;

            foreach (var param in parameters)
            {
                if (param is IRVariable)
                {
                    var irVar = param as IRVariable;
                    if (PropagateIRVariableType(rule, param as IRVariable, signature.Params[index].Type))
                    {
                        updated = true;
                    }
                }

                index++;
            }

            return(updated);
        }