/* 13.1, 15.3.2 */ void syntax_check_for_syntax_errors_in_formal_param_list (bool is_strict, locus loc __attr_unused___) { if (STACK_SIZE (props) - STACK_TOP (U8) < 2 || !is_strict) { STACK_DROP (U8, 1); return; } for (uint8_t i = (uint8_t) (STACK_TOP (U8) + 1); i < STACK_SIZE (props); i = (uint8_t) (i + 1)) { JERRY_ASSERT (STACK_ELEMENT (props, i).type == VARG); literal_t previous = STACK_ELEMENT (props, i).lit; JERRY_ASSERT (previous->get_type () == LIT_STR_T || previous->get_type () == LIT_MAGIC_STR_T || previous->get_type () == LIT_MAGIC_STR_EX_T); for (uint8_t j = STACK_TOP (U8); j < i; j = (uint8_t) (j + 1)) { JERRY_ASSERT (STACK_ELEMENT (props, j).type == VARG); literal_t current = STACK_ELEMENT (props, j).lit; JERRY_ASSERT (current->get_type () == LIT_STR_T || current->get_type () == LIT_MAGIC_STR_T || current->get_type () == LIT_MAGIC_STR_EX_T); if (lit_literal_equal_type (previous, current)) { PARSE_ERROR_VARG ("Duplication of literal '%s' in FormalParameterList is not allowed in strict mode", loc, lit_literal_to_str_internal_buf (previous)); } } } STACK_DROP (props, (uint8_t) (STACK_SIZE (props) - STACK_TOP (U8))); STACK_DROP (U8, 1); }
/* 13.1, 15.3.2 */ void jsp_early_error_check_for_syntax_errors_in_formal_param_list (bool is_strict, locus loc __attr_unused___) { if (is_strict && STACK_SIZE (props) - STACK_TOP (size_t_stack) >= 2) { for (size_t i = (STACK_TOP (size_t_stack) + 1u); i < STACK_SIZE (props); i++) { JERRY_ASSERT (STACK_ELEMENT (props, i).type == VARG); literal_t previous = STACK_ELEMENT (props, i).lit; JERRY_ASSERT (previous->get_type () == LIT_STR_T || previous->get_type () == LIT_MAGIC_STR_T || previous->get_type () == LIT_MAGIC_STR_EX_T); for (size_t j = STACK_TOP (size_t_stack); j < i; j++) { JERRY_ASSERT (STACK_ELEMENT (props, j).type == VARG); literal_t current = STACK_ELEMENT (props, j).lit; JERRY_ASSERT (current->get_type () == LIT_STR_T || current->get_type () == LIT_MAGIC_STR_T || current->get_type () == LIT_MAGIC_STR_EX_T); if (lit_literal_equal_type (previous, current)) { PARSE_ERROR_VARG (JSP_EARLY_ERROR_SYNTAX, "Duplication of literal '%s' in FormalParameterList is not allowed in strict mode", loc, lit_literal_to_str_internal_buf (previous)); } } } } STACK_DROP (props, (size_t) (STACK_SIZE (props) - STACK_TOP (size_t_stack))); STACK_DROP (size_t_stack, 1); }
/*Busca y almacena en el arbol un nuevo camino a un spot libre */ void network_newFreeSpot (AbbNet net){ /*Precondicion: network_newFreeSpot() se tiene que llamar despues de haber agregado un elemento*/ networkNode * pivot; networkNode * ancestor; pivot = STACK_TOP(net->freeSpot); STACK_POP(net->freespot); assert(pivot->left == Leaf); if(pivote->right != Leaf){ if(!STACK_IS_EMPTY(net->freeSpot)){ ancestor = STACK_TOP(net->freeSpot); /*mientras el hijo derecho del ancestro es el pivote*/ while(networkNode_compare(ancestor->right, pivot) && STACK_SIZE(net->freeSpot) > 1 ){ /*sigo subiendo en el arbol*/ pivot = ancestor; STACK_POP(net->freespot); ancestor = STACK_TOP(net->freeSpot); } /*pude haber salido por que el stack esta vacion o porque ancestor->right != pivot * si sali por que el ancestro->right es diferente al pivote, entonces me voy por el * el hijo derecho del ancestro todo a la izquierda. * si sali porque llegue a la copa del arbol me voo todo a la izq a iniciar un nivel del arbol nuevo */ if(!networkNode_compare(ancestor->right, pivot){ ancestro = ancestro->right; } while(ancestor->left != Leaf){ STACK_ADD(net->freeSpot, ancestor); ancestor = ancestor->left; } } }
/* --- parsing --- */ static void handle_subvalue (DskJsonParser *parser, DskJsonValue *take) { if (parser->stack_size > 0) { /* add to last stack node */ if (STACK_TOP (parser).type == STACK_NODE_OBJECT) { STACK_TOP (parser).u.members[STACK_TOP (parser).n_subs-1].value = take; parser->parse_state = PARSE_GOT_MEMBER; } else { if (STACK_TOP (parser).n_subs == STACK_TOP (parser).subs_alloced) stack_increase_subs_alloced (&STACK_TOP (parser)); STACK_TOP (parser).u.values[STACK_TOP (parser).n_subs++] = take; parser->parse_state = PARSE_GOT_ELEMENT; } } else { /* add to queue */ ValueQueue *q = DSK_NEW (ValueQueue); q->value = take; q->next = NULL; if (parser->queue_head == NULL) parser->queue_head = q; else parser->queue_tail->next = q; parser->queue_tail = q; parser->parse_state = PARSE_INIT; } }
static void array_finished (DskJsonParser *parser) { /* create array */ DskJsonValue *array; unsigned n_values = STACK_TOP(parser).n_subs; DskJsonValue **values = STACK_TOP(parser).u.values; array = dsk_json_value_new_array (n_values, values); /* pop the stack */ parser->stack_size--; /* deal with the new array */ handle_subvalue (parser, array); }
static void object_finished (DskJsonParser *parser) { /* create object */ DskJsonValue *object; unsigned i; unsigned n_members = STACK_TOP(parser).n_subs; DskJsonMember *members = STACK_TOP(parser).u.members; object = dsk_json_value_new_object (n_members, members); /* pop the stack (free members' names) */ for (i = 0; i < n_members; i++) dsk_free (members[i].name); parser->stack_size--; /* deal with the new object */ handle_subvalue (parser, object); }
static void mark(void **block) { void *obj = *block; struct segment *seg; size_t index; bitptr_t b; ASSERT(STACK_TOP() == NULL); if (!IS_IN_HEAP(obj)) { DBG(("%p at %p outside", obj, block)); if (obj != NULL) sml_trace_ptr(obj); return; } seg = OBJ_TO_SEGMENT(obj); index = OBJ_TO_INDEX(seg, obj); BITPTR_INIT(b, BITMAP0_BASE(seg), index); if (BITPTR_TEST(b)) { DBG(("already marked: %p", obj)); return; } MARKBIT(b, index, seg); DBG(("MARK: %p", obj)); if (OBJ_HAS_NO_POINTER(obj)) { DBG(("EARLYMARK: %p", obj)); return; } for (;;) { sml_obj_enum_ptr(obj, push); obj = STACK_TOP(); if (obj == NULL) { DBG(("MARK END")); break; } STACK_POP(obj); DBG(("POP: %p", obj)); } }
int main(int argc, char **argv) { ppmDocNodeP Root1_node = ppmDocAddSection(0, "Root"); { ppmDocNodeP doc2_node = ppmDocAddSection(Root1_node, "Description"); ppmDocAddText(doc2_node, "Graphics card"); ppmDocNodeP doc_12_node = ppmDocAddSection(Root1_node, "Licensing"); ppmDocAddText(doc_12_node, "Open Source Apache 2.0"); ppmDocNodeP doc_22_node = ppmDocAddSection(Root1_node, "Limitations"); ppmDocAddText(doc_22_node, "This model has sufficient functionality to allow a Linux Kernel to Boot on the MIPS:MALTA platform. \n\ The VGA peripheral utilises memory mapping.\n\ This requires the use of ICM memory for the frame buffers, which currently may stop its use in SystemC TLM2 platforms."); ppmDocNodeP doc_32_node = ppmDocAddSection(Root1_node, "Reference"); ppmDocAddText(doc_32_node, "cirrus CL GD 5446.pdf Version 2.0 November 1996"); } // diagnostic levels > 3 are passed to the semihost library diagLevel = bhmGetDiagnosticLevel(); if(ImperasTestModeTimeout(&ImperasTestTimeout)) { bhmCreateThread(ImperasTestModeTimeoutThread, 0, "ImperasTestModeTimeoutThread", &(testStack[TEST_STACK_SIZE])); } ISAconfigConnection(ISA_PORT_NAME); char title[32]; char* titleP = 0; if (bhmStringAttribute("title", title, sizeof(title))) { titleP = title; } ds = displayInit(titleP); vs = cirrusInit( VGA_RAM_SIZE, RAM_PORT_NAME, CIRRUS_ID_CLGD5446); vgaDisplay(vs, ds); Uns32 delay = 200; bhmIntegerAttribute(SCAN_DELAY_ATTRIBUTE, &delay); pciInit(); if (BHM_DIAG_LOW) { bhmCreateThread(endSimulation, 0, "end", STACK_TOP(endStack)); bhmMessage("I", PREFIX, "Starting. Diagnostic level:%d. Scan delay:%d", diagLevel, delay); } while(1) { bhmWaitDelay(delay); updateDisplay(); updates++; } return 0; }
static void print_process_memory(Process *p) { ErlHeapFragment* bp = MBUF(p); erts_printf("==============================\n"); erts_printf("|| Memory info for %T ||\n",p->common.id); erts_printf("==============================\n"); erts_printf("-- %-*s ---%s-%s-%s-%s--\n", PTR_SIZE, "PCB", dashes, dashes, dashes, dashes); if (p->msg.first != NULL) { ErtsMessage* mp; erts_printf(" Message Queue:\n"); mp = p->msg.first; while (mp != NULL) { erts_printf("| 0x%0*lx | 0x%0*lx |\n",PTR_SIZE, ERL_MESSAGE_TERM(mp),PTR_SIZE,ERL_MESSAGE_TOKEN(mp)); mp = mp->next; } } if (p->dictionary != NULL) { int n = ERTS_PD_SIZE(p->dictionary); Eterm *ptr = ERTS_PD_START(p->dictionary); erts_printf(" Dictionary: "); while (n--) erts_printf("0x%0*lx ",PTR_SIZE,(unsigned long)ptr++); erts_printf("\n"); } if (p->arity > 0) { int n = p->arity; Eterm *ptr = p->arg_reg; erts_printf(" Argument Registers: "); while (n--) erts_printf("0x%0*lx ",PTR_SIZE,(unsigned long)*ptr++); erts_printf("\n"); } erts_printf(" Trace Token: 0x%0*lx\n",PTR_SIZE,p->seq_trace_token); erts_printf(" Group Leader: 0x%0*lx\n",PTR_SIZE,p->group_leader); erts_printf(" Fvalue: 0x%0*lx\n",PTR_SIZE,p->fvalue); erts_printf(" Ftrace: 0x%0*lx\n",PTR_SIZE,p->ftrace); erts_printf("+- %-*s -+ 0x%0*lx 0x%0*lx %s-%s-+\n", PTR_SIZE, "Stack", PTR_SIZE, (unsigned long)STACK_TOP(p), PTR_SIZE, (unsigned long)STACK_START(p), dashes, dashes); print_untagged_memory(STACK_TOP(p),STACK_START(p)); erts_printf("+- %-*s -+ 0x%0*lx 0x%0*lx 0x%0*lx 0x%0*lx +\n", PTR_SIZE, "Heap", PTR_SIZE, (unsigned long)HEAP_START(p), PTR_SIZE, (unsigned long)HIGH_WATER(p), PTR_SIZE, (unsigned long)HEAP_TOP(p), PTR_SIZE, (unsigned long)HEAP_END(p)); print_untagged_memory(HEAP_START(p),HEAP_TOP(p)); if (OLD_HEAP(p)) { erts_printf("+- %-*s -+ 0x%0*lx 0x%0*lx 0x%0*lx %s-+\n", PTR_SIZE, "Old Heap", PTR_SIZE, (unsigned long)OLD_HEAP(p), PTR_SIZE, (unsigned long)OLD_HTOP(p), PTR_SIZE, (unsigned long)OLD_HEND(p), dashes); print_untagged_memory(OLD_HEAP(p),OLD_HTOP(p)); } if (bp) erts_printf("+- %-*s -+-%s-%s-%s-%s-+\n", PTR_SIZE, "heap fragments", dashes, dashes, dashes, dashes); while (bp) { print_untagged_memory(bp->mem,bp->mem + bp->used_size); bp = bp->next; } }
void erts_limited_stack_trace(int to, void *to_arg, Process *p) { Eterm* sp; if (ERTS_TRACE_FLAGS(p) & F_SENSITIVE) { return; } if (STACK_START(p) < STACK_TOP(p)) { return; } if ((STACK_START(p) - STACK_TOP(p)) < 512) { if (erts_sys_is_area_readable((char*)STACK_TOP(p), (char*)STACK_START(p))) for (sp = STACK_TOP(p); sp < STACK_START(p); sp++) stack_trace_dump(to, to_arg, sp); else erts_print(to, to_arg, "Could not read from stack memory: %p - %p\n", STACK_TOP(p), STACK_START(p)); } else { sp = STACK_TOP(p); if (erts_sys_is_area_readable((char*)STACK_TOP(p), (char*)(STACK_TOP(p) + 25))) for (; sp < (STACK_TOP(p) + 256); sp++) stack_trace_dump(to, to_arg, sp); else erts_print(to, to_arg, "Could not read from stack memory: %p - %p\n", STACK_TOP(p), STACK_TOP(p) + 256); erts_print(to, to_arg, "%p: skipping %d frames\n", sp, STACK_START(p) - STACK_TOP(p) - 512); if (erts_sys_is_area_readable((char*)(STACK_START(p) - 256), (char*)STACK_START(p))) for (sp = STACK_START(p) - 256; sp < STACK_START(p); sp++) stack_trace_dump(to, to_arg, sp); else erts_print(to, to_arg, "Could not read from stack memory: %p - %p\n", STACK_START(p) - 256, STACK_START(p)); } }
static dsk_boolean handle_token (DskJsonParser *parser, JsonTokenType token, DskError **error) { switch (parser->parse_state) { case PARSE_INIT: /* expecting value */ case PARSE_GOT_MEMBER_COLON: /* expecting subvalue */ if (!is_allowed_subvalue_token (token)) goto bad_token; handle_expected_subvalue (parser, token); break; case PARSE_EXPECTING_ELEMENT: /* expecting subvalue */ if (token == JSON_TOKEN_RBRACKET) array_finished (parser); else if (!is_allowed_subvalue_token (token)) goto bad_token; else handle_expected_subvalue (parser, token); break; case PARSE_EXPECTING_MEMBER: if (token == JSON_TOKEN_STRING) { /* add new member; copy string */ char *name; DskJsonMember *member; if (STACK_TOP (parser).n_subs == STACK_TOP (parser).subs_alloced) stack_increase_subs_alloced (&STACK_TOP (parser)); name = dsk_strndup (parser->str_len, parser->str); member = &STACK_TOP (parser).u.members[STACK_TOP (parser).n_subs++]; member->name = name; member->value = NULL; parser->parse_state = PARSE_GOT_MEMBER_NAME; } else if (token == JSON_TOKEN_RBRACE) object_finished (parser); else goto bad_token; break; case PARSE_GOT_MEMBER_NAME: if (token != JSON_TOKEN_COLON) goto bad_token; else parser->parse_state = PARSE_GOT_MEMBER_COLON; break; case PARSE_GOT_MEMBER: /* expecting , or } */ if (token == JSON_TOKEN_COMMA) parser->parse_state = PARSE_EXPECTING_MEMBER; else if (token == JSON_TOKEN_RBRACE) { object_finished (parser); } else goto bad_token; break; case PARSE_GOT_ELEMENT: /* expecting , or ] */ if (token == JSON_TOKEN_COMMA) parser->parse_state = PARSE_EXPECTING_ELEMENT; else if (token == JSON_TOKEN_RBRACKET) { /* create array */ DskJsonValue *array; array = dsk_json_value_new_array (STACK_TOP(parser).n_subs, STACK_TOP(parser).u.values); /* pop the stack */ parser->stack_size--; /* deal with the new array */ handle_subvalue (parser, array); } else goto bad_token; break; } parser->str_len = 0; return DSK_TRUE; bad_token: dsk_set_error (error, "got unexpected token %s: %s (line %u)", token_names[token], parse_state_expecting_strings[parser->parse_state], parser->line_no); parser->str_len = 0; return DSK_FALSE; }
void syntax_check_for_duplication_of_prop_names (bool is_strict, locus loc __attr_unused___) { if (STACK_SIZE (props) - STACK_TOP (U8) < 2) { STACK_DROP (U8, 1); return; } for (uint8_t i = (uint8_t) (STACK_TOP (U8) + 1); i < STACK_SIZE (props); i++) { const prop_literal previous = STACK_ELEMENT (props, i); if (previous.type == VARG) { continue; } JERRY_ASSERT (previous.type == PROP_DATA || previous.type == PROP_GET || previous.type == PROP_SET); for (uint8_t j = STACK_TOP (U8); j < i; j = (uint8_t) (j + 1)) { /*4*/ const prop_literal current = STACK_ELEMENT (props, j); if (current.type == VARG) { continue; } JERRY_ASSERT (current.type == PROP_DATA || current.type == PROP_GET || current.type == PROP_SET); if (lit_literal_equal (previous.lit, current.lit)) { /*a*/ if (is_strict && previous.type == PROP_DATA && current.type == PROP_DATA) { PARSE_ERROR_VARG ("Duplication of parameter name '%s' in ObjectDeclaration is not allowed in strict mode", loc, lit_literal_to_str_internal_buf (current.lit)); } /*b*/ if (previous.type == PROP_DATA && (current.type == PROP_SET || current.type == PROP_GET)) { PARSE_ERROR_VARG ("Parameter name '%s' in ObjectDeclaration may not be both data and accessor", loc, lit_literal_to_str_internal_buf (current.lit)); } /*c*/ if (current.type == PROP_DATA && (previous.type == PROP_SET || previous.type == PROP_GET)) { PARSE_ERROR_VARG ("Parameter name '%s' in ObjectDeclaration may not be both data and accessor", loc, lit_literal_to_str_internal_buf (current.lit)); } /*d*/ if ((previous.type == PROP_SET && current.type == PROP_SET) || (previous.type == PROP_GET && current.type == PROP_GET)) { PARSE_ERROR_VARG ("Parameter name '%s' in ObjectDeclaration may not be accessor of same type", loc, lit_literal_to_str_internal_buf (current.lit)); } } } } STACK_DROP (props, (uint8_t) (STACK_SIZE (props) - STACK_TOP (U8))); STACK_DROP (U8, 1); }
/* Returns the index of the first unmatched character, or -1 if the match * failed */ int run (Instruction *prog, const char *target) { unsigned int pc = 0; unsigned int pos = 0; void *capture = NULL; size_t target_len = strlen(target); Instruction *instr; for (;;) { if (pc == FAIL) { /* Machine is in fail state */ if (STACK_EMPTY()) { /* No further options */ return -1; } if (STACK_TOPTYPE() == BacktrackData) { /* Backtrack to stacked alternative */ pc = STACK_TOP().alternative; pos = STACK_TOP().pos; capture = STACK_TOP().capture_info; } /* Pop one stack entry */ STACK_POP(); continue; } instr = &prog[pc]; #if 0 printf("pc = %d, pos = %d, instr = %s\n", pc, pos, instruction_names[instr->instr]); #endif switch (instr->instr) { case iEnd: return pos; case iChar: if (target[pos] == instr->character) { pos += 1; pc += 1; } else { pc = FAIL; } break; case iJump: pc += instr->offset; break; case iChoice: STACK_PUSHALT(pc + instr->offset, pos - instr->count, capture); pc += 1; break; case iCall: STACK_PUSHRET(pc + 1); pc += instr->offset; break; case iReturn: pc = STACK_TOP().ret; STACK_POP(); break; case iCommit: STACK_POP(); pc += instr->offset; break; case iCapture: /* TODO: Add capture info */ pc += 1; break; case iFail: pc = FAIL; break; case iAny: if (pos + instr->count <= target_len) { pc += 1; pos += instr->count; } else { pc = FAIL; } break; case iCharset: if (IN_CHARSET(instr->cset, target[pos])) { pc += 1; pos += 1; } else { pc = FAIL; } break; case iPartialCommit: if (STACK_TOPTYPE() == BacktrackData) { /* Replace the backtrack data on the top of the stack */ STACK_TOP().pos = pos; STACK_TOP().capture_info = capture; } else { /* Cannot happen */ assert(0); } pc += instr->offset; break; case iSpan: if (IN_CHARSET(instr->cset, target[pos])) pos += 1; else pc += 1; break; case iFailTwice: STACK_POP(); pc = FAIL; break; case iBackCommit: if (STACK_TOPTYPE() == BacktrackData) { /* Pop the position and capture info, but jump */ pos = STACK_TOP().pos; capture = STACK_TOP().capture_info; STACK_POP(); } else { /* Cannot happen */ assert(0); } pc += instr->offset; break; case iTestChar: if (target[pos] == instr->character) { pos += 1; pc += 1; } else { pc += instr->offset; } break; case iTestCharset: if (IN_CHARSET(instr->cset, target[pos])) { pos += 1; pc += 1; } else { pc += instr->offset; } break; case iTestAny: if (pos + instr->count <= target_len) { pos += instr->count; pc += 1; } else { pc += instr->offset; } break; default: /* Cannot happen - skip the instruction */ pc += 1; break; } } /* We never actually reach here - we exit at the End instruction */ return pos; }