static void walk_exp_non_tail_if(FILE* oc, std::string dest, E* e1, E* e2, std::string b, std::string bn) { auto b_else = genid(b + "_else"); auto b_cont = genid(b + "_cont"); fprintf(oc, "\t%s\t%s\n", bn.c_str(), b_else.c_str()); auto stackset_back = stackset; walk_e_non_tail(oc, dest, e1); auto stackset1 = stackset; fprintf(oc, "\tjmp\t%s\n", b_cont.c_str()); fprintf(oc, "%s:\n", b_else.c_str()); stackset = stackset_back; walk_e_non_tail(oc, dest, e2); fprintf(oc, "%s:\n", b_cont.c_str()); stackset.insert(stackset1.begin(), stackset1.end()); }
void* thread_proc (void* arg) { pthread_detach (pthread_self ()); int connfd = (int)arg; OPEN_REQUEST req; if (rcvreq (connfd, &req, sizeof (req)) == -1) return NULL; OPEN_RESPOND res = {""}; ACCOUNT acc; if ((acc.id = genid ()) == -1) { sprintf (res.error, "创立账户失败!"); goto send_respond; } strcpy (acc.name, req.name); strcpy (acc.passwd, req.passwd); acc.balance = req.balance; if (save (&acc) == -1) { sprintf (res.error, "保存账户失败!"); goto send_respond; } res.id = acc.id; send_respond: if (sndres (connfd, &res, sizeof (res)) == -1) return NULL; return NULL; }
static void walk_exp_tail_if(FILE* oc, E* e1, E* e2, std::string b, std::string bn) { auto b_else = genid(b + "_else"); fprintf(oc, "\t%s\t%s\n", bn.c_str(), b_else.c_str()); auto stackset_back = stackset; walk_e_tail(oc, e1); fprintf(oc, "%s:\n", b_else.c_str()); stackset = stackset_back; walk_e_tail(oc, e2); }
port_t* mkport(const port_kind_t* kind, cpVect pos) { if(kind == NULL) { return NULL; // nyurupo~ } if(kind->mk == NULL) { return NULL; // not implemented } port_t* p = malloc(sizeof *p); p->id = genid(); if(kind->mk(p)) { return NULL; // TODO error handling } cpBodySetPos(p->body, pos); return p; }