Exemplo n.º 1
0
bool
FreezeScript::AnalyzeInitVisitor::visitStructStart(const StructPtr& v)
{
    if(v->isLocal())
    {
        return false;
    }

    string scoped = v->scoped();
    TypeList l = _oldUnit->lookupTypeNoBuiltin(scoped, false);
    if(!l.empty())
    {
        StructPtr s = StructPtr::dynamicCast(l.front());
        if(!s)
        {
            typeChange(l.front(), scoped, "struct");
        }
        else
        {
            return false;
        }
    }

    _out.newline();
    _out.newline();
    _out << "<!-- struct " << scoped << " -->";
    _out << se("init") << attr("type", scoped);
    _out << ee;

    return false;
}
Exemplo n.º 2
0
void
FreezeScript::AnalyzeInitVisitor::visitEnum(const EnumPtr& v)
{
    if(v->isLocal())
    {
        return;
    }

    string scoped = v->scoped();
    TypeList l = _oldUnit->lookupTypeNoBuiltin(scoped, false);
    if(!l.empty())
    {
        EnumPtr e = EnumPtr::dynamicCast(l.front());
        if(!e)
        {
            typeChange(l.front(), scoped, "enum");
        }
        else
        {
            return;
        }
    }

    _out.newline();
    _out.newline();
    _out << "<!-- enum " << scoped << " -->";
    _out << se("init") << attr("type", scoped);
    _out << ee;
}
Exemplo n.º 3
0
Node<DeclarationNode>::Link DeclarationParser::declaration(bool throwIfEmpty) {
  if (accept(TT::SEMI)) {
    if (throwIfEmpty) throw InternalError("Empty declaration", {METADATA_PAIRS});
    else return nullptr;
  }
  if (accept(TT::DEFINE)) {
    skip();
    // Dynamic variable declaration
    expect(TT::IDENTIFIER, "Unexpected token after define keyword");
    return declarationFromTypes({});
  } else if (accept(TT::IDENTIFIER)) {
    auto ident = current().data;
    skip();
    // Single-type declaration
    if (accept(TT::IDENTIFIER)) {
      return declarationFromTypes({ident});
    }
    // Multi-type declaration
    if (accept(",")) {
      TypeList types = {ident};
      do {
        skip();
        expect(TT::IDENTIFIER, "Expected identifier in type list");
        types.insert(current().data);
        skip();
      } while (accept(","));
      expect(TT::IDENTIFIER);
      return declarationFromTypes(types);
    }
  }
  throw Error("SyntaxError", "Invalid declaration", current().trace);
}
Exemplo n.º 4
0
bool
FreezeScript::AnalyzeInitVisitor::visitClassDefStart(const ClassDefPtr& v)
{
    if(v->isInterface() || v->isLocal())
    {
        return false;
    }

    string scoped = v->scoped();
    TypeList l = _oldUnit->lookupTypeNoBuiltin(scoped, false);
    if(!l.empty())
    {
        ClassDeclPtr decl = ClassDeclPtr::dynamicCast(l.front());
        if(!decl || decl->isInterface())
        {
            typeChange(l.front(), scoped, "class");
        }
        else
        {
            return false;
        }
    }

    _out.newline();
    _out.newline();
    _out << "<!-- class " << scoped << " -->";
    _out << se("init") << attr("type", scoped);
    _out << ee;

    return false;
}
Exemplo n.º 5
0
FbTextElement::TypeList::const_iterator FbTextElement::subtype(const TypeList &list, const QString &style)
{
    for (TypeList::const_iterator item = list.begin(); item != list.end(); item++) {
        if (item->name() == style) return item;
    }
    return list.end();
}
Exemplo n.º 6
0
 /**
  * @brief Return list of types in kernel list
  *
  * This method determines what types of kernels are currently in the internal
  * list and returns them in alphabetical order.  An empty list is returned if
  * there are no kernels.  The list may contain "UNKNOWN" which is the default
  * type assigned when the type of the kernel file cannot be determined.  These
  * kernels are excluded from any loading/unloading.
  *
  * The list of known types are:
  *
  * CK
  * SPK
  * DAF  (synonymous for SPKs as well so load both)
  * PCK
  * EK
  * META
  * IK
  * FK
  * SCLK
  * IAK  (ISIS specific)
  *
  * Kernel types are determined by inspecting the first 8 characters of a
  * kernel file and extracting the contents there.  The actual type is the
  * string value after the last '/' character.  This is typically the value
  * that is also returned by the NAIF kinfo_c utility.
  *
  * @return std::vector<QString> Alphabetical list of kernel types
  */
 QStringList Kernels::getKernelTypes() const {
   TypeList kmap = categorizeByType();
   QStringList types;
   for (int i = 0 ; i < kmap.size() ; i++) {
     types.append(kmap.key(i));
   }
   return (types);
 }
