oop ByteCode::create_outer_method_prim(oop ignore, byteVectorOop bv, objVectorOop lits, stringOop file, smiOop line, stringOop source) { Unused(ignore); ResourceMark rm; if (bv->length() == 0) return ErrorCodes::general_prim_error("Error: empty byte code vector"); smi errorIndex; IntBList* stack_deltas; const char* errorMsg = methodMap::check_byteCodes_and_literals( errorIndex, stack_deltas, bv, lits ); if (errorMsg) { char buf[BUFSIZ]; (void) sprintf(buf, "Error: bad byte code at: %d <%s>", errorIndex, errorMsg); return ErrorCodes::general_prim_error(buf); } // clone bv & lits for cheap insurance // also must clone literals because create_outerMethod will set // the methodPointer in it ByteCode b(false, new_string(bv->bytes(), bv->length()), lits->clone(), file, line, source); oop m = create_outerMethod(0, &b, "", stack_deltas); return m->as_mirror(); }
oop evalExpressions(Scanner* scanner) { // evaluate expressions until scanner is at EOF or an error occurs oop res = NULL; fint line, len; const char* source; while (!res->is_mark() && !scanner->is_done()) { // This resource mark must be inside the loop otherwise long files can // cause the resource area to become huge -miw, 12/5/94 ResourceMark rm; Parser parser(scanner, false); scanner->commentList = new TokenList(100); Expr* e = parser.readExpr(line, source, len); if (e && (AddFileAnnotationsToSlots || (ConvertCommentsIntoAnnotations && scanner->commentList->length() > 0)) ) { e->addCommentAnnotations(scanner); } if (e) { preservedObj x(e); // for GenByteCodes if (ScavengeInPrimitives && Memory->needs_scavenge()) { Memory->scavenge(); } ByteCode b(true); slotsOop evalMethod; if (! e->GenByteCodes(&b, 0) || NLRSupport::have_NLR_through_C() ) res = badOop; else if ( !b.Finish(scanner->fileName(), line, source, len)) { e->ErrorMessage(b.errorMessage); res = badOop; } else evalMethod = create_outerMethod(EMPTY, &b); if (!res->is_mark()) { res = currentProcess->runDoItMethod(Memory->lobbyObj, evalMethod); if (NLRSupport::have_NLR_through_C()) break; // let NLR go through } } else if (!parser.noParseError()) { res = badOop; } else { // empty line } // Tokens are allocated in the resource area, which is about to be freed. // Reset the list so that we don't attempt to use any next time. scanner->resetTokenList(); } if (currentProcess->hadStackOverflow()) { res = ErrorCodes::vmString_prim_error(STACKOVERFLOWERROR); } return res; }