MCPcopy Create free account
hub / github.com/WheretIB/nullc / GetBytecode

Method GetBytecode

NULLC/Compiler.cpp:1847–2381  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1845}
1846
1847unsigned int Compiler::GetBytecode(char **bytecode)
1848{
1849 // find out the size of generated bytecode
1850 unsigned int size = sizeof(ByteCode);
1851
1852 size += CodeInfo::typeInfo.size() * sizeof(ExternTypeInfo);
1853
1854 unsigned symbolStorageSize = 0;
1855 unsigned allMemberCount = 0, allConstantCount = 0;
1856 unsigned typedefCount = 0;
1857 for(unsigned int i = 0; i < CodeInfo::typeInfo.size(); i++)
1858 {
1859 TypeInfo *type = CodeInfo::typeInfo[i];
1860 AliasInfo *typeAlias = type->childAlias;
1861 while(typeAlias)
1862 {
1863 typedefCount++;
1864 symbolStorageSize += (unsigned)(typeAlias->name.end - typeAlias->name.begin) + 1;
1865 typeAlias = typeAlias->next;
1866 }
1867
1868 symbolStorageSize += type->GetFullNameLength() + 1;
1869 if((type->type == TypeInfo::TYPE_COMPLEX || type->firstVariable) && type->subType == NULL && type->funcType == NULL)
1870 {
1871 for(TypeInfo::MemberVariable *curr = type->firstVariable; curr; curr = curr->next)
1872 {
1873 symbolStorageSize += (unsigned int)strlen(curr->name) + 1;
1874 if(curr->type->hasPointers)
1875 allMemberCount += 2;
1876 if(curr->defaultValue)
1877 allConstantCount++;
1878 }
1879 }
1880 allMemberCount += type->funcType ? type->funcType->paramCount + 1 : type->memberCount;
1881 }
1882 size += allMemberCount * sizeof(unsigned int);
1883
1884 unsigned int offsetToConstants = size;
1885 size += allConstantCount * (sizeof(unsigned) + sizeof(long long)); // typeID + value
1886
1887 unsigned int functionsInModules = 0;
1888 unsigned int offsetToModule = size;
1889 size += activeModules.size() * sizeof(ExternModuleInfo);
1890 for(unsigned int i = 0; i < activeModules.size(); i++)
1891 {
1892 functionsInModules += activeModules[i].funcCount;
1893 symbolStorageSize += (unsigned int)strlen(activeModules[i].name) + 1;
1894 }
1895
1896 unsigned int offsetToVar = size;
1897 unsigned int globalVarCount = 0, exportVarCount = 0;
1898 size += CodeInfo::varInfo.size() * sizeof(ExternVarInfo);
1899 for(unsigned int i = 0; i < CodeInfo::varInfo.size(); i++)
1900 {
1901 VariableInfo *curr = CodeInfo::varInfo[i];
1902 if(curr->pos >> 24)
1903 continue;
1904 globalVarCount++;

Callers 2

nullcGetBytecodeFunction · 0.45
nullcGetBytecodeNoCacheFunction · 0.45

Calls 12

assertFunction · 0.85
GetGlobalSizeFunction · 0.85
FindFirstTypeFunction · 0.85
FindFirstVarFunction · 0.85
FindFirstFuncFunction · 0.85
CreateExternalInfoFunction · 0.85
FindCodeFunction · 0.85
GetFullNameLengthMethod · 0.80
GetFullTypeNameMethod · 0.80
GetFullNameHashMethod · 0.80
GetStringHashFunction · 0.70
sizeMethod · 0.45

Tested by

no test coverage detected