void PreClass::prettyPrint(std::ostream &out) const { out << "Class "; if (m_attrs & AttrAbstract) { out << "abstract "; } if (m_attrs & AttrFinal) { out << "final "; } if (m_attrs & AttrInterface) { out << "interface "; } out << m_name->data() << " at " << m_offset; if (m_hoistable == MaybeHoistable) { out << " (maybe-hoistable)"; } else if (m_hoistable == AlwaysHoistable) { out << " (always-hoistable)"; } if (m_attrs & AttrUnique) out << " (unique)"; if (m_attrs & AttrPersistent) out << " (persistent)"; if (m_id != -1) { out << " (ID " << m_id << ")"; } out << std::endl; for (Func* const* it = methods(); it != methods() + numMethods(); ++it) { out << " "; (*it)->prettyPrint(out); } for (const Prop* it = properties(); it != properties() + numProperties(); ++it) { out << " "; it->prettyPrint(out); } for (const Const* it = constants(); it != constants() + numConstants(); ++it) { out << " "; it->prettyPrint(out); } }
class_info get_class_info(const object& o) { lua_State* L = o.interpreter(); class_info result; o.push(L); detail::object_rep* obj = static_cast<detail::object_rep*>(lua_touserdata(L, -1)); lua_pop(L, 1); result.name = obj->crep()->name(); obj->crep()->get_table(L); object methods(from_stack(L, -1)); methods.swap(result.methods); lua_pop(L, 1); result.attributes = newtable(L); typedef detail::class_rep::property_map map_type; std::size_t index = 1; for (map_type::const_iterator i = obj->crep()->properties().begin(); i != obj->crep()->properties().end(); ++i, ++index) { result.attributes[index] = i->first; } return result; }
void AccountsPreferencesPane::onAddServiceButtonClicked() { // FIXME we should here provide a nice dialog for choosing an appropriate service // However, for now, create only that which is allowed QVariantMap defaults(Utopia::defaults()); if (defaults.contains("service_uri")) { QString serviceUri = defaults["service_uri"].toString(); Service * newService = new Service; newService->setUrl(serviceUri); QVariantMap methods(newService->supportedAuthenticationMethods()); if (methods.size() > 0) { if (methods.size() == 1 || true) { newService->setAuthenticationMethod((--methods.end()).key()); bool anon = newService->resourceCapabilities(Service::AuthenticationResource).contains("anonymous"); if (anon) { newService->setAnonymous(true); } serviceManager->addService(newService); serviceManager->start(newService); } else { // FIXME should make list } } else { delete newService; } } else { NewAccountDialog dialog; dialog.exec(); } }
void mixinOopDesc::uncustomize_methods() { objArrayOop array = methods(); for (int index = 1; index <= array->length(); index++) { methodOop m = methodOop(array->obj_at(index)); m->uncustomize_for(this); } }
/** * @brief Class::allMethods * @param s * @return */ MethodsList Class::allMethods(Section s) const { MethodsList result; result << methods(s) << optionalMethods(s); return result; }
void mixinOopDesc::customize_for(klassOop klass) { objArrayOop array = methods(); for (int index = 1; index <= array->length(); index++) { methodOop m = methodOop(array->obj_at(index)); m->customize_for(klass, this); } }
// Allocates memory void quotation_jit::emit_mega_cache_lookup(cell methods_, fixnum index, cell cache_) { data_root<array> methods(methods_, parent); data_root<array> cache(cache_, parent); // Load the object from the datastack. emit_with_literal(parent->special_objects[PIC_LOAD], tag_fixnum(-index * sizeof(cell))); // Do a cache lookup. emit_with_literal(parent->special_objects[MEGA_LOOKUP], cache.value()); // If we end up here, the cache missed. emit(parent->special_objects[JIT_PROLOG]); // Push index, method table and cache on the stack. push(methods.value()); push(tag_fixnum(index)); push(cache.value()); word_call(parent->special_objects[MEGA_MISS_WORD]); // Now the new method has been stored into the cache, and its on // the stack. emit(parent->special_objects[JIT_EPILOG]); emit(parent->special_objects[JIT_EXECUTE]); }
T &methods(Istanbul::Web::HTTP::Method method, MethodArgs ... args_method) { methods(args_method...); static_cast<T *>(this)->methods_ |= 1 << (int) method; return static_cast<T &>(*this); }
Environment::MethodsPtr Environment::get_class_methods_list(std::string& cls_name) { Environment::MethodsPtr methods(new std::vector<PairOfStrPtr>); ClsInfoPtr cls = this->get_class(cls_name); std::list<ClsInfoPtr> inheritance_chain; while (cls) { inheritance_chain.push_front(cls); cls = cls->lat_cls_parent; } for (std::list<ClsInfoPtr>::iterator it = inheritance_chain.begin(); it != inheritance_chain.end(); it++) { for(Environment::lat_class::methods_t::iterator m_it = (*it)->methods.begin(); m_it != (*it)->methods.end(); m_it++) { FunInfoPtr fun = m_it->second; int position_on_vector = fun->position - Environment::object_methods_offset; StringPtr cls_name_ptr(new std::string((*it)->ident)); StringPtr function_ident_ptr(new std::string(m_it->first)); PairOfStrPtr new_function( std::make_pair( cls_name_ptr, function_ident_ptr) ); if (methods->size() <= (unsigned)position_on_vector) methods->resize(position_on_vector + 1); (*methods)[position_on_vector] = new_function; // maybe function will be overriden } } return methods; }
// [F] Method* MethodGroup::Find(const FunctionType& type) const { for (auto& method: methods()) { if (method.function_type() == type) return &method; } return nullptr; } // Find
// Write the method information portion of ClassFile structure // JVMSpec| u2 methods_count; // JVMSpec| method_info methods[methods_count]; void JvmtiClassFileReconstituter::write_method_infos() { HandleMark hm(thread()); objArrayHandle methods(thread(), ikh()->methods()); int num_methods = methods->length(); write_u2(num_methods); if (JvmtiExport::can_maintain_original_method_order()) { int index; int original_index; int* method_order = NEW_RESOURCE_ARRAY(int, num_methods); // invert the method order mapping for (index = 0; index < num_methods; index++) { original_index = ikh()->method_ordering()->int_at(index); assert(original_index >= 0 && original_index < num_methods, "invalid original method index"); method_order[original_index] = index; } // write in original order for (original_index = 0; original_index < num_methods; original_index++) { index = method_order[original_index]; methodHandle method(thread(), (methodOop)(ikh()->methods()->obj_at(index))); write_method_info(method); } } else { // method order not preserved just dump the method infos for (int index = 0; index < num_methods; index++) {
static void luaopen(lua_State* L) { luaL_newmetatable(L, metatable); lua_pushvalue(L, -1); luax::setfuncs(L, methods()); lua_setfield(L, -2, "__index"); lua_pop(L, 1); }
bool mixinOopDesc::includes_method(methodOop method) { objArrayOop array = methods(); for (int index = 1; index <= array->length(); index++) { methodOop m = methodOop(array->obj_at(index)); if (m == method) return true; } return false; }
// The cache_entries parameter is empty (on cold call site) or has entries // (on cache miss). Called from assembly with the actual return address. // Compilation of the inline cache may trigger a GC, which may trigger a // compaction; // also, the block containing the return address may now be dead. Use a // code_root to take care of the details. // Allocates memory cell factor_vm::inline_cache_miss(cell return_address_) { code_root return_address(return_address_, this); bool tail_call_site = tail_call_site_p(return_address.value); #ifdef PIC_DEBUG FACTOR_PRINT("Inline cache miss at " << (tail_call_site ? "tail" : "non-tail") << " call site 0x" << std::hex << return_address.value << std::dec); print_callstack(); #endif data_root<array> cache_entries(ctx->pop(), this); fixnum index = untag_fixnum(ctx->pop()); data_root<array> methods(ctx->pop(), this); data_root<word> generic_word(ctx->pop(), this); data_root<object> object(((cell*)ctx->datastack)[-index], this); cell pic_size = array_capacity(cache_entries.untagged()) / 2; update_pic_transitions(pic_size); cell xt = generic_word->entry_point; if (pic_size < max_pic_size) { cell klass = object_class(object.value()); cell method = lookup_method(object.value(), methods.value()); data_root<array> new_cache_entries( add_inline_cache_entry(cache_entries.value(), klass, method), this); inline_cache_jit jit(generic_word.value(), this); jit.emit_inline_cache(index, generic_word.value(), methods.value(), new_cache_entries.value(), tail_call_site); code_block* code = jit.to_code_block(CODE_BLOCK_PIC, JIT_FRAME_SIZE); initialize_code_block(code); xt = code->entry_point(); } // Install the new stub. if (return_address.valid) { // Since each PIC is only referenced from a single call site, // if the old call target was a PIC, we can deallocate it immediately, // instead of leaving dead PICs around until the next GC. deallocate_inline_cache(return_address.value); set_call_target(return_address.value, xt); #ifdef PIC_DEBUG FACTOR_PRINT("Updated " << (tail_call_site ? "tail" : "non-tail") << " call site 0x" << std::hex << return_address.value << std::dec << " with 0x" << std::hex << (cell)xt << std::dec); print_callstack(); #endif } return xt; }
void ImplItem::bind(NameSema& sema) const { sema.push_scope(); bind_ast_type_params(sema); if (trait()) trait()->bind(sema); ast_type()->bind(sema); for (auto&& fn : methods()) fn->bind(sema); sema.lambda_depth_ -= num_ast_type_params(); sema.pop_scope(); }
QList<Model::Node*> Class::findSymbols(const QRegExp& symbolExp,Model::Node* source, FindSymbolMode mode, bool exhaustAllScopes) { QList<Model::Node*> symbols; symbols << methods()->findAllSymbolDefinitions(symbolExp); symbols << fields()->findAllSymbolDefinitions(symbolExp); if (exhaustAllScopes || symbols.isEmpty()) symbols << Node::findSymbols(symbolExp, source, mode, exhaustAllScopes); return symbols; }
void TraitDecl::bind(NameSema& sema) const { sema.push_scope(); bind_ast_type_params(sema); for (auto&& t : super_traits()) t->bind(sema); for (auto&& method : methods()) { method->bind(sema); method_table_[method->symbol()] = method.get(); } sema.lambda_depth_ -= num_ast_type_params(); sema.pop_scope(); }
int main(int argc, char* argv[]) { if (argc < 6) { print_usage(argv[0]); return -1; } std::ofstream out ("ServiceDescription.h", std::ofstream::binary); std::ifstream version(argv[1], std::ios_base::in); std::ifstream license(argv[2], std::ios_base::in); std::ifstream methods(argv[3], std::ios_base::in); std::ifstream types(argv[4], std::ios_base::in); std::ifstream notifications(argv[5], std::ios_base::in); if (!(version && license && methods && types && notifications)) { std::cout << "Failed to find one or more of version.txt, license.txt, methods.json, types.json or notifications.json" << std::endl; return -1; } out << "#pragma once" << std::endl; print_license(license, out); out << std::endl; out << "namespace JSONRPC" << std::endl; out << "{" << std::endl; out << " const char* const JSONRPC_SERVICE_ID = \"http://xbmc.org/jsonrpc/ServiceDescription.json\";" << std::endl; out << " const char* const JSONRPC_SERVICE_VERSION = \""; print_version(version, out); out << "\";" << std::endl; out << " const char* const JSONRPC_SERVICE_DESCRIPTION = \"JSON-RPC API of XBMC\";" << std::endl; out << std::endl; out << " const char* const JSONRPC_SERVICE_TYPES[] = {"; print_json(types, out); out << " };" << std::endl; out << std::endl; out << " const char* const JSONRPC_SERVICE_METHODS[] = {"; print_json(methods, out); out << " };" << std::endl; out << std::endl; out << " const char* const JSONRPC_SERVICE_NOTIFICATIONS[] = {"; print_json(notifications, out); out << " };" << std::endl; out << "}" << std::endl; return 0; }
/* The cache_entries parameter is either f (on cold call site) or an array (on cache miss). Called from assembly with the actual return address */ void *factor_vm::inline_cache_miss(cell return_address) { check_code_pointer(return_address); /* Since each PIC is only referenced from a single call site, if the old call target was a PIC, we can deallocate it immediately, instead of leaving dead PICs around until the next GC. */ deallocate_inline_cache(return_address); gc_root<array> cache_entries(dpop(),this); fixnum index = untag_fixnum(dpop()); gc_root<array> methods(dpop(),this); gc_root<word> generic_word(dpop(),this); gc_root<object> object(((cell *)ds)[-index],this); void *xt; cell pic_size = inline_cache_size(cache_entries.value()); update_pic_transitions(pic_size); if(pic_size >= max_pic_size) xt = megamorphic_call_stub(generic_word.value()); else { cell klass = object_class(object.value()); cell method = lookup_method(object.value(),methods.value()); gc_root<array> new_cache_entries(add_inline_cache_entry( cache_entries.value(), klass, method),this); xt = compile_inline_cache(index, generic_word.value(), methods.value(), new_cache_entries.value(), tail_call_site_p(return_address))->xt(); } /* Install the new stub. */ set_call_target(return_address,xt); #ifdef PIC_DEBUG printf("Updated %s call site 0x%lx with 0x%lx\n", tail_call_site_p(return_address) ? "tail" : "non-tail", return_address, (cell)xt); #endif return xt; }
int main(int argc, char** argv) { int menuNum; printf("1 = IF Statement:PH Level | 2 = Loops:Fibonacci Series| 3 = Array:Temperature| 4 = Methods:Number to Words "); printf("Please enter a number for what you would like to see:"); scanf( "%d", & menuNum); if (menuNum == 1) { ifStatement(); } else if(menuNum == 2){ loops(); } else if(menuNum == 3){ arrays(); } else if(menuNum == 4){ methods(); } void ifStatement(){ //Variables double pH; printf("Acid Rain\n"); printf("Acid Rain is an enviromentmatal problem. This program determines if the pH level in water is safe for fish."); printf(" \nEnter pH level:"); scanf( "%d", & pH); if( pH < 0 | pH > 14 ) { printf( "ERROR"); } else if(pH < 6.5) { printf("TOO ACIDIC - FISH IN STREAMS, RIVERS AND LAKES WILL NOT SURVIVE."); } else if (pH > 7.5) { printf("TOO ALKALINE - FISH IN STREAMS, RIVERS AND LAKES WILL NOT SURVIVE"); } else { printf("NEUTRAL - FISH IN STREAMS, RIVERS AND LAKES WILL SURVIVE."); } }
// Calls GetClassMethods on a given class to force the creation of // jmethodIDs of it. void CreateJMethodIDsForClass(jvmtiEnv *jvmti, jclass klass) { jint method_count; JvmtiScopedPtr<jmethodID> methods(jvmti); jvmtiError e = jvmti->GetClassMethods(klass, &method_count, methods.GetRef()); if (e != JVMTI_ERROR_NONE && e != JVMTI_ERROR_CLASS_NOT_PREPARED) { // JVMTI_ERROR_CLASS_NOT_PREPARED is okay because some classes may // be loaded but not prepared at this point. JvmtiScopedPtr<char> ksig(jvmti); JVMTI_ERROR_CLEANUP( jvmti->GetClassSignature(klass, ksig.GetRef(), NULL), ksig.AbandonBecauseOfError()); logError("Failed to create method IDs for methods in class %s with error %d ", ksig.Get(), e); } }
void NewAccountDialog::onNextButtonClicked() { page_one.errorLabel->setText(QString()); if (slideLayout->top() == page_one.widget) { // Remove current service, if one exists if (newService) { newService->deleteLater(); } // Create new service newService = new Service(this); newService->setUrl(page_one.serviceUrlLineEdit->text()); // If successful, fill out fields elsewhere if (newService->serviceState() == Service::StoppedState) { page_two.serviceDescription->setText(newService->description()); page_three.serviceDescription->setText(newService->description()); } else { page_one.errorLabel->setText("Unable to connect to service."); return; } // Check if we need to choose an authentication method QVariantMap methods(newService->supportedAuthenticationMethods()); if (methods.size() > 0) { if (methods.size() == 1 || true) { page_three.authenticationMethod->setText((--methods.end()).key()); newService->setAuthenticationMethod((--methods.end()).key()); slideLayout->push("3"); } else { // FIXME should make list slideLayout->push("2"); } } else { page_one.errorLabel->setText("Unable to authenticate with service."); return; } } else if (slideLayout->top() == page_two.widget) { } if (slideLayout->top() == page_three.widget) { nextButton->hide(); doneButton->show(); doneButton->setDefault(true); } previousButton->show(); }
code_block *factor_vm::compile_inline_cache(fixnum index,cell generic_word_,cell methods_,cell cache_entries_,bool tail_call_p) { gc_root<word> generic_word(generic_word_,this); gc_root<array> methods(methods_,this); gc_root<array> cache_entries(cache_entries_,this); inline_cache_jit jit(generic_word.value(),this); jit.compile_inline_cache(index, generic_word.value(), methods.value(), cache_entries.value(), tail_call_p); code_block *code = jit.to_code_block(); relocate_code_block(code); return code; }
typename Foam::AMIInterpolation<SourcePatch, TargetPatch>::interpolationMethod Foam::AMIInterpolation<SourcePatch, TargetPatch>::wordTointerpolationMethod ( const word& im ) { interpolationMethod method = imDirect; wordList methods ( IStringStream ( "(" "directAMI " "mapNearestAMI " "faceAreaWeightAMI " "partialFaceAreaWeightAMI" ")" )() ); if (im == "directAMI") { method = imDirect; } else if (im == "mapNearestAMI") { method = imMapNearest; } else if (im == "faceAreaWeightAMI") { method = imFaceAreaWeight; } else if (im == "partialFaceAreaWeightAMI") { method = imPartialFaceAreaWeight; } else { FatalErrorInFunction << "Invalid interpolationMethod " << im << ". Valid methods are:" << methods << exit(FatalError); } return method; }
static RList* sections(RBinArch *arch) { RList *ret = NULL; RBinSection *ptr = NULL; struct r_bin_java_sym_t *s = NULL; RList *ml; RListIter *iter; int ns, fsymsz = 0; int fsym = 0; RBinSymbol *m; ml = methods (arch); r_list_foreach (ml, iter, m) { if (fsym == 0 || m->offset<fsym) fsym = m->offset; ns = m->offset + m->size; if (ns>fsymsz) fsymsz = ns; } if (fsym == 0) return NULL; if (!(ret = r_list_new ())) return NULL; ret->free = free; if ((ptr = R_NEW (RBinSection))) { strcpy (ptr->name, "code"); ptr->size = ptr->vsize = fsymsz; ptr->offset = ptr->rva = fsym; ptr->srwx = 4|1; r_list_append (ret, ptr); } if ((ptr = R_NEW (RBinSection))) { strcpy (ptr->name, "constpool"); ptr->size = ptr->vsize = fsym; ptr->offset = ptr->rva = 0; ptr->srwx = 4; r_list_append (ret, ptr); } if ((ptr = R_NEW (RBinSection))) { strcpy (ptr->name, "data"); ptr->offset = ptr->rva = fsymsz+fsym; ptr->size = ptr->vsize = arch->buf->length - ptr->rva; ptr->srwx = 4|2; r_list_append (ret, ptr); } free (s); return ret; }
void mixinOopDesc::add_method(methodOop method) { objArrayOop old_array = methods(); symbolOop selector = method->selector(); // Find out if a method with the same selector exists. for (int index = 1; index <= old_array->length(); index++) { assert(old_array->obj_at(index)->is_method(), "must be method"); methodOop m = methodOop(old_array->obj_at(index)); if (m->selector() == selector) { objArrayOop new_array = old_array->copy(); new_array->obj_at_put(index, method); set_methods(new_array); return; } } // Extend the array set_methods(old_array->copy_add(method)); }
HttpServerRequestRouter &HttpServerRequestRouter::unmap(Handler *handler) { for (int i = priv->general.size() - 1;i >= 0;--i) { if (priv->general[i].second == handler) priv->general.removeAt(i); } QList<QByteArray> methods(priv->methods.keys()); foreach (const QByteArray &method, methods) { for (int i = priv->methods[method].size() - 1;i >= 0;--i) { if (priv->methods[method][i].second == handler) priv->methods[method].removeAt(i); } } return *this; }
HttpServerRequestRouter &HttpServerRequestRouter::unmap(const QRegExp &path) { for (int i = priv->general.size() - 1;i >= 0;--i) { if (priv->general[i].first == path) priv->general.removeAt(i); } QList<QByteArray> methods(priv->methods.keys()); foreach (const QByteArray &method, methods) { for (int i = priv->methods[method].size() - 1;i >= 0;--i) { if (priv->methods[method][i].first == path) priv->methods[method].removeAt(i); } } return *this; }
void MustOverrideChecker::check(const MatchFinder::MatchResult &Result) { auto D = Result.Nodes.getNodeAs<CXXRecordDecl>("class"); // Look through all of our immediate bases to find methods that need to be // overridden typedef std::vector<CXXMethodDecl *> OverridesVector; OverridesVector MustOverrides; for (const auto &Base : D->bases()) { // The base is either a class (CXXRecordDecl) or it's a templated class... CXXRecordDecl *Parent = Base.getType() .getDesugaredType(D->getASTContext()) ->getAsCXXRecordDecl(); // The parent might not be resolved to a type yet. In this case, we can't // do any checking here. For complete correctness, we should visit // template instantiations, but this case is likely to be rare, so we will // ignore it until it becomes important. if (!Parent) { continue; } Parent = Parent->getDefinition(); for (const auto &M : Parent->methods()) { if (hasCustomAnnotation(M, "moz_must_override")) MustOverrides.push_back(M); } } for (auto &O : MustOverrides) { bool Overridden = false; for (const auto &M : D->methods()) { // The way that Clang checks if a method M overrides its parent method // is if the method has the same name but would not overload. if (getNameChecked(M) == getNameChecked(O) && !CI->getSema().IsOverload(M, O, false)) { Overridden = true; break; } } if (!Overridden) { diag(D->getLocation(), "%0 must override %1", DiagnosticIDs::Error) << D->getDeclName() << O->getDeclName(); diag(O->getLocation(), "function to override is here", DiagnosticIDs::Note); } } }
// index: 0 = top of stack, 1 = item underneath, etc // cache_entries: array of class/method pairs // Allocates memory void inline_cache_jit::emit_inline_cache(fixnum index, cell generic_word_, cell methods_, cell cache_entries_, bool tail_call_p) { data_root<word> generic_word(generic_word_, parent); data_root<array> methods(methods_, parent); data_root<array> cache_entries(cache_entries_, parent); cell ic_type = determine_inline_cache_type(cache_entries.untagged()); parent->update_pic_count(ic_type); // Generate machine code to determine the object's class. emit_with_literal(parent->special_objects[PIC_LOAD], tag_fixnum(-index * sizeof(cell))); // Put the tag of the object, or class of the tuple in a register. emit(parent->special_objects[ic_type]); // Generate machine code to check, in turn, if the class is one of the cached // entries. for (cell i = 0; i < array_capacity(cache_entries.untagged()); i += 2) { cell klass = array_nth(cache_entries.untagged(), i); cell method = array_nth(cache_entries.untagged(), i + 1); emit_check_and_jump(ic_type, i, klass, method); } // If none of the above conditionals tested true, then execution "falls // through" to here. // A stack frame is set up, since the inline-cache-miss sub-primitive // makes a subroutine call to the VM. emit(parent->special_objects[JIT_PROLOG]); // The inline-cache-miss sub-primitive call receives enough information to // reconstruct the PIC with the new entry. push(generic_word.value()); push(methods.value()); push(tag_fixnum(index)); push(cache_entries.value()); emit_subprimitive( parent->special_objects[tail_call_p ? PIC_MISS_TAIL_WORD : PIC_MISS_WORD], true, // tail_call_p true); // stack_frame_p }