コード例 #1
0
 private VariableState(int id, IntHandle representation, bool canBeNull, bool isInputDerived, int?value)
 {
     this.Id             = id;
     this.Representation = representation;
     this.CanBeNull      = canBeNull;
     this.IsInputDerived = isInputDerived;
     this.Value          = value;
 }
コード例 #2
0
        internal IntegerModel(IntegerModelFactory factory, ITypeSymbol type, IntHandle value)
        {
            Contract.Requires <ArgumentNullException>(factory != null, nameof(factory));
            Contract.Requires <ArgumentException>(value.Expression != null, nameof(value));

            this.Factory = factory;
            this.Type    = type;
            this.Value   = value;
        }
コード例 #3
0
        internal static object GetObject(JNIEnv env, JniHandle obj)
        {
            long handle = getClrHandle(env, obj);

            if (handle == 0)
            {
                return(null);
            }
            object real = IntHandle.ToObject(handle);

            return(real);
        }
コード例 #4
0
        private static void DisposeClrHandle(IntPtr @__envp, IntPtr @__class, long clrHandle)
        {
            JNIEnv env = JNIEnv.Wrap(@__envp);

            try
            {
                IntHandle.Free(clrHandle);
            }
            catch (Exception ex)
            {
                env.ThrowExisting(ex);
            }
        }
コード例 #5
0
        private static long Convert(IntPtr __envp, JniLocalHandle __class, JniLocalHandle str)
        {
            JNIEnv env = JNIEnv.Wrap(__envp);

            try
            {
                string value = env.ConvertToString(str);
                return(IntHandle.Alloc(value));
            }
            catch (Exception ex)
            {
                env.ThrowExisting(ex);
            }
            return(default(long));
        }
コード例 #6
0
        private static JniHandle UnwrapJVM(IntPtr __envp, IntPtr __class, long clrHandle)
        {
            JNIEnv env = JNIEnv.Wrap(__envp);

            try
            {
                IJvmProxy jvmProxy = (IJvmProxy)IntHandle.ToObject(clrHandle);
                return(jvmProxy.JvmHandle);
            }
            catch (Exception ex)
            {
                env.ThrowExisting(ex);
            }
            return(JniGlobalHandle.Zero);
        }
コード例 #7
0
        private static long WrapJVM(IntPtr __envp, JniLocalHandle __class, JniLocalHandle obj)
        {
            JNIEnv env = JNIEnv.Wrap(__envp);

            try
            {
                Class          clazz    = env.GetObjectClass(obj);
                RegistryRecord record   = Registry.GetJVMRecord(clazz);
                IJvmProxy      clrProxy = record.CreateCLRProxy(env, obj);
                return(IntHandle.Alloc(clrProxy));
            }
            catch (Exception ex)
            {
                env.ThrowExisting(ex);
            }
            return(0);
        }
コード例 #8
0
        public static TRes UnwrapCLR <TRes>(Object obj)
        {
            var clrProxy = obj as IClrProxy;

            if (clrProxy == null)
            {
                throw new JNIException("Can't unwrap JVM instance");
            }
            long   handle  = clrProxy.getClrHandle();
            object res     = IntHandle.ToObject(handle);
            Type   type    = res.GetType();
            Type   reqType = typeof(TRes);

            if (!reqType.IsAssignableFrom(type))
            {
                throw new InvalidCastException("Can't cast CLR instance of " + type + " to " + reqType);
            }
            return((TRes)res);
        }
コード例 #9
0
        private void GetOperationResult(
            IModellingContext context,
            IMethodSymbol method,
            IEnumerable <ITypeModel> arguments,
            out IntHandle intResult,
            out BoolHandle boolResult)
        {
            var first = ((IntegerModel)arguments.First()).Value;

            if (method.Parameters.Length == 1)
            {
                if (method.Name == "op_UnaryNegation")
                {
                    intResult = -first;
                }
                else if (method.Name == "op_UnaryPlus")
                {
                    intResult = first;
                }
            }
            else
            {
                Contract.Assert(method.Parameters.Length == 2);
                var second = ((IntegerModel)arguments.ElementAt(1)).Value;

                if (BooleanModelFactory.Instance.IsTypeSupported(method.ReturnType))
                {
                    switch (method.Name)
                    {
                    case "op_Equality":
                        boolResult = (first == second);
                        break;

                    case "op_Inequality":
                        boolResult = (first != second);
                        break;

                    case "op_GreaterThan":
                        boolResult = (first > second);
                        break;

                    case "op_LessThan":
                        boolResult = (first < second);
                        break;

                    case "op_GreaterThanOrEqual":
                        boolResult = (first >= second);
                        break;

                    case "op_LessThanOrEqual":
                        boolResult = (first <= second);
                        break;

                    default:
                        break;
                    }
                }
                else
                {
                    Contract.Assert(this.IsTypeSupported(method.ReturnType));

                    switch (method.Name)
                    {
                    case "op_Addition":
                        intResult = first + second;
                        break;

                    case "op_Subtraction":
                        intResult = first - second;
                        break;

                    case "op_Division":
                        // TODO: Set the exception if the right is zero
                        intResult = first / second;
                        break;

                    case "op_Modulus":
                        intResult = first % second;
                        break;

                    case "op_Multiply":
                        intResult = first * second;
                        break;

                    default:
                        break;
                    }
                }
            }
        }
コード例 #10
0
 public ArrayHandleTest()
 {
     this.a = (ArrayHandle <IntHandle, BoolHandle>)ExpressionFactory.NamedVariable(arraySort, "a");
     this.k = (IntHandle)ExpressionFactory.NamedVariable(Sort.Int, "k");
     this.v = (BoolHandle)ExpressionFactory.NamedVariable(Sort.Bool, "v");
 }
コード例 #11
0
 internal IntegerValueModel(IntegerModelFactory factory, ITypeSymbol type, IntHandle value)
     : base(factory, type, value)
 {
     Contract.Requires(value.Expression.Kind == SmtLibStandard.ExpressionKind.Interpretation);
 }
コード例 #12
0
 public IntHandleTest()
 {
     this.a = (IntHandle)ExpressionFactory.NamedVariable(Sort.Int, "a");
     this.b = (IntHandle)ExpressionFactory.NamedVariable(Sort.Int, "b");
     this.c = (IntHandle)ExpressionFactory.NamedVariable(Sort.Int, "c");
 }
コード例 #13
0
ファイル: Model.cs プロジェクト: roberthusak/AskTheCode
 public long GetValue(IntHandle handle)
 {
     throw new NotImplementedException();
 }