Exemplo n.º 7
0
Address::TypeList Address::typeList()
{
    static TypeList list;

    if(list.isEmpty())
        list << Dom << Intl << Postal << Parcel << Home << Work << Pref;

    return list;
}
Exemplo n.º 8
0
Secrecy::TypeList Secrecy::typeList()
{
  static TypeList list;

  if ( list.isEmpty() )
    list << Public << Private << Confidential;

  return list;
}
Exemplo n.º 9
0
TypeList FunctionParser::getTypeList() {
  TypeList types = {};
  skip(-1); // Counter the comma skip below for the first iteration
  do {
    skip(1); // Skips the comma
    expect(TT::IDENTIFIER, "Expected identifier in type list");
    types.insert(current().data);
    skip();
  } while (accept(","));
  return types;
}
Exemplo n.º 10
0
FbTextElement::Sublist::Sublist(const TypeList &list, const QString &name)
    : m_list(list)
    , m_pos(list.begin())
{
    TypeList::const_iterator empty = list.end();
    while (m_pos != list.end()) {
        if (m_pos->name() == name) break;
        if (m_pos->name().isEmpty()) empty = m_pos;
        m_pos++;
    }
    if (m_pos == list.end()) m_pos = empty;
}
Exemplo n.º 11
0
uint32_t
Module::FindTypes (const SymbolContext& sc,
                   const ConstString &name,
                   bool exact_match,
                   uint32_t max_matches,
                   TypeList& types)
{
    uint32_t num_matches = 0;
    const char *type_name_cstr = name.GetCString();
    std::string type_scope;
    std::string type_basename;
    const bool append = true;
    TypeClass type_class = eTypeClassAny;
    if (Type::GetTypeScopeAndBasename (type_name_cstr, type_scope, type_basename, type_class))
    {
        // Check if "name" starts with "::" which means the qualified type starts
        // from the root namespace and implies and exact match. The typenames we
        // get back from clang do not start with "::" so we need to strip this off
        // in order to get the qualfied names to match

        if (type_scope.size() >= 2 && type_scope[0] == ':' && type_scope[1] == ':')
        {
            type_scope.erase(0,2);
            exact_match = true;
        }
        ConstString type_basename_const_str (type_basename.c_str());
        if (FindTypes_Impl(sc, type_basename_const_str, NULL, append, max_matches, types))
        {
            types.RemoveMismatchedTypes (type_scope, type_basename, type_class, exact_match);
            num_matches = types.GetSize();
        }
    }
    else
    {
        // The type is not in a namespace/class scope, just search for it by basename
        if (type_class != eTypeClassAny)
        {
            // The "type_name_cstr" will have been modified if we have a valid type class
            // prefix (like "struct", "class", "union", "typedef" etc).
            num_matches = FindTypes_Impl(sc, ConstString(type_name_cstr), NULL, append, max_matches, types);
            types.RemoveMismatchedTypes (type_class);
            num_matches = types.GetSize();
        }
        else
        {
            num_matches = FindTypes_Impl(sc, name, NULL, append, max_matches, types);
        }
    }
    
    return num_matches;
    
}
Exemplo n.º 12
0
 /**
  * @brief Categorizes the kernel list by type
  *
  * This method creates essentially a kernel type map with a pointer list to
  * each KernelFile structure of that type.
  *
  * @return Kernels::TypeList Kernel type list map of kernel file pointers
  */
 Kernels::TypeList Kernels::categorizeByType() const {
   TypeList ktypes;
   for (unsigned int i = 0 ; i < _kernels.size() ; i++) {
     KernelFile *kfile = const_cast<KernelFile *> (&_kernels[i]);
     if (ktypes.exists(_kernels[i].ktype)) {
       ktypes.get(_kernels[i].ktype).push_back(kfile);
     }
     else {
       ktypes.add(_kernels[i].ktype, KernelFileList(1, kfile));
     }
   }
   return (ktypes);
 }
