HLInst* X86Compiler::emit(uint32_t code, uint64_t o0_) { Imm o0(o0_); HLInst* node = newInst(code, o0); if (node == NULL) return NULL; return static_cast<HLInst*>(addNode(node)); }
HLInst* X86Compiler::emit(uint32_t code, uint64_t o0_) noexcept { Imm o0(o0_); HLInst* node = newInst(code, o0); if (node == nullptr) return nullptr; return static_cast<HLInst*>(addNode(node)); }
void test_CTypedPtrMap() { typedef ::CTypedPtrMap< ::CMapStringToPtr, ::CString, int *> rng_t; boost::function_requires< boost::ForwardRangeConcept<rng_t> >(); rng_t rng; ::CString o0(_T('a')), o1(_T('c')), o2(_T('f')), o3(_T('q')), o4(_T('g')); int d0, d1, d2, d3, d4; std::map< ::CString, int * > data; data[o0] = &d0, data[o1] = &d1, data[o2] = &d2, data[o3] = &d3, data[o4] = &d4; BOOST_CHECK( brdm::test_init_map(rng, data) ); BOOST_CHECK( ::test_mfc_map(rng, data) ); BOOST_CHECK( brdm::test_emptiness(rng) ); }
void test_in_circle() { Gt traits; traits.set_domain(Gt::Iso_rectangle_2(0, 0, 1, 1)); Gt::Offset_2 o0(0, 0); Gt::Offset_2 o1(0, 1); /// Near degenerate points, which cause the predicate to fail if not filtered /// On the circle with center (0.4999, 0.4999) and radius 5 Point p0( 5 - 0.4999, -0.4999); Point p1( 3 - 0.4999, 4 - 0.4999); Point p2(-4 - 0.4999, 3 - 0.4999); Point p3( 4 - 0.4999, -3 - 0.4999); CGAL_assertion(traits.side_of_oriented_circle_2_object()(p0, p1, p2, p3) == 1); CGAL_assertion(traits.side_of_oriented_circle_2_object()(p2, p0, p1, p3) == 1); CGAL_assertion(traits.side_of_oriented_circle_2_object()(p1, p2, p0, p3) == 1); CGAL_assertion(traits.side_of_oriented_circle_2_object()(p0, p2, p1, p3) == -1); CGAL_assertion(traits.side_of_oriented_circle_2_object()(p1, p0, p2, p3) == -1); CGAL_assertion(traits.side_of_oriented_circle_2_object()(p2, p1, p0, p3) == -1); CGAL_assertion(traits.side_of_oriented_circle_2_object()(p0, p1, p2, p3) == traits.side_of_oriented_circle_2_object()(p0, p1, p2, p3, o0, o0, o0, o0)); CGAL_assertion(traits.side_of_oriented_circle_2_object()(p2, p0, p1, p3) == traits.side_of_oriented_circle_2_object()(p2, p0, p1, p3, o0, o0, o0, o0)); CGAL_assertion(traits.side_of_oriented_circle_2_object()(p1, p2, p0, p3) == traits.side_of_oriented_circle_2_object()(p1, p2, p0, p3, o0, o0, o0, o0)); CGAL_assertion(traits.side_of_oriented_circle_2_object()(p0, p2, p1, p3) == traits.side_of_oriented_circle_2_object()(p0, p2, p1, p3, o0, o0, o0, o0)); CGAL_assertion(traits.side_of_oriented_circle_2_object()(p1, p0, p2, p3) == traits.side_of_oriented_circle_2_object()(p1, p0, p2, p3, o0, o0, o0, o0)); CGAL_assertion(traits.side_of_oriented_circle_2_object()(p2, p1, p0, p3) == traits.side_of_oriented_circle_2_object()(p2, p1, p0, p3, o0, o0, o0, o0)); CGAL_assertion(traits.side_of_oriented_circle_2_object()(p0, p1, p2, p3) == traits.side_of_oriented_circle_2_object()(p0, p1, p2, p3, o1, o1, o1, o1)); CGAL_assertion(traits.side_of_oriented_circle_2_object()(p2, p0, p1, p3) == traits.side_of_oriented_circle_2_object()(p2, p0, p1, p3, o1, o1, o1, o1)); CGAL_assertion(traits.side_of_oriented_circle_2_object()(p1, p2, p0, p3) == traits.side_of_oriented_circle_2_object()(p1, p2, p0, p3, o1, o1, o1, o1)); CGAL_assertion(traits.side_of_oriented_circle_2_object()(p0, p2, p1, p3) == traits.side_of_oriented_circle_2_object()(p0, p2, p1, p3, o1, o1, o1, o1)); CGAL_assertion(traits.side_of_oriented_circle_2_object()(p1, p0, p2, p3) == traits.side_of_oriented_circle_2_object()(p1, p0, p2, p3, o1, o1, o1, o1)); CGAL_assertion(traits.side_of_oriented_circle_2_object()(p2, p1, p0, p3) == traits.side_of_oriented_circle_2_object()(p2, p1, p0, p3, o1, o1, o1, o1)); }
void test_orientation() { Gt traits; traits.set_domain(Gt::Iso_rectangle_2(0, 0, 1, 1)); Gt::Offset_2 o0(0, 0); Gt::Offset_2 o1(0, 1); /// Near degenerate points, which cause the predicate to fail if not filtered Point p0(0.5 + (0.4999 / N) * 2, 0.5 + (0.4999 / N) * -5); Point p1(0.5 + (0.4999 / N) * 4, 0.5 + (0.4999 / N) * -4); Point p2(0.5 + (0.4999 / N) * 6, 0.5 + (0.4999 / N) * -3); CGAL_assertion(traits.orientation_2_object()(p0, p1, p2) == 1); CGAL_assertion(traits.orientation_2_object()(p2, p0, p1) == 1); CGAL_assertion(traits.orientation_2_object()(p1, p2, p0) == 1); CGAL_assertion(traits.orientation_2_object()(p0, p2, p1) == -1); CGAL_assertion(traits.orientation_2_object()(p1, p0, p2) == -1); CGAL_assertion(traits.orientation_2_object()(p2, p1, p0) == -1); CGAL_assertion(traits.orientation_2_object()(p0, p1, p2) == traits.orientation_2_object()(p0, p1, p2, o0, o0, o0)); CGAL_assertion(traits.orientation_2_object()(p2, p0, p1) == traits.orientation_2_object()(p2, p0, p1, o0, o0, o0)); CGAL_assertion(traits.orientation_2_object()(p1, p2, p0) == traits.orientation_2_object()(p1, p2, p0, o0, o0, o0)); CGAL_assertion(traits.orientation_2_object()(p0, p2, p1) == traits.orientation_2_object()(p0, p2, p1, o0, o0, o0)); CGAL_assertion(traits.orientation_2_object()(p1, p0, p2) == traits.orientation_2_object()(p1, p0, p2, o0, o0, o0)); CGAL_assertion(traits.orientation_2_object()(p2, p1, p0) == traits.orientation_2_object()(p2, p1, p0, o0, o0, o0)); CGAL_assertion(traits.orientation_2_object()(p0, p1, p2) == traits.orientation_2_object()(p0, p1, p2, o1, o1, o1)); CGAL_assertion(traits.orientation_2_object()(p2, p0, p1) == traits.orientation_2_object()(p2, p0, p1, o1, o1, o1)); CGAL_assertion(traits.orientation_2_object()(p1, p2, p0) == traits.orientation_2_object()(p1, p2, p0, o1, o1, o1)); CGAL_assertion(traits.orientation_2_object()(p0, p2, p1) == traits.orientation_2_object()(p0, p2, p1, o1, o1, o1)); CGAL_assertion(traits.orientation_2_object()(p1, p0, p2) == traits.orientation_2_object()(p1, p0, p2, o1, o1, o1)); CGAL_assertion(traits.orientation_2_object()(p2, p1, p0) == traits.orientation_2_object()(p2, p1, p0, o1, o1, o1)); }
void dCustomJoint::dDebugDisplay::DrawFrame(const dMatrix& matrix) { dVector o0(matrix.m_posit); dFloat size = 0.25f; dVector x(matrix.m_posit + matrix.RotateVector(dVector(size, 0.0f, 0.0f, 0.0f))); SetColor(dVector (1.0f, 0.0f, 0.0f)); DrawLine (matrix.m_posit, x); dVector y(matrix.m_posit + matrix.RotateVector(dVector(0.0f, size, 0.0f, 0.0f))); SetColor(dVector (0.0f, 1.0f, 0.0f)); DrawLine (matrix.m_posit, y); dVector z(matrix.m_posit + matrix.RotateVector(dVector(0.0f, 0.0f, size, 0.0f))); SetColor(dVector (0.0f, 0.0f, 1.0f)); DrawLine (matrix.m_posit, z); }
void VRSnappingEngine::setPreset(PRESET preset) { clear(); Line t0(Pnt3f(0,0,0), Vec3f(0,0,0)); Line o0(Pnt3f(0,0,-1), Vec3f(0,1,0)); switch(preset) { case SIMPLE_ALIGNMENT: addRule(POINT, POINT, t0, o0, 1, 1, 0); addRule(LINE, POINT, Line(Pnt3f(), Vec3f(1,0,0)), o0, 1, 1, 0); addRule(LINE, POINT, Line(Pnt3f(), Vec3f(0,1,0)), o0, 1, 1, 0); addRule(LINE, POINT, Line(Pnt3f(), Vec3f(0,0,1)), o0, 1, 1, 0); break; case SNAP_BACK: addRule(POINT, POINT, t0, o0, 1, 1, 0); break; } }
void RenderJointsDebugInfo (NewtonWorld* const world, dFloat size) { glDisable(GL_TEXTURE_2D); glDisable (GL_LIGHTING); glBegin(GL_LINES); // this will go over the joint list twice, for (NewtonBody* body = NewtonWorldGetFirstBody(world); body; body = NewtonWorldGetNextBody(world, body)) { for (NewtonJoint* joint = NewtonBodyGetFirstJoint(body); joint; joint = NewtonBodyGetNextJoint(body, joint)) { NewtonJointRecord info; NewtonJointGetInfo (joint, &info); if (strcmp (info.m_descriptionType, "customJointNotInfo")) { // draw first frame dMatrix matrix0; NewtonBodyGetMatrix (info.m_attachBody_0, &matrix0[0][0]); matrix0 = dMatrix (&info.m_attachmenMatrix_0[0][0]) * matrix0; dVector o0 (matrix0.m_posit); dVector x (o0 + matrix0.RotateVector (dVector (size, 0.0f, 0.0f, 0.0f))); glColor3f (1.0f, 0.0f, 0.0f); glVertex3f (o0.m_x, o0.m_y, o0.m_z); glVertex3f (x.m_x, x.m_y, x.m_z); dVector y (o0 + matrix0.RotateVector (dVector (0.0f, size, 0.0f, 0.0f))); glColor3f (0.0f, 1.0f, 0.0f); glVertex3f (o0.m_x, o0.m_y, o0.m_z); glVertex3f (y.m_x, y.m_y, y.m_z); dVector z (o0 + matrix0.RotateVector (dVector (0.0f, 0.0f, size, 0.0f))); glColor3f (0.0f, 0.0f, 1.0f); glVertex3f (o0.m_x, o0.m_y, o0.m_z); glVertex3f (z.m_x, z.m_y, z.m_z); // draw second frame dMatrix matrix1 (dGetIdentityMatrix()); if (info.m_attachBody_1) { NewtonBodyGetMatrix (info.m_attachBody_1, &matrix1[0][0]); } matrix1 = dMatrix (&info.m_attachmenMatrix_1[0][0]) * matrix1; dVector o1 (matrix1.m_posit); x = o1 + matrix1.RotateVector (dVector (size, 0.0f, 0.0f, 0.0f)); glColor3f (1.0f, 0.0f, 0.0f); glVertex3f (o1.m_x, o1.m_y, o1.m_z); glVertex3f (x.m_x, x.m_y, x.m_z); y = o1 + matrix1.RotateVector (dVector (0.0f, size, 0.0f, 0.0f)); glColor3f (0.0f, 1.0f, 0.0f); glVertex3f (o1.m_x, o1.m_y, o1.m_z); glVertex3f (y.m_x, y.m_y, y.m_z); z = o1 + matrix1.RotateVector (dVector (0.0f, 0.0f, size, 0.0f)); glColor3f (0.0f, 0.0f, 1.0f); glVertex3f (o1.m_x, o1.m_y, o1.m_z); glVertex3f (z.m_x, z.m_y, z.m_z); if (!strcmp (info.m_descriptionType, "limitballsocket")) { // draw the cone limit of this joint int steps = 12; dMatrix coneMatrix (dRollMatrix(info.m_maxAngularDof[1])); dMatrix ratationStep (dPitchMatrix(2.0f * 3.14151693f / steps)); dVector p0 (coneMatrix.RotateVector(dVector (size * 0.5f, 0.0f, 0.0f, 0.0f))); dVector q0 (matrix1.TransformVector(p0)); glColor3f (1.0f, 1.0f, 0.0f); for (int i = 0; i < (steps + 1); i ++) { dVector p1 (ratationStep.RotateVector(p0)); dVector q1 (matrix1.TransformVector(p1)); glVertex3f (o0.m_x, o0.m_y, o0.m_z); glVertex3f (q0.m_x, q0.m_y, q0.m_z); glVertex3f (q0.m_x, q0.m_y, q0.m_z); glVertex3f (q1.m_x, q1.m_y, q1.m_z); p0 = p1; q0 = q1; } } } } } glEnd(); }
/* * START THE VM */ void startVM(Vm* vm) { vm->PC = 0; while (charArrayToInt(0,2,vm->IR) != 99) { nextInstruction(vm); switch (charArrayToInt(0,2,vm->IR)) { case 0: o0(vm); break; case 1: o1(vm); break; case 2: o2(vm); break; case 3: o3(vm); break; case 4: o4(vm); break; case 5: o5(vm); break; case 6: o6(vm); break; case 7: o7(vm); break; case 8: o8(vm); break; case 9: o9(vm); break; case 10: o10(vm); break; case 11: o11(vm); break; case 12: o12(vm); break; case 13: o13(vm); break; case 14: o14(vm); break; case 15: o15(vm); break; case 16: o16(vm); break; case 17: o17(vm); break; case 18: o18(vm); break; case 19: o19(vm); break; case 20: o20(vm); break; case 21: o21(vm); break; case 22: o22(vm); break; case 23: o23(vm); break; case 24: o24(vm); break; case 25: o25(vm); break; case 26: o26(vm); break; case 27: o27(vm); break; case 28: o28(vm); break; case 29: o29(vm); break; case 30: o30(vm); break; case 31: o31(vm); break; case 32: o32(vm); break; case 33: o33(vm); break; case 34: o34(vm); break; case 35: o35(vm); break; case 99: o99(vm); break; default: // Code break; } displayVmFinal(vm); } }
void bv_refinementt::check_SAT(approximationt &a) { // get values get_values(a); // see if the satisfying assignment is spurious in any way const typet &type=ns.follow(a.expr.type()); if(type.id()==ID_floatbv) { // these are all trinary assert(a.expr.operands().size()==3); if(a.over_state==MAX_STATE) return; ieee_float_spect spec(to_floatbv_type(type)); ieee_floatt o0(spec), o1(spec); o0.unpack(a.op0_value); o1.unpack(a.op1_value); ieee_floatt result=o0; o0.rounding_mode=RM; o1.rounding_mode=RM; result.rounding_mode=RM; if(a.expr.id()==ID_floatbv_plus) result+=o1; else if(a.expr.id()==ID_floatbv_minus) result-=o1; else if(a.expr.id()==ID_floatbv_mult) result*=o1; else if(a.expr.id()==ID_floatbv_div) result/=o1; else assert(false); if(result.pack()==a.result_value) // ok return; #ifdef DEBUG ieee_floatt rr(spec); rr.unpack(a.result_value); std::cout << "S1: " << o0 << " " << a.expr.id() << " " << o1 << " != " << rr << std::endl; std::cout << "S2: " << integer2binary(a.op0_value, spec.width()) << " " << a.expr.id() << " " << integer2binary(a.op1_value, spec.width()) << "!=" << integer2binary(a.result_value, spec.width()) << std::endl; std::cout << "S3: " << integer2binary(a.op0_value, spec.width()) << " " << a.expr.id() << " " << integer2binary(a.op1_value, spec.width()) << "==" << integer2binary(result.pack(), spec.width()) << std::endl; #endif //if(a.over_state==1) { std::cout << "DISAGREEMENT!\n"; exit(1); } if(a.over_state<max_node_refinement) { bvt r; float_utilst float_utils(prop); float_utils.spec=spec; float_utils.rounding_mode_bits.set(RM); literalt op0_equal= bv_utils.equal(a.op0_bv, float_utils.build_constant(o0)); literalt op1_equal= bv_utils.equal(a.op1_bv, float_utils.build_constant(o1)); literalt result_equal= bv_utils.equal(a.result_bv, float_utils.build_constant(result)); literalt op0_and_op1_equal= prop.land(op0_equal, op1_equal); prop.l_set_to_true( prop.limplies(op0_and_op1_equal, result_equal)); } else { // give up // remove any previous over-approximation a.over_assumptions.clear(); a.over_state=MAX_STATE; bvt r; float_utilst float_utils(prop); float_utils.spec=spec; float_utils.rounding_mode_bits.set(RM); bvt op0=a.op0_bv, op1=a.op1_bv, res=a.result_bv; if(a.expr.id()==ID_floatbv_plus) r=float_utils.add(op0, op1); else if(a.expr.id()==ID_floatbv_minus) r=float_utils.sub(op0, op1); else if(a.expr.id()==ID_floatbv_mult) r=float_utils.mul(op0, op1); else if(a.expr.id()==ID_floatbv_div) r=float_utils.div(op0, op1); else assert(0); assert(r.size()==res.size()); bv_utils.set_equal(r, res); } } else if(type.id()==ID_signedbv || type.id()==ID_unsignedbv) { // these are all binary assert(a.expr.operands().size()==2); // already full interpretation? if(a.over_state>0) return; bv_spect spec(type); bv_arithmetict o0(spec), o1(spec); o0.unpack(a.op0_value); o1.unpack(a.op1_value); // division by zero is never spurious if((a.expr.id()==ID_div || a.expr.id()==ID_mod) && o1==0) return; if(a.expr.id()==ID_mult) o0*=o1; else if(a.expr.id()==ID_div) o0/=o1; else if(a.expr.id()==ID_mod) o0%=o1; else assert(false); if(o0.pack()==a.result_value) // ok return; if(a.over_state==0) { // we give up right away and add the full interpretation bvt r; if(a.expr.id()==ID_mult) { r=bv_utils.multiplier( a.op0_bv, a.op1_bv, a.expr.type().id()==ID_signedbv?bv_utilst::SIGNED:bv_utilst::UNSIGNED); } else if(a.expr.id()==ID_div) { r=bv_utils.divider( a.op0_bv, a.op1_bv, a.expr.type().id()==ID_signedbv?bv_utilst::SIGNED:bv_utilst::UNSIGNED); } else if(a.expr.id()==ID_mod) { r=bv_utils.remainder( a.op0_bv, a.op1_bv, a.expr.type().id()==ID_signedbv?bv_utilst::SIGNED:bv_utilst::UNSIGNED); } else assert(0); bv_utils.set_equal(r, a.result_bv); } else assert(0); } else assert(0); status() << "Found spurious `" << a.as_string() << "' (state " << a.over_state << ")" << eom; progress=true; if(a.over_state<MAX_STATE) a.over_state++; }