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; }
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; }
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); }
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); } }
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)); }
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); }
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); }
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); }
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; } } } }
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"); }
internal IntegerValueModel(IntegerModelFactory factory, ITypeSymbol type, IntHandle value) : base(factory, type, value) { Contract.Requires(value.Expression.Kind == SmtLibStandard.ExpressionKind.Interpretation); }
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"); }
public long GetValue(IntHandle handle) { throw new NotImplementedException(); }