1831 ^ nil |
1831 ^ nil |
1832 ! ! |
1832 ! ! |
1833 |
1833 |
1834 !Context methodsFor:'special accessing'! |
1834 !Context methodsFor:'special accessing'! |
1835 |
1835 |
|
1836 argAndVarNames |
|
1837 "helper: given a context, return a collection of arg&var names" |
|
1838 |
|
1839 |homeContext method block numArgs numVars m src |
|
1840 sel isDoIt blocksLineNr extractFromBlock| |
|
1841 |
|
1842 numArgs := self numArgs. |
|
1843 numVars := self numVars. |
|
1844 (numArgs == 0 and:[numVars == 0]) ifTrue:[^ #()]. |
|
1845 |
|
1846 homeContext := self methodHome. |
|
1847 sel := homeContext selector. |
|
1848 method := homeContext method. |
|
1849 |
|
1850 extractFromBlock := |
|
1851 [ |
|
1852 |blockNode argNames varNames vars args| |
|
1853 |
|
1854 blockNode := Compiler |
|
1855 blockAtLine:blocksLineNr |
|
1856 in:m |
|
1857 orSource:src |
|
1858 numArgs:numArgs |
|
1859 numVars:numVars. |
|
1860 |
|
1861 blockNode notNil ifTrue:[ |
|
1862 argNames := #(). |
|
1863 varNames := #(). |
|
1864 |
|
1865 numArgs > 0 ifTrue:[ |
|
1866 vars := blockNode arguments. |
|
1867 vars size > 0 ifTrue:[ |
|
1868 argNames := vars collect:[:var | var name] |
|
1869 ] |
|
1870 ]. |
|
1871 numVars > 0 ifTrue:[ |
|
1872 vars := blockNode variables. |
|
1873 vars size > 0 ifTrue:[ |
|
1874 varNames := vars collect:[:var | var name]. |
|
1875 ] |
|
1876 ]. |
|
1877 ^ argNames , varNames |
|
1878 ]. |
|
1879 ]. |
|
1880 |
|
1881 "/ #doIt needs special handling below |
|
1882 isDoIt := (sel == #'doIt') or:[sel == #'doIt:']. |
|
1883 self isBlockContext ifFalse:[ |
|
1884 isDoIt ifTrue:[ |
|
1885 method notNil ifTrue:[ |
|
1886 "/ special for #doIt |
|
1887 m := nil. |
|
1888 src := ('[' , method source , '\]') withCRs. |
|
1889 blocksLineNr := self lineNumber. |
|
1890 extractFromBlock value. |
|
1891 ] |
|
1892 ]. |
|
1893 |
|
1894 method notNil ifTrue:[ |
|
1895 ^ method methodArgAndVarNames. |
|
1896 ]. |
|
1897 ^ #() |
|
1898 ]. |
|
1899 |
|
1900 method notNil ifTrue:[ |
|
1901 isDoIt ifTrue:[ |
|
1902 "/ special for #doIt |
|
1903 "/ my source is found in the method. |
|
1904 m := nil. |
|
1905 src := ('[' , method source , '\]') withCRs. |
|
1906 ] ifFalse:[ |
|
1907 m := method. |
|
1908 src := nil. |
|
1909 ]. |
|
1910 blocksLineNr := self lineNumber. |
|
1911 extractFromBlock value. |
|
1912 ]. |
|
1913 |
|
1914 blocksLineNr isNil ifTrue:[ |
|
1915 self isBlockContext ifTrue:[ |
|
1916 (self sender notNil |
|
1917 and:[self sender receiver isBlock |
|
1918 and:[self sender selector startsWith:'value']]) |
|
1919 ifTrue:[ |
|
1920 block := self sender receiver. |
|
1921 src := block source. |
|
1922 src isNil ifTrue:[ |
|
1923 self halt. |
|
1924 ]. |
|
1925 blocksLineNr := 1. |
|
1926 extractFromBlock value. |
|
1927 ]. |
|
1928 ]. |
|
1929 ]. |
|
1930 |
|
1931 ^ #() |
|
1932 ! |
|
1933 |
1836 canResume |
1934 canResume |
1837 "return true, if the receiver allows to be resumed. |
1935 "return true, if the receiver allows to be resumed. |
1838 Due to the implementation, this requires that the context which |
1936 Due to the implementation, this requires that the context which |
1839 is right below the receiver is returnable." |
1937 is right below the receiver is returnable." |
1840 |
1938 |