int test_machine() { Machine m; Instr instr1; instr1.o = Op(OpType::MOV, OpLayout::MC).op; instr1.mc.a = 10; instr1.mc.c = 16; m.mem[1] = instr1.uint64; Instr instr2; instr2.o = Op(OpType::MOV, OpLayout::RC).op; instr2.rc.r = 1; instr2.rc.c = 16; m.mem[2] = instr2.uint64; Instr instr3; instr3.o = Op(OpType::INT, OpLayout::C).op; instr3.c = 2; m.mem[3] = instr3.uint64; Instr instr10; instr10.o = Op(OpType::HALT, OpLayout::NONE).op; m.mem[4] = instr10.uint64; m.run(); //cout << m.r[0] << "\n"; //cout << m.mem[5] << "\n"; //char c = getch(); //testOp(); }
cTCPLink::cCallbacksPtr cLuaServerHandle::OnIncomingConnection(const AString & a_RemoteIPAddress, UInt16 a_RemotePort) { // If not valid anymore, drop the connection: if (!m_Callbacks.IsValid()) { return nullptr; } // Ask the plugin for link callbacks: cPluginLua::cOperation Op(m_Plugin); cLuaState::cRef LinkCallbacks; if ( !Op().Call(cLuaState::cTableRef(m_Callbacks, "OnIncomingConnection"), a_RemoteIPAddress, a_RemotePort, m_Port, cLuaState::Return, LinkCallbacks) || !LinkCallbacks.IsValid() ) { LOGINFO("cNetwork server (port %d) OnIncomingConnection callback failed in plugin %s. Dropping connection.", m_Port, m_Plugin.GetName().c_str() ); return nullptr; } // Create the link wrapper to use with the callbacks: auto res = std::make_shared<cLuaTCPLink>(m_Plugin, std::move(LinkCallbacks), m_Self); // Add the link to the list of our connections: cCSLock Lock(m_CSConnections); m_Connections.push_back(res); return res; }
void RenderNode::issueDrawShadowOperation(const Matrix4& transformFromParent, T& handler) { if (properties().getAlpha() <= 0.0f || properties().getOutline().getAlpha() <= 0.0f || !properties().getOutline().getPath() || properties().getScaleX() == 0 || properties().getScaleY() == 0) { // no shadow to draw return; } mat4 shadowMatrixXY(transformFromParent); applyViewPropertyTransforms(shadowMatrixXY); // Z matrix needs actual 3d transformation, so mapped z values will be correct mat4 shadowMatrixZ(transformFromParent); applyViewPropertyTransforms(shadowMatrixZ, true); const SkPath* casterOutlinePath = properties().getOutline().getPath(); const SkPath* revealClipPath = properties().getRevealClip().getPath(); if (revealClipPath && revealClipPath->isEmpty()) return; float casterAlpha = properties().getAlpha() * properties().getOutline().getAlpha(); // holds temporary SkPath to store the result of intersections SkPath* frameAllocatedPath = nullptr; const SkPath* outlinePath = casterOutlinePath; // intersect the outline with the reveal clip, if present if (revealClipPath) { frameAllocatedPath = handler.allocPathForFrame(); Op(*outlinePath, *revealClipPath, kIntersect_SkPathOp, frameAllocatedPath); outlinePath = frameAllocatedPath; } // intersect the outline with the clipBounds, if present if (properties().getClippingFlags() & CLIP_TO_CLIP_BOUNDS) { if (!frameAllocatedPath) { frameAllocatedPath = handler.allocPathForFrame(); } Rect clipBounds; properties().getClippingRectForFlags(CLIP_TO_CLIP_BOUNDS, &clipBounds); SkPath clipBoundsPath; clipBoundsPath.addRect(clipBounds.left, clipBounds.top, clipBounds.right, clipBounds.bottom); Op(*outlinePath, clipBoundsPath, kIntersect_SkPathOp, frameAllocatedPath); outlinePath = frameAllocatedPath; } DisplayListOp* shadowOp = new (handler.allocator()) DrawShadowOp( shadowMatrixXY, shadowMatrixZ, casterAlpha, outlinePath); handler(shadowOp, PROPERTY_SAVECOUNT, properties().getClipToBounds()); }
/** * Return the number of successor-edges including fall-through paths but not * implicit exception paths. */ int numSuccs(const Opcode* instr) { if (!instrIsControlFlow(*instr)) return 1; if ((instrFlags(*instr) & TF) != 0) { if (Op(*instr) == OpSwitch) return *(int*)(instr + 1); if (Op(*instr) == OpJmp) return 1; return 0; } if (instrJumpOffset(const_cast<Opcode*>(instr))) return 2; return 1; }
bool SceneEditorVP::DoNotify(const ork::event::Event* pev) { const ork::ent::SceneInstEvent* sei = ork::rtti::autocast(pev); if(sei) { switch(sei->GetEvent()) { case ork::ent::SceneInstEvent::ESIEV_DISABLE_UPDATE: { auto lamb = [=]() { gUpdateStatus.SetState(EUPD_STOP); }; Op(lamb).QueueASync(UpdateSerialOpQ()); break; } case ork::ent::SceneInstEvent::ESIEV_ENABLE_UPDATE: { auto lamb = [=]() { gUpdateStatus.SetState(EUPD_START); }; Op(lamb).QueueASync(UpdateSerialOpQ()); break; } case ork::ent::SceneInstEvent::ESIEV_DISABLE_VIEW: { auto lamb = [=]() { this->DisableSceneDisplay(); //#disable path that would lead to gfx globallock //# maybe show a "loading" screen or something }; Op(lamb).QueueASync(MainThreadOpQ()); //mDbLock.ReleaseCurrent(); break; } case ork::ent::SceneInstEvent::ESIEV_ENABLE_VIEW: { auto lamb = [=]() { this->EnableSceneDisplay(); //#disable path that would lead to gfx globallock //# maybe show a "loading" screen or something }; Op(lamb).QueueASync(MainThreadOpQ()); //mDbLock.ReleaseCurrent(); break; } case ork::ent::SceneInstEvent::ESIEV_BIND: //mDbLock.ReleaseCurrent(); break; case ork::ent::SceneInstEvent::ESIEV_START: break; case ork::ent::SceneInstEvent::ESIEV_STOP: break; case ork::ent::SceneInstEvent::ESIEV_USER: break; } } return false; }
TestRPCServerMRC::TestRPCServerMRC() : file_size_(1024 * 1024) { interface_id_ = INTERFACE_ID_MRC; // Register available operations. operations_[PROC_ID_OPEN] = Op(this, &TestRPCServerMRC::OpenOperation); operations_[PROC_ID_XTREEMFS_RENEW_CAPABILITY] = Op(this, &TestRPCServerMRC::RenewCapabilityOperation); operations_[PROC_ID_XTREEMFS_UPDATE_FILE_SIZE] = Op(this, &TestRPCServerMRC::UpdateFileSizeOperation); operations_[PROC_ID_FTRUNCATE] = Op(this, &TestRPCServerMRC::FTruncate); }
cLuaTCPLink::cLuaTCPLink(cPluginLua & a_Plugin, int a_CallbacksTableStackPos): m_Plugin(a_Plugin), m_Callbacks(cPluginLua::cOperation(a_Plugin)(), a_CallbacksTableStackPos) { // Warn if the callbacks aren't valid: if (!m_Callbacks.IsValid()) { LOGWARNING("cTCPLink in plugin %s: callbacks could not be retrieved", m_Plugin.GetName().c_str()); cPluginLua::cOperation Op(m_Plugin); Op().LogStackTrace(); } }
edge *Join(edge *a, point *u, edge *b, point *v, int side) { edge *e = Make_edge(u, v); if (side == 1) { if (Oi(a) == u) Splice(Op(a), e, u); else Splice(Dp(a), e, u); Splice(b, e, v); } else { Splice(a, e, u); if (Oi(b) == v) Splice(Op(b), e, v); else Splice(Dp(b), e, v); } return e; }
TestRPCServerDIR::TestRPCServerDIR() { interface_id_ = INTERFACE_ID_DIR; // Register available operations. operations_[PROC_ID_XTREEMFS_SERVICE_GET_BY_NAME] = Op(this, &TestRPCServerDIR::GetServiceByNameOperation); operations_[PROC_ID_XTREEMFS_SERVICE_GET_BY_UUID] = Op(this, &TestRPCServerDIR::GetServiceByUUIDOperation); operations_[PROC_ID_XTREEMFS_ADDRESS_MAPPINGS_GET] = Op(this, &TestRPCServerDIR::GetAddressMappingOperation); }
cLuaTCPLink::cLuaTCPLink(cPluginLua & a_Plugin, cLuaState::cRef && a_CallbacksTableRef, cLuaServerHandleWPtr a_ServerHandle): m_Plugin(a_Plugin), m_Callbacks(std::move(a_CallbacksTableRef)), m_Server(std::move(a_ServerHandle)) { // Warn if the callbacks aren't valid: if (!m_Callbacks.IsValid()) { LOGWARNING("cTCPLink in plugin %s: callbacks could not be retrieved", m_Plugin.GetName().c_str()); cPluginLua::cOperation Op(m_Plugin); Op().LogStackTrace(); } }
bool cLuaChunkStay::AddChunks(int a_ChunkCoordTableStackPos) { // This function is expected to be called just once, with all the coords in a table ASSERT(m_Chunks.empty()); cPluginLua::cOperation Op(m_Plugin); cLuaState & L = Op(); // Check that we got a table: if (!lua_istable(L, a_ChunkCoordTableStackPos)) { LOGWARNING("%s: The parameter is not a table of coords (got %s). Ignoring the call.", __FUNCTION__, lua_typename(L, lua_type(L, a_ChunkCoordTableStackPos)) ); L.LogStackTrace(); return false; } // Add each set of coords: int NumChunks = luaL_getn(L, a_ChunkCoordTableStackPos); m_Chunks.reserve((size_t)NumChunks); for (int idx = 1; idx <= NumChunks; idx++) { // Push the idx-th element of the array onto stack top, check that it's a table: lua_rawgeti(L, a_ChunkCoordTableStackPos, idx); if (!lua_istable(L, -1)) { LOGWARNING("%s: Element #%d is not a table (got %s). Ignoring the element.", __FUNCTION__, idx, lua_typename(L, -1) ); L.LogStackTrace(); lua_pop(L, 1); continue; } AddChunkCoord(L, idx); lua_pop(L, 1); } // If there are no chunks, log a warning and return failure: if (m_Chunks.empty()) { LOGWARNING("%s: Zero chunks to stay.", __FUNCTION__); L.LogStackTrace(); return false; } // All ok return true; }
void cLuaTCPLink::ReceivedCleartextData(const char * a_Data, size_t a_NumBytes) { // Check if we're still valid: if (!m_Callbacks.IsValid()) { return; } // Call the callback: cPluginLua::cOperation Op(m_Plugin); if (!Op().Call(cLuaState::cTableRef(m_Callbacks, "OnReceivedData"), this, AString(a_Data, a_NumBytes))) { LOGINFO("cTCPLink OnReceivedData callback failed in plugin %s.", m_Plugin.GetName().c_str()); } }
bool cLuaChunkStay::OnAllChunksAvailable(void) { { // Call the callback: cPluginLua::cOperation Op(m_Plugin); Op().Call((int)m_OnAllChunksAvailable); // Remove the callback references - they won't be needed anymore m_OnChunkAvailable.UnRef(); m_OnAllChunksAvailable.UnRef(); } // Disable the ChunkStay by returning true return true; }
void cLuaTCPLink::OnConnected(cTCPLink & a_Link) { // Check if we're still valid: if (!m_Callbacks.IsValid()) { return; } // Call the callback: cPluginLua::cOperation Op(m_Plugin); if (!Op().Call(cLuaState::cTableRef(m_Callbacks, "OnConnected"), this)) { LOGINFO("cTCPLink OnConnected() callback failed in plugin %s.", m_Plugin.GetName().c_str()); } }
void pop() { key[heap[1].first] = 0; heap[1] = heap[sz--]; if (sz == 0) return; key[heap[1].first] = 1; for (int pos=1, c; (c=pos<<1) <= sz; pos=c) { if (c<sz && Op()(heap[c+1].second, heap[c].second)) ++c; if (Op()(heap[c].second, heap[pos].second)) { std::swap(heap[c], heap[pos]); key[heap[c].first] = c; key[heap[pos].first] = pos; } else break; } }
void Parser::Expp() { switch(look.kind) { case LT: case TIMES: case PLUS: case OR: case AND: case GT: case EQ: case MINUS: case DIV: Op();Exp();Expp();return; case LBRACK: Match(LBRACK);Exp();Match(RBRACK);Expp();return; case DOT: Match(DOT); switch(look.kind) { case LENGTH:Match(LENGTH);Expp();return; case ID: Id();Match(LPAREN);ExpList();Match(RPAREN);Expp(); default: return; } case RPAREN: case SEMICOLON: return; } }
bool SkClipStack::asPath(SkPath *path) const { bool isAA = false; path->reset(); path->setFillType(SkPath::kInverseEvenOdd_FillType); SkClipStack::Iter iter(*this, SkClipStack::Iter::kBottom_IterStart); while (const SkClipStack::Element* element = iter.next()) { SkPath operand; if (element->getType() != SkClipStack::Element::kEmpty_Type) { element->asPath(&operand); } SkRegion::Op elementOp = element->getOp(); if (elementOp == SkRegion::kReplace_Op) { *path = operand; } else { Op(*path, operand, (SkPathOp)elementOp, path); } // if the prev and curr clips disagree about aa -vs- not, favor the aa request. // perhaps we need an API change to avoid this sort of mixed-signals about // clipping. isAA = (isAA || element->isAA()); } return isAA; }
void CheckResults(const TestDatum &test, ib_status_t rc, ib_flags_t result) { const TextBuf &exout = ExpectedOut(test); bool exmod = (exout != test.InBuf()); ib_flags_t exresult = ExpectedResult( Op(), exmod ); CheckResult(test.LineNo(), test, rc, exresult, result); const char *out = m_outbuf.GetBuf(); if (out != NULL) { size_t outlen = m_outbuf.GetLen(); size_t exlen = exout.GetLen(); EXPECT_EQ(exlen, outlen) << "Line " << test.LineNo() << ": " << Stringize(test) << " expected len=" << exlen << ", actual len=" << outlen; EXPECT_TRUE(exout == m_outbuf) << "Line " << test.LineNo() << ": " << Stringize(test) << " expected=\"" << exout.GetFmt() << "\"" << " actual=\"" << m_outbuf.GetFmt() << "\""; } }
virtual void CheckResults(const TestDatum &test, ib_status_t rc, ib_flags_t result) { size_t lno = test.LineNo(); const char *out = m_outbuf.GetBuf(); const TextBuf &exout = ExpectedOut(test); bool exmod = (test.InBuf() != exout); ib_flags_t exresult = ExpectedResult(Op(), exmod); CheckResult(lno, test, rc, exresult, result); EXPECT_STRNE(NULL, out) << "Line " << lno << ": " << Stringize(test) << " Data out is NULL"; if (out != NULL) { const char *exbuf = exout.GetBuf(); EXPECT_STREQ(exbuf, out) << "Line " << lno << ": " << Stringize(test) << " expected=\"" << exout.GetFmt() << " actual=\"" << m_outbuf.GetFmt() << "\""; } }
static int cfuncall (const double kc, const double c[], double f[], void *params) // calculate all components simultaneously { size_t n,m,q; const size_t NB=model->total_bands; const size_t N2=NB*NB; const odeparams pars = * (odeparams *) params; const ThreeVector dir = pars.dir; complex double * cc = (complex double*) c; complex double * fc = (complex double*) f; // calculate matrix elements from c[] ThreeVector k = dir; three_vector_scale(&k,kc); if (!pars.pos) three_vector_scale(&k,-1.0); three_vector_incr(&k,&pars.kperp); if(fabs(dir.x[0])>1e-5*three_vector_length(&dir)) { model->dHdx (dHx, &k); } if(fabs(dir.x[1])>1e-5*three_vector_length(&dir)) { model->dHdy (dHy, &k); } if(fabs(dir.x[2])>1e-5*three_vector_length(&dir)) { model->dHdz (dHz, &k); } three_vector_array_project_inplace ((double*) wc, (double *) dHx, (double *) dHy, (double *) dHz, &dir, 2*N2); complex double *W = model->buffer1; complex_array_zero(W,N2); matrix_transform (W, cc, wc, NB); memset(f, 0, sizeof(double)*(2*N2+NB)); for (n=0;n<NB;n++) { Op(n) = creal(W[n+n*NB]); } for (n=0;n<NB;n++) { for (q=0;q<NB;q++) { double omegadiff=O(n)-O(q); if (fabs(omegadiff)>1e-11) { // was 1e-12 complex double aa = W[q*NB+n]/omegadiff; for (m=0;m<NB;m++) { F(m,n)+=aa*C(m,q); } } } } if (!pars.pos) for (m=0;m<2*N2+NB;m++) f[m]=-f[m]; return GSL_SUCCESS; }
template <typename TIter> void Insert(TIter it, size_type n) { if (n != 0) { Op(INSERT, n); m_PatchWriter.WriteData(it, n); } }
virtual void op(void *&inbuf, void *&outbuf) const { value_type *tin = align_cast<value_type>(inbuf); value_type *tout = align_cast<value_type>(outbuf); for (size_t i = m_length; i; --i) Op(tout++, tin++); inbuf = tin; outbuf = tout; }
void cLuaServerHandle::OnError(int a_ErrorCode, const AString & a_ErrorMsg) { // Check if we're still valid: if (!m_Callbacks.IsValid()) { return; } // Notify the plugin: cPluginLua::cOperation Op(m_Plugin); if (!Op().Call(cLuaState::cTableRef(m_Callbacks, "OnError"), a_ErrorCode, a_ErrorMsg)) { LOGINFO("cNetwork server (port %d) OnError callback failed in plugin %s. The error is %d (%s).", m_Port, m_Plugin.GetName().c_str(), a_ErrorCode, a_ErrorMsg.c_str() ); return; } }
void cLuaServerHandle::OnAccepted(cTCPLink & a_Link) { // Check if we're still valid: if (!m_Callbacks.IsValid()) { return; } // Notify the plugin: cPluginLua::cOperation Op(m_Plugin); if (!Op().Call(cLuaState::cTableRef(m_Callbacks, "OnAccepted"), static_cast<cLuaTCPLink *>(a_Link.GetCallbacks().get()))) { LOGINFO("cNetwork server (port %d) OnAccepted callback failed in plugin %s, connection to %s:%d.", m_Port, m_Plugin.GetName().c_str(), a_Link.GetRemoteIP().c_str(), a_Link.GetRemotePort() ); return; } }
DoubleCRT& DoubleCRT::Op(const ZZX &poly, Fun fun) { if (dryRun) return *this; const IndexSet& s = map.getIndexSet(); DoubleCRT other(poly, context, s); // other defined wrt same primes as *this return Op(other, fun); }
void cLuaTCPLink::OnError(int a_ErrorCode, const AString & a_ErrorMsg) { // Check if we're still valid: if (!m_Callbacks.IsValid()) { return; } // Call the callback: cPluginLua::cOperation Op(m_Plugin); if (!Op().Call(cLuaState::cTableRef(m_Callbacks, "OnError"), this, a_ErrorCode, a_ErrorMsg)) { LOGINFO("cTCPLink OnError() callback failed in plugin %s; the link error is %d (%s).", m_Plugin.GetName().c_str(), a_ErrorCode, a_ErrorMsg.c_str() ); } Terminated(); }
void draw(SkCanvas* canvas) { SkPaint paint; paint.setTextSize(80); SkPath path, path2; paint.getTextPath("ABC", 3, 20, 80, &path); path.offset(20, 20, &path2); Op(path, path2, SkPathOp::kDifference_SkPathOp, &path); path.addPath(path2); paint.setStyle(SkPaint::kStroke_Style); canvas->drawPath(path, paint); }
static bool innerPathOp(skiatest::Reporter* reporter, const SkPath& a, const SkPath& b, const SkPathOp shapeOp, const char* testName, bool threaded) { #if DEBUG_SHOW_TEST_NAME if (testName == NULL) { SkDebugf("\n"); showPathData(a); showOp(shapeOp); showPathData(b); } else { SkPathOpsDebug::ShowPath(a, b, shapeOp, testName); } #endif SkPath out; if (!Op(a, b, shapeOp, &out) ) { SkDebugf("%s did not expect failure\n", __FUNCTION__); REPORTER_ASSERT(reporter, 0); return false; } if (threaded && !reporter->verbose()) { return true; } SkPath pathOut, scaledPathOut; SkRegion rgnA, rgnB, openClip, rgnOut; openClip.setRect(-16000, -16000, 16000, 16000); rgnA.setPath(a, openClip); rgnB.setPath(b, openClip); rgnOut.op(rgnA, rgnB, (SkRegion::Op) shapeOp); rgnOut.getBoundaryPath(&pathOut); SkMatrix scale; scaleMatrix(a, b, scale); SkRegion scaledRgnA, scaledRgnB, scaledRgnOut; SkPath scaledA, scaledB; scaledA.addPath(a, scale); scaledA.setFillType(a.getFillType()); scaledB.addPath(b, scale); scaledB.setFillType(b.getFillType()); scaledRgnA.setPath(scaledA, openClip); scaledRgnB.setPath(scaledB, openClip); scaledRgnOut.op(scaledRgnA, scaledRgnB, (SkRegion::Op) shapeOp); scaledRgnOut.getBoundaryPath(&scaledPathOut); SkBitmap bitmap; SkPath scaledOut; scaledOut.addPath(out, scale); scaledOut.setFillType(out.getFillType()); int result = comparePaths(reporter, pathOut, scaledPathOut, out, scaledOut, bitmap, a, b, shapeOp, scale); if (result && gPathStrAssert) { REPORTER_ASSERT(reporter, 0); } reporter->bumpTestCount(); return result == 0; }
static SkRRect path_contains_rrect(skiatest::Reporter* reporter, const SkPath& path) { SkRRect out; REPORTER_ASSERT(reporter, path.isRRect(&out)); SkPath path2, xorBoth; path2.addRRect(out); if (path == path2) { return out; } Op(path, path2, SkPathOp::kXOR_SkPathOp, &xorBoth); REPORTER_ASSERT(reporter, xorBoth.isEmpty()); return out; }
bool testPathFailOp(skiatest::Reporter* reporter, const SkPath& a, const SkPath& b, const SkPathOp shapeOp, const char* testName) { #if DEBUG_SHOW_TEST_NAME showName(a, b, shapeOp); #endif SkPath out; if (Op(a, b, shapeOp, &out) ) { SkDebugf("%s test is expected to fail\n", __FUNCTION__); REPORTER_ASSERT(reporter, 0); return false; } return true; }