std::array<processed_object, 3> mock_processed_object_factory:: make_generalization(unsigned int n, const std::string& st) { std::array<processed_object, 3> r = {{ create_object(object_types::uml_generalization, n), make_class(++n, st), make_class(++n, st), }}; r[0].connection(std::make_pair(r[1].id(), r[2].id())); return r; }
std::array<processed_object, 4> mock_processed_object_factory:: make_first_degree_cycle(unsigned int n) { std::array<processed_object, 4> r = {{ make_class(n), make_class(++n), create_object(object_types::uml_generalization, ++n), create_object(object_types::uml_generalization, ++n) }}; r[2].connection(std::make_pair(r[0].id(), r[1].id())); r[3].connection(std::make_pair(r[1].id(), r[0].id())); return r; }
void imgtool_library_add(imgtool_library *library, imgtool_get_info get_info) { int (*make_class)(int index, imgtool_class *imgclass); imgtool_class imgclass; int i, result; /* try this class */ memset(&imgclass, 0, sizeof(imgclass)); imgclass.get_info = get_info; /* do we have derived getinfo functions? */ make_class = (int (*)(int index, imgtool_class *imgclass)) imgtool_get_info_fct(&imgclass, IMGTOOLINFO_PTR_MAKE_CLASS); if (make_class) { i = 0; do { /* clear out the class */ memset(&imgclass, 0, sizeof(imgclass)); imgclass.get_info = get_info; /* make the class */ result = make_class(i++, &imgclass); if (result) imgtool_library_add_class(library, &imgclass); } while(result); } else { imgtool_library_add_class(library, &imgclass); } }
void library::add(imgtool_get_info get_info) { int (*make_class)(int index, imgtool_class *imgclass); imgtool_class imgclass; int i, result; // try this class memset(&imgclass, 0, sizeof(imgclass)); imgclass.get_info = get_info; // do we have derived getinfo functions? make_class = (int (*)(int index, imgtool_class *imgclass)) imgtool_get_info_fct(&imgclass, IMGTOOLINFO_PTR_MAKE_CLASS); if (make_class) { i = 0; do { // clear out the class memset(&imgclass, 0, sizeof(imgclass)); imgclass.get_info = get_info; // make the class result = make_class(i++, &imgclass); if (result) add_class(&imgclass); } while(result); } else { add_class(&imgclass); } }
std::array<processed_object, 4> mock_processed_object_factory:: make_generalization_inside_large_package( unsigned int n, const std::string& st) { std::array<processed_object, 4> r = {{ make_large_package(n), make_class(++n, st), make_class(++n, st), create_object(object_types::uml_generalization, ++n) }}; r[3].connection(std::make_pair(r[1].id(), r[2].id())); r[1].child_node_id(r[0].id()); r[2].child_node_id(r[0].id()); r[3].child_node_id(r[0].id()); return r; }
ALWAYS_INLINE APCObject::APCObject(ObjectData* obj, uint32_t propCount) : m_handle(KindOfObject) , m_cls{make_class(obj->getVMClass())} , m_propCount{propCount} { m_handle.setObjAttempted(); m_handle.setIsObj(); m_handle.mustCache(); }
std::array<processed_object, 2> mock_processed_object_factory:: make_class_inside_large_package(unsigned int n, const std::string& st) { std::array<processed_object, 2> r = {{ make_large_package(n), make_class(++n, st), }}; r[1].child_node_id(r[0].id()); return r; }
/** Initialize the connection class list. * A connection class named "default" is created, with ping frequency, * connection frequency, maximum links and max SendQ values from the * corresponding configuration features. */ void init_class(void) { if (!connClassList) { connClassList = (struct ConnectionClass*) make_class(); connClassList->next = 0; } /* We had better not try and free this... */ ConClass(connClassList) = "default"; PingFreq(connClassList) = feature_int(FEAT_PINGFREQUENCY); ConFreq(connClassList) = feature_int(FEAT_CONNECTFREQUENCY); MaxLinks(connClassList) = feature_int(FEAT_MAXIMUM_LINKS); MaxSendq(connClassList) = feature_uint(FEAT_DEFAULTMAXSENDQLENGTH); connClassList->valid = 1; Links(connClassList) = 1; }
/** Make sure we have a connection class named \a name. * If one does not exist, create it. Then set its ping frequency, * connection frequency, maximum link count, and max SendQ according * to the parameters. * @param[in] name Connection class name. * @param[in] ping Ping frequency for clients in this class. * @param[in] confreq Connection frequency for clients. * @param[in] maxli Maximum link count for class. * @param[in] sendq Max SendQ for clients. */ void add_class(char *name, unsigned int ping, unsigned int confreq, unsigned int maxli, unsigned int sendq) { struct ConnectionClass* p; Debug((DEBUG_DEBUG, "Add Class %s: cf: %u pf: %u ml: %u sq: %d", name, confreq, ping, maxli, sendq)); assert(name != NULL); p = do_find_class(name, 1); if (!p) p = make_class(); else MyFree(ConClass(p)); ConClass(p) = name; ConFreq(p) = confreq; PingFreq(p) = ping; MaxLinks(p) = maxli; MaxSendq(p) = (sendq > 0U) ? sendq : feature_uint(FEAT_DEFAULTMAXSENDQLENGTH); p->valid = 1; }
APCHandle::Pair APCObject::Construct(ObjectData* objectData) { // This function assumes the object and object/array down the tree have no // internal references and do not implement the serializable interface. assert(!objectData->instanceof(SystemLib::s_SerializableClass)); auto cls = objectData->getVMClass(); auto clsOrName = make_class(cls); if (clsOrName.right()) return ConstructSlow(objectData, clsOrName); // We have a persistent Class. Build an array of APCHandle* to mirror the // declared properties in the object. auto const propInfo = cls->declProperties(); auto const hasDynProps = objectData->hasDynProps(); auto const numRealProps = propInfo.size(); auto const numApcProps = numRealProps + hasDynProps; auto size = sizeof(APCObject) + sizeof(APCHandle*) * numApcProps; auto const apcObj = new (malloc_huge(size)) APCObject(clsOrName, numApcProps); apcObj->m_persistent = 1; // Set a few more flags for faster fetching: whether or not the object has a // wakeup method, and whether or not we can use a fast path that avoids // default-initializing properties before setting them to their APC values. if (!cls->lookupMethod(s___wakeup.get())) apcObj->m_no_wakeup = 1; if (!cls->instanceCtor()) { apcObj->m_fast_init = 1; } auto const apcPropVec = apcObj->persistentProps(); auto const objPropVec = objectData->propVec(); const TypedValueAux* propInit = nullptr; for (unsigned i = 0; i < numRealProps; ++i) { auto const attrs = propInfo[i].attrs; assert((attrs & AttrStatic) == 0); const TypedValue* objProp; if (attrs & AttrBuiltin) { // Special properties like the Memoize cache should be set to their // default value, not the current value. if (propInit == nullptr) { propInit = cls->pinitVec().empty() ? &cls->declPropInit()[0] : &(*cls->getPropData())[0]; } objProp = propInit + i; } else { objProp = objPropVec + i; } auto val = APCHandle::Create(tvAsCVarRef(objProp), false, APCHandleLevel::Inner, true); size += val.size; apcPropVec[i] = val.handle; } if (UNLIKELY(hasDynProps)) { auto val = APCHandle::Create(objectData->dynPropArray(), false, APCHandleLevel::Inner, true); size += val.size; apcPropVec[numRealProps] = val.handle; } return {apcObj->getHandle(), size}; }
tree build_java_array_type (tree element_type, HOST_WIDE_INT length) { tree sig, t, fld, atype, arfld; char buf[23]; tree elsig = build_java_signature (element_type); tree el_name = element_type; buf[0] = '['; if (length >= 0) sprintf (buf+1, HOST_WIDE_INT_PRINT_DEC, length); else buf[1] = '\0'; sig = ident_subst (IDENTIFIER_POINTER (elsig), IDENTIFIER_LENGTH (elsig), buf, 0, 0, ""); t = IDENTIFIER_SIGNATURE_TYPE (sig); if (t != NULL_TREE) return TREE_TYPE (t); t = make_class (); IDENTIFIER_SIGNATURE_TYPE (sig) = build_pointer_type (t); TYPE_ARRAY_P (t) = 1; if (TREE_CODE (el_name) == POINTER_TYPE) el_name = TREE_TYPE (el_name); el_name = TYPE_NAME (el_name); if (TREE_CODE (el_name) == TYPE_DECL) el_name = DECL_NAME (el_name); { char suffix[23]; if (length >= 0) sprintf (suffix, "[%d]", (int)length); else strcpy (suffix, "[]"); TYPE_NAME (t) = TYPE_STUB_DECL (t) = build_decl (input_location, TYPE_DECL, identifier_subst (el_name, "", '.', '.', suffix), t); TYPE_DECL_SUPPRESS_DEBUG (TYPE_STUB_DECL (t)) = true; } set_java_signature (t, sig); set_super_info (0, t, object_type_node, 0); if (TREE_CODE (element_type) == RECORD_TYPE) element_type = promote_type (element_type); TYPE_ARRAY_ELEMENT (t) = element_type; /* Add length pseudo-field. */ fld = build_decl (input_location, FIELD_DECL, get_identifier ("length"), int_type_node); TYPE_FIELDS (t) = fld; DECL_CONTEXT (fld) = t; FIELD_PUBLIC (fld) = 1; FIELD_FINAL (fld) = 1; TREE_READONLY (fld) = 1; atype = build_prim_array_type (element_type, length); arfld = build_decl (input_location, FIELD_DECL, get_identifier ("data"), atype); DECL_CONTEXT (arfld) = t; DECL_CHAIN (fld) = arfld; DECL_ALIGN (arfld) = TYPE_ALIGN (element_type); /* We could layout_class, but that loads java.lang.Object prematurely. * This is called by the parser, and it is a bad idea to do load_class * in the middle of parsing, because of possible circularity problems. */ push_super_field (t, object_type_node); layout_type (t); return t; }
ALWAYS_INLINE APCObject::APCObject(ObjectData* obj, uint32_t propCount) : m_handle(KindOfObject) , m_cls{make_class(obj->getVMClass())} , m_propCount{propCount} {}