예제 #1
0
 protected virtual bool MatchConstraint(ParameterConstraint constraint, Location l)
 {
     if ((constraint.Type == ParameterConstraint.ConstraintType.Const) && (l.ModifierType == Location.LocationModifierType.ValueOf) &&
         (l.AType == Location.LocationType.Number) && (l.NumOp == Location.NumOpType.None))
     {
         // TODO match bitness etc
         return(true);
     }
     if ((constraint.Type == ParameterConstraint.ConstraintType.Const) && (l.ModifierType == Location.LocationModifierType.ValueOf) &&
         (l.AType == Location.LocationType.Label) && (l.NumOp == Location.NumOpType.None))
     {
         // TODO match bitness etc
         return(true);
     }
     return(false);
 }
예제 #2
0
        public string?GetParamConstraint(ParameterConstraint source, System.Type type)
        {
            if (source == null || !source.Enabled)
            {
                return(null);
            }

            if (source.Type == ParameterConstraint.ConstraintType.Static)
            {
                return(source.Value);
            }
            else if (source.Type == ParameterConstraint.ConstraintType.SQL)
            {
                return(this.ReportingDatabase.ExecuteToTable(source.Value).GetSingle <string>());
            }
            else
            {
                return(CodeGenerator.Execute(source.Value, type)?.ToString());
            }
        }
예제 #3
0
        protected override bool MatchConstraint(ParameterConstraint constraint, Location param)
        {
            // Match various param types
            string param_as_any_constraint  = null;
            string param_as_spec_constraint = null;

            switch (param.ModifierType)
            {
            case Location.LocationModifierType.ValueOf:
                if ((param.AType == Location.LocationType.Register) && (param.NumOp == Location.NumOpType.None))
                {
                    string r = param.A as string;
                    if (R32s.Contains(r))
                    {
                        param_as_any_constraint = R32;
                    }
                    else if (R64s.Contains(r))
                    {
                        param_as_any_constraint = R64;
                    }
                    else if (Cregs.Contains(r))
                    {
                        param_as_any_constraint = Creg;
                    }
                    param_as_spec_constraint = r;
                }
                break;

            case Location.LocationModifierType.ContentsOf:
                if ((param.AType == Location.LocationType.Register) && ((param.NumOp == Location.NumOpType.None) ||
                                                                        (((param.NumOp == Location.NumOpType.Plus) || (param.NumOp == Location.NumOpType.Minus) &&
                                                                          ((param.BType == Location.LocationType.Number) || (param.BType == Location.LocationType.Label))))))
                {
                    string r = param.A as string;
                    if (R32s.Contains(r))
                    {
                        param_as_any_constraint = p32;
                    }
                    else if (R64s.Contains(r))
                    {
                        param_as_any_constraint = p64;
                    }
                    param_as_spec_constraint = "[" + r + "]";
                }
                break;
            }

            if (constraint.Type == ParameterConstraint.ConstraintType.AnyOfType)
            {
                if (constraint.Value.Contains(param_as_any_constraint))
                {
                    return(true);
                }
            }
            if (constraint.Type == ParameterConstraint.ConstraintType.Specific)
            {
                if (constraint.Value.Contains(param_as_spec_constraint))
                {
                    return(true);
                }
            }

            return(base.MatchConstraint(constraint, param));
        }
예제 #4
0
 private void ParameterConstraintFromCCITypeParameterFlags(CCI.TypeParameterFlags flags, out ParameterVariance variance, out ParameterConstraint constraint)
 {
     var isCovariant = (flags & CCI.TypeParameterFlags.Covariant) != 0;
     var isContravariant = (flags & CCI.TypeParameterFlags.Contravariant) != 0;
     if (isCovariant && isContravariant)
         throw new InvalidOperationException("invalid type parameter variance");
     else if (isCovariant)
         variance = ParameterVariance.Covariant;
     else if (isContravariant)
         variance = ParameterVariance.Contravariant;
     else
         variance = ParameterVariance.Invariant;
     if ((flags & CCI.TypeParameterFlags.ReferenceTypeConstraint) != 0)
     {
         if ((flags & CCI.TypeParameterFlags.ValueTypeConstraint) != 0)
             throw new InvalidOperationException("invalid type paramater flags");
         if ((flags & CCI.TypeParameterFlags.DefaultConstructorConstraint) != 0)
             constraint = ParameterConstraint.ReferenceTypeWithDefaultConstructor;
         else
             constraint = ParameterConstraint.ReferenceType;
     }
     else if ((flags & CCI.TypeParameterFlags.ValueTypeConstraint) != 0)
     {
         // Seems this flag is sometimes also given even though redundant...
         // if ((flags & CCI.TypeParameterFlags.DefaultConstructorConstraint) != 0)
         //     throw new InvalidOperationException("invalid type parameter flags");
         constraint = ParameterConstraint.NonNullableValueType;
     }
     else
         constraint = ParameterConstraint.Unconstrained;
 }