Ejemplo n.º 1
0
            public override OperatorMethod Lift(CppOperators operators)
            {
                var lifted = new LiftedBinaryOperatorMethod(operators, this);

                lifted.ReturnType = this.ReturnType;                 // don't lift the return type for relational operators
                return(lifted);
            }
Ejemplo n.º 2
0
 public RelationalOperatorMethod(CppOperators operators, Func <T1, T2, bool> func)
     : base(operators.compilation)
 {
     this.ReturnType = operators.compilation.FindType(KnownTypeCode.Boolean);
     this.Parameters.Add(operators.MakeParameter(Type.GetTypeCode(typeof(T1))));
     this.Parameters.Add(operators.MakeParameter(Type.GetTypeCode(typeof(T2))));
     this.func = func;
 }
Ejemplo n.º 3
0
 public StringConcatenation(CppOperators operators, TypeCode p1, TypeCode p2)
     : base(operators.compilation)
 {
     this.canEvaluateAtCompileTime = p1 == TypeCode.String && p2 == TypeCode.String;
     this.ReturnType = operators.compilation.FindType(KnownTypeCode.String);
     this.Parameters.Add(operators.MakeParameter(p1));
     this.Parameters.Add(operators.MakeParameter(p2));
 }
Ejemplo n.º 4
0
 public LiftedBinaryOperatorMethod(CppOperators operators, BinaryOperatorMethod baseMethod)
     : base(operators.compilation)
 {
     this.baseMethod = baseMethod;
     this.ReturnType = NullableType.Create(operators.compilation, baseMethod.ReturnType);
     this.Parameters.Add(operators.MakeNullableParameter(baseMethod.Parameters[0]));
     this.Parameters.Add(operators.MakeNullableParameter(baseMethod.Parameters[1]));
 }
Ejemplo n.º 5
0
 public EqualityOperatorMethod(CppOperators operators, TypeCode type, bool negate)
     : base(operators.compilation)
 {
     this.Negate     = negate;
     this.Type       = type;
     this.ReturnType = operators.compilation.FindType(KnownTypeCode.Boolean);
     this.Parameters.Add(operators.MakeParameter(type));
     this.Parameters.Add(operators.MakeParameter(type));
 }
Ejemplo n.º 6
0
            public LambdaUnaryOperatorMethod(CppOperators operators, Func <T, T> func)
                : base(operators.compilation)
            {
                TypeCode typeCode = Type.GetTypeCode(typeof(T));

                this.ReturnType = operators.compilation.FindType(typeCode);
                this.Parameters.Add(operators.MakeParameter(typeCode));
                this.func = func;
            }
Ejemplo n.º 7
0
            public LiftedEqualityOperatorMethod(CppOperators operators, EqualityOperatorMethod baseMethod)
                : base(operators.compilation)
            {
                this.baseMethod = baseMethod;
                this.ReturnType = baseMethod.ReturnType;
                IParameter p = operators.MakeNullableParameter(baseMethod.Parameters[0]);

                this.Parameters.Add(p);
                this.Parameters.Add(p);
            }
Ejemplo n.º 8
0
 public override OperatorMethod Lift(CppOperators operators)
 {
     if (Type == TypeCode.Object || Type == TypeCode.String)
     {
         return(null);
     }
     else
     {
         return(new LiftedEqualityOperatorMethod(operators, this));
     }
 }
Ejemplo n.º 9
0
            public LambdaBinaryOperatorMethod(CppOperators operators, Func <T1, T2, T1> checkedFunc, Func <T1, T2, T1> uncheckedFunc)
                : base(operators.compilation)
            {
                TypeCode t1 = Type.GetTypeCode(typeof(T1));

                this.ReturnType = operators.compilation.FindType(t1);
                this.Parameters.Add(operators.MakeParameter(t1));
                this.Parameters.Add(operators.MakeParameter(Type.GetTypeCode(typeof(T2))));
                this.checkedFunc   = checkedFunc;
                this.uncheckedFunc = uncheckedFunc;
            }
Ejemplo n.º 10
0
        /// <summary>
        /// Gets the CSharpOperators instance for the specified <see cref="ICompilation"/>.
        /// This will make use of the context's cache manager (if available) to reuse the CSharpOperators instance.
        /// </summary>
        public static CppOperators Get(ICompilation compilation)
        {
            CacheManager cache     = compilation.CacheManager;
            CppOperators operators = (CppOperators)cache.GetShared(typeof(CppOperators));

            if (operators == null)
            {
                operators = (CppOperators)cache.GetOrAddShared(typeof(Conversions), new CppOperators(compilation));
            }
            return(operators);
        }
Ejemplo n.º 11
0
 public override OperatorMethod Lift(CppOperators operators)
 {
     return(new LiftedBinaryOperatorMethod(operators, this));
 }
Ejemplo n.º 12
0
 public LambdaBinaryOperatorMethod(CppOperators operators, Func <T1, T2, T1> func)
     : this(operators, func, func)
 {
 }
Ejemplo n.º 13
0
 public virtual OperatorMethod Lift(CppOperators operators)
 {
     return(null);
 }