static void Storage_class(sym_pt templt){ switch(Scanner::token()){ case T_STATIC: if(templt->storage) crit_error("Storage_class(): storage class already set"); templt->storage = sc_static; Scanner::next_token(); break; case T_EXTRN: if(templt->storage) crit_error("Storage_class(): storage class already set"); templt->storage = sc_extern; Scanner::next_token(); break; } }
// ========== Connection Handling ========== void handle_connection() { pid_t pid; int cfd; char c; // Wait to accept connection cfd = accept(sfd, NULL, NULL); if (cfd == -1) { crit_error("Could not accept connections"); } pid = fork(); if (pid == -1) error("Fork"); if (pid == 0) { // we are the child. child_function(cfd); printf("Spawned child exiting.\n"); while(read(cfd, &c, 1) > 0); std::cout << "Connection reading..." << std::endl; close(cfd); std::cout << "Connection closed." << std::endl; exit(0); } else { // we are the parent close(cfd); // the child handles this } }
static void Type_qualifier(sym_pt templt){ if(templt->qual) crit_error("Type_qualifier(): qualifier already set"); switch(Scanner::token()){ case T_RO : templt->qual = q_ro ; Scanner::next_token(); break; case T_VOL: templt->qual = q_volatile; Scanner::next_token(); break; } }
// get the current context prefix inline const char * Context_Stack::prefix(void){ contxt_pt con; con=first(); if(!con) crit_error("Context_Stack::prefix(): no context"); if(con->parent) return con->parent->full_name(); else return ""; }
void Context_Stack::nq_inst( str_dx a, op_code b, str_dx c, const sym_pt d, const sym_pt e, const sym_pt f ){ contxt_pt con; con = first(); if(!con) crit_error("Context_Stack::instructions(): the context stack is empty"); else con->inst_q->add_inst(a, b, c, d, e, f); }
void obstack::free(page *chunk, char *obj) { page *tmp; while ((tmp = chunk->next) && (chunk->firstp >= obj || chunk->endp < obj)) { _pa->free(chunk); chunk = tmp; /* If we switch chunks, we can't tell whether the new current chunk contains an empty object, so assume that it may. */ _maybe_empty_object = true; } if (!tmp && (chunk->firstp > obj || chunk->endp < obj)) { crit_error("obstack free failed, obj is not in any of the chunks!"); } _object_base = _next_free = obj; _chunk_limit = chunk->endp; _chunk = chunk; }
/* This function returns the correct symbol for the given name in the current context */ sym_pt Context_Stack::bind(const char * given_name){ sym_pt sym=NULL; contxt_pt con; // const char * prefix; std::string full_name; con = first(); if(!con) crit_error("Context_Stack::bind(): stack is empty"); // if(con->parent){ // prefix = con->parent->full_name(); // length += strlen(prefix) + 1; // // // resize the buffer // if(length > buf_l){ // buffer = (char*) realloc(buffer, length); // buf_l = length; // } // } // search the context stack while ( con->parent ){ full_name = con->parent->full_name(); full_name += given_name; if(( sym = Syms::find(full_name.c_str()) )) break; con = next(); } // if we didn't find anything, check the global context if(!sym) sym = Syms::find(given_name); // Set the token // return sym; }