Exemplo n.º 13
0
TypeItem*
TResourceSet::FindItemID(type_code type, int32 id)
{
	TypeList* list = FindTypeList(type);
	TypeItem* item = NULL;
	
	if (list) item = list->FindItemByID(id);
	
	if (!item)
		item = LoadResource(type, id, 0, &list);
	
	return item;
}
Exemplo n.º 14
0
bool
FreezeScript::AnalyzeTransformVisitor::visitClassDefStart(const ClassDefPtr& v)
{
    if(v->isInterface() || v->isLocal())
    {
        return false;
    }

    string scoped = v->scoped();
    if(ignoreType(scoped))
    {
        return false;
    }

    TypeList l = _newUnit->lookupTypeNoBuiltin(scoped, false);
    if(l.empty())
    {
        _missingTypes.push_back(scoped);
        return false;
    }

    ClassDeclPtr decl = ClassDeclPtr::dynamicCast(l.front());
    if(!decl || decl->isInterface())
    {
        if(!_ignoreTypeChanges)
        {
            typeChange(scoped, v->declaration(), l.front());
        }
        return false;
    }

    ClassDefPtr newClass = decl->definition();
    if(!newClass)
    {
        _missingTypes.push_back(scoped);
        return false;
    }

    _out.newline();
    _out.newline();
    _out << "<!-- class " << scoped << " -->";
    _out << se("transform") << attr("type", scoped);

    DataMemberList oldMembers = v->dataMembers();
    DataMemberList newMembers = newClass->dataMembers();
    compareMembers(oldMembers, newMembers);

    _out << ee;

    return false;
}
Exemplo n.º 15
0
TypeItem*
TResourceSet::FindItemName(type_code type, const char* name)
{
	TypeList* list = FindTypeList(type);
	TypeItem* item = NULL;

	if (list)
		item = list->FindItemByName(name);

	if (!item)
		item = LoadResource(type, -1, name, &list);

	return item;
}
Exemplo n.º 16
0
TypeList*
TResourceSet::FindTypeList(type_code type)
{
	BAutolock lock(&fLock);

	int32 count = fTypes.CountItems();
	for (int32 i = 0; i < count; i++ ) {
		TypeList* list = (TypeList*)fTypes.ItemAt(i);
		if (list && list->Type() == type)
			return list;
	}

	return NULL;
}
Exemplo n.º 17
0
QString Address::typeLabel() const
{
  QString label;
  bool first = true;

  const TypeList list = typeList();

  TypeList::ConstIterator it;
  for ( it = list.begin(); it != list.end(); ++it ) {
    if ( ( type() & (*it) ) && ( (*it) != Pref ) ) {
      label.append( ( first ? "" : "/" ) + typeLabel( *it ) );
      if ( first )
        first = false;
    }
  }

  return label;
}
Exemplo n.º 18
0
bool
FreezeScript::AnalyzeTransformVisitor::visitStructStart(const StructPtr& v)
{
    if(v->isLocal())
    {
        return false;
    }

    string scoped = v->scoped();
    if(ignoreType(scoped))
    {
        return false;
    }

    TypeList l = _newUnit->lookupTypeNoBuiltin(scoped, false);
    if(l.empty())
    {
        _missingTypes.push_back(scoped);
        return false;
    }

    StructPtr newStruct = StructPtr::dynamicCast(l.front());
    if(!newStruct)
    {
        if(!_ignoreTypeChanges)
        {
            typeChange(scoped, v, l.front());
        }
        return false;
    }

    _out.newline();
    _out.newline();
    _out << "<!-- struct " << scoped << " -->";
    _out << se("transform") << attr("type", scoped);

    DataMemberList oldMembers = v->dataMembers();
    DataMemberList newMembers = newStruct->dataMembers();
    compareMembers(oldMembers, newMembers);

    _out << ee;

    return false;
}
Exemplo n.º 19
0
uint32_t
SymbolVendor::FindTypes (const SymbolContext& sc, const ConstString &name, const ClangNamespaceDecl *namespace_decl, bool append, uint32_t max_matches, TypeList& types)
{
    Mutex::Locker locker(m_mutex);
    if (m_sym_file_ap.get())
        return m_sym_file_ap->FindTypes(sc, name, namespace_decl, append, max_matches, types);
    if (!append)
        types.Clear();
    return 0;
}
Exemplo n.º 20
0
void 
Queue<T,M,C>::popAll(TypeList& dlist) 
{
    mMutex.lock();
    while(mQueue.empty()) {
        mCond.wait();
    } 
    dlist.swap(mQueue);
    mMutex.unlock();
}
Exemplo n.º 21
0
    /**
     * Create a new field declaration with exactly one variable in it.
     * If the field is uninitialized, the initializer may be
     * <code>null</code>.
     *
     * @param  context  Context indicating what line and file this
     *                  field is created at
     * @param  type     Type of the field
     * @param  name     Name of the field
     * @param  init     Expression initializing the field, or
     *                  <code>null</code> if the field is uninitialized
     */
    FieldDecl(FEContext *context, Type *type, string name,
	      Expression *init) : FENode(context)
    {
	types = new TypeList;
	names = new NameList;
	inits = new ExpressionList;

	types->push_back(type);
	names->push_back(name);
	inits->push_back(init);
    }
