public void MarkWrite(IBoundType type, BoundValueType valueType)
            {
                var internalType = (BoundType)type;

                if (type.Type == BoundValueType.Unset)
                    internalType.Type = valueType;
                else if (type.Type != valueType)
                    internalType.Type = BoundValueType.Unknown;
            }
 private static Func<CodeGenerator, BoundExpression[], BoundValueType> FindOperationBuilder(Operation operation, BoundValueType a, BoundValueType b, BoundValueType c)
 {
     Func<CodeGenerator, BoundExpression[], BoundValueType> result;
     _operationBuilders.TryGetValue(GetOperationMethodKey(operation, a, b, c), out result);
     return result;
 }
 private static Func<CodeGenerator, BoundExpression[], BoundValueType> FindOperationBuilder(Operation operation, BoundValueType operand)
 {
     return FindOperationBuilder(operation, operand, BoundValueType.Unset);
 }
 private static Func<CodeGenerator, BoundExpression[], BoundValueType> FindOperationBuilder(Operation operation, BoundValueType left, BoundValueType right)
 {
     return FindOperationBuilder(operation, left, right, BoundValueType.Unset);
 }
 private static MethodInfo FindOperationMethod(Operation operation, BoundValueType operand)
 {
     return FindOperationMethod(operation, operand, BoundValueType.Unset);
 }
 private static MethodInfo FindOperationMethod(Operation operation, BoundValueType left, BoundValueType right)
 {
     return FindOperationMethod(operation, left, right, BoundValueType.Unset);
 }
 private static int GetOperationMethodKey(Operation operation, BoundValueType a, BoundValueType b)
 {
     return GetOperationMethodKey(operation, a, b, BoundValueType.Unset);
 }
 private static int GetOperationMethodKey(Operation operation, BoundValueType a, BoundValueType b, BoundValueType c)
 {
     return (int)operation << 24 | (int)a << 16 | (int)b << 8 | (int)c;
 }
 private static MethodInfo FindOperationMethod(Operation operation, BoundValueType a, BoundValueType b, BoundValueType c)
 {
     MethodInfo result;
     _operationCache.TryGetValue(GetOperationMethodKey(operation, a, b, c), out result);
     return result;
 }
Beispiel #10
0
                public void MarkWrite(IBoundWritable writable, BoundValueType type)
                {
                    var boundType = ResolveType(writable);

                    if (boundType != null)
                        _marker.MarkWrite(boundType, type);
                }
Beispiel #11
0
        private void EmitCast(BoundValueType source, BoundValueType target)
        {
            if (source == target)
                return;

            if (target == BoundValueType.Unknown)
            {
                if (source.IsValueType())
                    IL.Emit(OpCodes.Box, source.GetNativeType());
                return;
            }

            MethodInfo method;

            switch (target)
            {
                case BoundValueType.Boolean:
                    switch (source)
                    {
                        case BoundValueType.Boolean: throw new InvalidOperationException();
                        case BoundValueType.Number: method = _numberToBoolean; break;
                        case BoundValueType.String: method = _stringToBoolean; break;
                        default: method = _toBoolean; break;
                    }
                    break;

                case BoundValueType.Number:
                    switch (source)
                    {
                        case BoundValueType.Boolean: method = _booleanToNumber; break;
                        case BoundValueType.Number: throw new InvalidOperationException();
                        case BoundValueType.String: method = _stringToNumber; break;
                        default: method = _toNumber; break;
                    }
                    break;

                case BoundValueType.String:
                    switch (source)
                    {
                        case BoundValueType.Boolean: method = _booleanToString; break;
                        case BoundValueType.Number: method = _numberToString; break;
                        case BoundValueType.String: throw new InvalidOperationException();
                        default: method = _toString; break;
                    }
                    break;

                default: throw new ArgumentOutOfRangeException("source", String.Format("Cannot cast '{0}' to '{1}'", source, target));
            }

            IL.EmitCall(method);
        }
Beispiel #12
0
 private void EmitBox(BoundValueType type)
 {
     EmitCast(type, BoundValueType.Unknown);
 }
Beispiel #13
0
 private void EmitPop(BoundValueType type)
 {
     if (type != BoundValueType.Unset)
         IL.Emit(OpCodes.Pop);
 }