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

Function CreateExternalInfo

NULLC/Compiler.cpp:1757–1845  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1755}
1756
1757bool CreateExternalInfo(ExternFuncInfo &fInfo, FunctionInfo &refFunc)
1758{
1759 fInfo.bytesToPop = NULLC_PTR_SIZE;
1760 for(VariableInfo *curr = refFunc.firstParam; curr; curr = curr->next)
1761 {
1762 unsigned int paramSize = curr->varType->size > 4 ? curr->varType->size : 4;
1763 fInfo.bytesToPop += paramSize;
1764 }
1765
1766 unsigned int rCount = 0, fCount = 0;
1767 unsigned int rMaxCount = sizeof(fInfo.rOffsets) / sizeof(fInfo.rOffsets[0]);
1768 unsigned int fMaxCount = sizeof(fInfo.fOffsets) / sizeof(fInfo.fOffsets[0]);
1769
1770 // parse all parameters, fill offsets
1771 unsigned int offset = 0;
1772
1773 fInfo.ps3Callable = 1;
1774
1775 for(VariableInfo *curr = refFunc.firstParam; curr; curr = curr->next)
1776 {
1777 TypeInfo& type = *curr->varType;
1778
1779 TypeInfo::TypeCategory oldCategory = type.type;
1780 if(type.type == TypeInfo::TYPE_COMPLEX)
1781 {
1782 if(type.size <= 4)
1783 type.type = TypeInfo::TYPE_INT;
1784 else if(type.size <= 8)
1785 type.type = TypeInfo::TYPE_LONG;
1786 }
1787 if(fCount >= fMaxCount || rCount >= rMaxCount) // too many f/r parameters
1788 {
1789 fInfo.ps3Callable = 0;
1790 break;
1791 }
1792 switch(type.type)
1793 {
1794 case TypeInfo::TYPE_CHAR:
1795 case TypeInfo::TYPE_SHORT:
1796 case TypeInfo::TYPE_INT:
1797 case TypeInfo::TYPE_LONG:
1798 if(type.refLevel)
1799 fInfo.rOffsets[rCount++] = offset | 2u << 30u;
1800 else
1801 fInfo.rOffsets[rCount++] = offset | (type.type == TypeInfo::TYPE_LONG ? 1u : 0u) << 30u;
1802 offset += type.type == TypeInfo::TYPE_LONG ? 2 : 1;
1803 break;
1804
1805 case TypeInfo::TYPE_FLOAT:
1806 case TypeInfo::TYPE_DOUBLE:
1807 fInfo.rOffsets[rCount++] = offset;
1808 fInfo.fOffsets[fCount++] = offset | (type.type == TypeInfo::TYPE_FLOAT ? 1u : 0u) << 31u;
1809 offset += type.type == TypeInfo::TYPE_DOUBLE ? 2 : 1;
1810 break;
1811
1812 default:
1813 if(rCount + type.size / 8 >= rMaxCount)
1814 {

Callers 1

GetBytecodeMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected