| 1917 | |
| 1918 | const char *getName() HXCPP_OVERRIDE { return "CallStatic"; } |
| 1919 | CppiaExpr *link(CppiaModule &inModule) HXCPP_OVERRIDE |
| 1920 | { |
| 1921 | |
| 1922 | TypeData *type = inModule.types[classId]; |
| 1923 | String field = inModule.strings[fieldId]; |
| 1924 | |
| 1925 | CppiaExpr *replace = 0; |
| 1926 | if (type->cppiaClass) |
| 1927 | { |
| 1928 | ScriptCallable *func = (ScriptCallable *)type->cppiaClass->findFunction(true,fieldId); |
| 1929 | if (!func) |
| 1930 | { |
| 1931 | CPPIALOG("Could not find static function %s in %s\n", field.out_str(), type->name.out_str()); |
| 1932 | } |
| 1933 | else |
| 1934 | { |
| 1935 | replace = new CallFunExpr( this, 0, func, args, false ); |
| 1936 | } |
| 1937 | } |
| 1938 | |
| 1939 | if (!replace && type->haxeClass.mPtr) |
| 1940 | { |
| 1941 | ScriptNamedFunction func = type->haxeBase->findStaticFunction(field); |
| 1942 | if (func.signature) |
| 1943 | { |
| 1944 | //CPPIALOG(" found function %s\n", func.signature ); |
| 1945 | replace = new CallHaxe( this, func, 0, args, true ); |
| 1946 | } |
| 1947 | else |
| 1948 | { |
| 1949 | //const StaticInfo *info = type->haxeClass->GetStaticStorage(field); |
| 1950 | //CPPIALOG("INFO %s -> %p\n", field.out_str(), info); |
| 1951 | // TODO - create proper glue for static functions |
| 1952 | Dynamic func = type->haxeClass.mPtr->__Field( field, HX_PROP_NEVER ); |
| 1953 | if (func.mPtr) |
| 1954 | { |
| 1955 | replace = new CallDynamicFunction(inModule, this, func, args ); |
| 1956 | } |
| 1957 | } |
| 1958 | } |
| 1959 | |
| 1960 | // TODO - optimise... |
| 1961 | if (!replace && type->name==HX_CSTRING("String") && field==HX_CSTRING("fromCharCode")) |
| 1962 | replace = new CallDynamicFunction(inModule, this, String::fromCharCode_dyn(), args ); |
| 1963 | |
| 1964 | |
| 1965 | //CPPIALOG(" static call to %s::%s (%d)\n", type->name.out_str(), field.out_str(), type->cppiaClass!=0); |
| 1966 | if (replace) |
| 1967 | { |
| 1968 | delete this; |
| 1969 | replace->link(inModule); |
| 1970 | return replace; |
| 1971 | } |
| 1972 | |
| 1973 | CPPIALOG("Unknown static call to %s::%s (%d)\n", type->name.out_str(), field.out_str(), type->cppiaClass!=0); |
| 1974 | inModule.where(this); |
| 1975 | throw "Bad link"; |
| 1976 | return this; |
nothing calls this directly
no test coverage detected