MCPcopy Create free account
hub / github.com/anjo76/angelscript / FindLabel

Method FindLabel

sdk/angelscript/source/as_bytecode.cpp:1827–1877  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1825}
1826
1827int asCByteCode::FindLabel(int label, asCByteInstruction *from, asCByteInstruction **dest, int *positionDelta)
1828{
1829 TimeIt("asCByteCode::FindLabel");
1830
1831 // Search forward
1832 int labelPos = -from->GetSize();
1833
1834 asCByteInstruction *labelInstr = from;
1835 while( labelInstr )
1836 {
1837 labelPos += labelInstr->GetSize();
1838 labelInstr = labelInstr->next;
1839
1840 if( labelInstr && labelInstr->op == asBC_LABEL )
1841 {
1842 if( labelInstr->wArg[0] == label )
1843 break;
1844 }
1845 }
1846
1847 if( labelInstr == 0 )
1848 {
1849 // Search backwards
1850 labelPos = -from->GetSize();
1851
1852 labelInstr = from;
1853 while( labelInstr )
1854 {
1855 labelInstr = labelInstr->prev;
1856 if( labelInstr )
1857 {
1858 labelPos -= labelInstr->GetSize();
1859
1860 if( labelInstr->op == asBC_LABEL )
1861 {
1862 if( labelInstr->wArg[0] == label )
1863 break;
1864 }
1865 }
1866 }
1867 }
1868
1869 if( labelInstr != 0 )
1870 {
1871 if( dest ) *dest = labelInstr;
1872 if( positionDelta ) *positionDelta = labelPos;
1873 return 0;
1874 }
1875
1876 return -1;
1877}
1878
1879int asCByteCode::ResolveJumpAddresses()
1880{

Callers

nothing calls this directly

Calls 1

GetSizeMethod · 0.45

Tested by

no test coverage detected