Exemplo n.º 22
0
void
FreezeScript::AnalyzeTransformVisitor::visitDictionary(const DictionaryPtr& v)
{
    if(v->isLocal())
    {
        return;
    }

    string scoped = v->scoped();
    if(ignoreType(scoped))
    {
        return;
    }

    TypeList l = _newUnit->lookupTypeNoBuiltin(scoped, false);
    if(l.empty())
    {
        _missingTypes.push_back(scoped);
        return;
    }

    DictionaryPtr newDict = DictionaryPtr::dynamicCast(l.front());
    if(!newDict)
    {
        if(!_ignoreTypeChanges)
        {
            typeChange(scoped, v, l.front());
        }
        return;
    }

    _out.newline();
    _out.newline();
    _out << "<!-- dictionary " << scoped << " -->";
    _out << se("transform") << attr("type", scoped);

    compareTypes(scoped + " key type", v->keyType(), newDict->keyType());
    compareTypes(scoped + " value type", v->valueType(), newDict->valueType());

    _out << ee;
}
Exemplo n.º 23
0
void
FreezeScript::AnalyzeTransformVisitor::visitSequence(const SequencePtr& v)
{
    if(v->isLocal())
    {
        return;
    }

    string scoped = v->scoped();
    if(ignoreType(scoped))
    {
        return;
    }

    TypeList l = _newUnit->lookupTypeNoBuiltin(scoped, false);
    if(l.empty())
    {
        _missingTypes.push_back(scoped);
        return;
    }

    SequencePtr newSeq = SequencePtr::dynamicCast(l.front());
    if(!newSeq)
    {
        if(!_ignoreTypeChanges)
        {
            typeChange(scoped, v, l.front());
        }
        return;
    }

    _out.newline();
    _out.newline();
    _out << "<!-- sequence " << scoped << " -->";
    _out << se("transform") << attr("type", scoped);

    compareTypes(scoped + " sequence type", v->type(), newSeq->type());

    _out << ee;
}
Exemplo n.º 24
0
bool
FreezeScript::AnalyzeTransformVisitor::checkClasses(const ClassDeclPtr& from, const ClassDeclPtr& to)
{
    string fromScoped = from->scoped();
    string toScoped = to->scoped();

    if(fromScoped == toScoped)
    {
        return true;
    }

    //
    // The types don't match, so check them for compatibility. Specifically,
    // look up the old type id in the new Slice and see if it has the target
    // type as a base class.
    //
    TypeList l = to->unit()->lookupTypeNoBuiltin(from->scoped(), false);
    if(!l.empty())
    {
        ClassDeclPtr decl = ClassDeclPtr::dynamicCast(l.front());
        if(decl)
        {
            ClassDefPtr def = decl->definition();
            if(def)
            {
                ClassList bases = def->allBases();
                for(ClassList::iterator p = bases.begin(); p != bases.end(); ++p)
                {
                    if((*p)->scoped() == toScoped)
                    {
                        return true;
                    }
                }
            }
        }
    }

    return false;
}
Exemplo n.º 25
0
size_t
SymbolVendor::FindTypes (const SymbolContext& sc, const ConstString &name, const ClangNamespaceDecl *namespace_decl, bool append, size_t max_matches, TypeList& types)
{
    ModuleSP module_sp(GetModule());
    if (module_sp)
    {
        lldb_private::Mutex::Locker locker(module_sp->GetMutex());
        if (m_sym_file_ap.get())
            return m_sym_file_ap->FindTypes(sc, name, namespace_decl, append, max_matches, types);
    }
    if (!append)
        types.Clear();
    return 0;
}
Exemplo n.º 26
0
void ObjectWrapper::writeSchema( StringList& properties, TypeList& types )
{
    SerializerList::iterator sitr = _serializers.begin();
    TypeList::iterator titr = _typeList.begin();
    while(sitr!=_serializers.end() && titr!=_typeList.end())
    {
        if ((*sitr)->supportsReadWrite())
        {
            properties.push_back( (*sitr)->getName() );
            types.push_back( (*titr) );
        }
        ++sitr;
        ++titr;
    }
}
Exemplo n.º 27
0
 bool Find_Impl(ExecutionContextScope *exe_scope, const char *key,
                ResultSet &results) override {
   bool result = false;
   
   Target *target = exe_scope->CalculateTarget().get();
   if (target) {
     const auto &images(target->GetImages());
     SymbolContext null_sc;
     ConstString cs_key(key);
     llvm::DenseSet<SymbolFile*> searched_sym_files;
     TypeList matches;
     images.FindTypes(null_sc,
                      cs_key,
                      false,
                      UINT32_MAX,
                      searched_sym_files,
                      matches);
     for (const auto& match : matches.Types()) {
       if (match.get()) {
         CompilerType compiler_type(match->GetFullCompilerType());
         LanguageType lang_type(compiler_type.GetMinimumLanguage());
         // other plugins will find types for other languages - here we only do C and C++
         if (!Language::LanguageIsC(lang_type) && !Language::LanguageIsCPlusPlus(lang_type))
           continue;
         if (compiler_type.IsTypedefType())
           compiler_type = compiler_type.GetTypedefedType();
         std::unique_ptr<Language::TypeScavenger::Result> scavengeresult(
                                                                 new CPlusPlusTypeScavengerResult(compiler_type));
         results.insert(std::move(scavengeresult));
         result = true;
       }
     }
   }
   
   return result;
 }
Exemplo n.º 28
0
uint32_t
ModuleList::FindTypes_Impl (const SymbolContext& sc, const ConstString &name, bool append, uint32_t max_matches, TypeList& types)
{
    Mutex::Locker locker(m_modules_mutex);
    
    if (!append)
        types.Clear();

    uint32_t total_matches = 0;
    collection::const_iterator pos, end = m_modules.end();
    for (pos = m_modules.begin(); pos != end; ++pos)
    {
        if (sc.module_sp.get() == NULL || sc.module_sp.get() == (*pos).get())
            total_matches += (*pos)->FindTypes (sc, name, NULL, true, max_matches, types);

        if (total_matches >= max_matches)
            break;
    }
    return total_matches;
}
Exemplo n.º 29
0
bool
TypeFormatImpl_EnumType::FormatObject (ValueObject *valobj,
                                       std::string& dest) const
{
    dest.clear();
    if (!valobj)
        return false;
    if (!valobj->CanProvideValue())
        return false;
    ProcessSP process_sp;
    TargetSP target_sp;
    void* valobj_key = (process_sp = valobj->GetProcessSP()).get();
    if (!valobj_key)
        valobj_key = (target_sp = valobj->GetTargetSP()).get();
    else
        target_sp = process_sp->GetTarget().shared_from_this();
    if (!valobj_key)
        return false;
    auto iter = m_types.find(valobj_key),
    end = m_types.end();
    CompilerType valobj_enum_type;
    if (iter == end)
    {
        // probably a redundant check
        if (!target_sp)
            return false;
        const ModuleList& images(target_sp->GetImages());
        SymbolContext sc;
        TypeList types;
        images.FindTypes(sc, m_enum_type, false, UINT32_MAX, types);
        if (types.GetSize() == 0)
            return false;
        for (lldb::TypeSP type_sp : types.Types())
        {
            if (!type_sp)
                continue;
            if ( (type_sp->GetForwardCompilerType().GetTypeInfo() & eTypeIsEnumeration) == eTypeIsEnumeration)
            {
                valobj_enum_type = type_sp->GetFullCompilerType ();
                m_types.emplace(valobj_key,valobj_enum_type);
                break;
            }
        }
    }
    else
        valobj_enum_type = iter->second;
    if (valobj_enum_type.IsValid() == false)
        return false;
    DataExtractor data;
    Error error;
    valobj->GetData(data, error);
    if (error.Fail())
        return false;
    ExecutionContext exe_ctx (valobj->GetExecutionContextRef());
    StreamString sstr;
    valobj_enum_type.DumpTypeValue(&sstr,
                                   lldb::eFormatEnum,
                                   data,
                                   0,
                                   data.GetByteSize(),
                                   0,
                                   0,
                                   exe_ctx.GetBestExecutionContextScope());
    if (!sstr.GetString().empty())
        dest.swap(sstr.GetString());
    return !dest.empty();
}
Exemplo n.º 30
0
TypeItem*
TResourceSet::LoadResource(type_code type, int32 id, const char* name,
	TypeList** inOutList)
{
	TypeItem* item = NULL;

	if (name) {
		BEntry entry;

		// If a named resource, first look in directories.
		fLock.Lock();
		int32 count = fDirectories.CountItems();
		for (int32 i = 0; item == 0 && i < count; i++) {
			BPath* dir = (BPath*)fDirectories.ItemAt(i);
			if (dir) {
				fLock.Unlock();
				BPath path(dir->Path(), name);
				if (entry.SetTo(path.Path(), true) == B_OK ) {
					BFile file(&entry, B_READ_ONLY);
					if (file.InitCheck() == B_OK ) {
						item = new TypeItem(id, name, &file);
						item->SetSourceIsFile(true);
					}
				}
				fLock.Lock();
			}
		}
		fLock.Unlock();
	}

#if USE_RESOURCES
	if (!item) {
		// Look through resource objects for data.
		fLock.Lock();
		int32 count = fResources.CountItems();
		for (int32 i = 0; item == 0 && i < count; i++ ) {
			BResources* resource = (BResources*)fResources.ItemAt(i);
			if (resource) {
				const void* data = NULL;
				size_t size = 0;
				if (id >= 0)
					data = resource->LoadResource(type, id, &size);
				else if (name != NULL)
					data = resource->LoadResource(type, name, &size);

				if (data && size) {
					item = new TypeItem(id, name, data, size);
					item->SetSourceIsFile(false);
				}
			}
		}
		fLock.Unlock();
	}
#endif

	if (item) {
		TypeList* list = inOutList ? *inOutList : NULL;
		if (!list) {
			// Don't currently have a list for this type -- check if there is
			// already one.
			list = FindTypeList(type);
		}

		BAutolock lock(&fLock);

		if (!list) {
			// Need to make a new list for this type.
			list = new TypeList(type);
			fTypes.AddItem(list);
		}
		if (inOutList)
			*inOutList = list;

		list->AddItem(item);
	}

	return item;
}