├── push.sh ├── tests ├── plotting ├── md5_python ├── function_tests ├── md5_pythonize ├── nimcache │ ├── dynlib.o │ ├── hashes.o │ ├── math.o │ ├── system.o │ ├── tables.o │ ├── times.o │ ├── etcpriv.o │ ├── strutils.o │ ├── parseutils.o │ ├── python_python.o │ ├── pythonize_plotting.o │ ├── pythonize_md5_python.o │ ├── pythonize_pythonize.o │ ├── pythonize_md5_pythonize.o │ ├── pythonize_function_tests.o │ ├── etcpriv.c │ ├── tables.c │ ├── dynlib.c │ ├── math.c │ ├── parseutils.c │ ├── hashes.c │ ├── strutils.c │ ├── pythonize_md5_python.c │ ├── pythonize_plotting.c │ └── pythonize_md5_pythonize.c ├── plot_screenshot.png ├── plotting.nim ├── md5_pythonize.nim ├── md5_python.nim └── function_tests.nim ├── nimblemeta.json ├── pythonize.nimble ├── LICENSE.txt ├── README.md └── pythonize.nim /push.sh: -------------------------------------------------------------------------------- 1 | #/bin/bash 2 | git commit -am "$1" 3 | git push -u origin master 4 | 5 | -------------------------------------------------------------------------------- /tests/plotting: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/marcoapintoo/nim-pythonize/HEAD/tests/plotting -------------------------------------------------------------------------------- /tests/md5_python: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/marcoapintoo/nim-pythonize/HEAD/tests/md5_python -------------------------------------------------------------------------------- /tests/function_tests: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/marcoapintoo/nim-pythonize/HEAD/tests/function_tests -------------------------------------------------------------------------------- /tests/md5_pythonize: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/marcoapintoo/nim-pythonize/HEAD/tests/md5_pythonize -------------------------------------------------------------------------------- /tests/nimcache/dynlib.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/marcoapintoo/nim-pythonize/HEAD/tests/nimcache/dynlib.o -------------------------------------------------------------------------------- /tests/nimcache/hashes.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/marcoapintoo/nim-pythonize/HEAD/tests/nimcache/hashes.o -------------------------------------------------------------------------------- /tests/nimcache/math.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/marcoapintoo/nim-pythonize/HEAD/tests/nimcache/math.o -------------------------------------------------------------------------------- /tests/nimcache/system.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/marcoapintoo/nim-pythonize/HEAD/tests/nimcache/system.o -------------------------------------------------------------------------------- /tests/nimcache/tables.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/marcoapintoo/nim-pythonize/HEAD/tests/nimcache/tables.o -------------------------------------------------------------------------------- /tests/nimcache/times.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/marcoapintoo/nim-pythonize/HEAD/tests/nimcache/times.o -------------------------------------------------------------------------------- /tests/nimcache/etcpriv.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/marcoapintoo/nim-pythonize/HEAD/tests/nimcache/etcpriv.o -------------------------------------------------------------------------------- /tests/nimcache/strutils.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/marcoapintoo/nim-pythonize/HEAD/tests/nimcache/strutils.o -------------------------------------------------------------------------------- /tests/plot_screenshot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/marcoapintoo/nim-pythonize/HEAD/tests/plot_screenshot.png -------------------------------------------------------------------------------- /tests/nimcache/parseutils.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/marcoapintoo/nim-pythonize/HEAD/tests/nimcache/parseutils.o -------------------------------------------------------------------------------- /tests/nimcache/python_python.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/marcoapintoo/nim-pythonize/HEAD/tests/nimcache/python_python.o -------------------------------------------------------------------------------- /tests/nimcache/pythonize_plotting.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/marcoapintoo/nim-pythonize/HEAD/tests/nimcache/pythonize_plotting.o -------------------------------------------------------------------------------- /tests/nimcache/pythonize_md5_python.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/marcoapintoo/nim-pythonize/HEAD/tests/nimcache/pythonize_md5_python.o -------------------------------------------------------------------------------- /tests/nimcache/pythonize_pythonize.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/marcoapintoo/nim-pythonize/HEAD/tests/nimcache/pythonize_pythonize.o -------------------------------------------------------------------------------- /tests/nimcache/pythonize_md5_pythonize.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/marcoapintoo/nim-pythonize/HEAD/tests/nimcache/pythonize_md5_pythonize.o -------------------------------------------------------------------------------- /tests/nimcache/pythonize_function_tests.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/marcoapintoo/nim-pythonize/HEAD/tests/nimcache/pythonize_function_tests.o -------------------------------------------------------------------------------- /nimblemeta.json: -------------------------------------------------------------------------------- 1 | {"url": "https://github.com/marcoapintoo/nim-pythonize.git", "files": ["/tests/plot_screenshot.png", "/pythonize.nim", "/README.md", "/nimblemeta.json", "/LICENSE.txt", "/tests/md5_python.nim", "/tests/function_tests.nim", "/tests/plotting.nim"]} -------------------------------------------------------------------------------- /tests/plotting.nim: -------------------------------------------------------------------------------- 1 | import pythonize 2 | 3 | pythonEnvironment["signal"] = @[0, 2290, 4001, 5122, 5686, 5756, 5419, 4773, 3919, 2955, 1966, 1026, 188, 0].pythonify 4 | execPython("import pylab") 5 | execPython("pylab.fill(signal)") 6 | execPython("pylab.show()") 7 | 8 | releasePythonObjects() -------------------------------------------------------------------------------- /pythonize.nimble: -------------------------------------------------------------------------------- 1 | [Package] 2 | name = "pythonize" 3 | version = "1.0.0" 4 | author = "Marco Antonio Pinto" 5 | description = "A higher-level wrapper for the Python Programing Language" 6 | license = "MIT" 7 | 8 | [Deps] 9 | Requires: "nim >= 0.10.0, python >= 1.0" 10 | -------------------------------------------------------------------------------- /tests/md5_pythonize.nim: -------------------------------------------------------------------------------- 1 | # 2 | # Using a md5 coding technique using Python 3 | # 4 | import pythonize 5 | 6 | var text_to_encode = "Hello world!" 7 | pythonEnvironment["text"] = text_to_encode 8 | execPython("import md5") 9 | execPython("encoded_text = md5.md5(text).hexdigest()") 10 | var encoded_text = pythonEnvironment["encoded_text"].depythonify(string) 11 | echo "Text: ", text_to_encode 12 | echo "Encoded Text: ", encoded_text 13 | releasePythonObjects() # To free the memory used by Python -------------------------------------------------------------------------------- /tests/md5_python.nim: -------------------------------------------------------------------------------- 1 | # 2 | # Using a md5 coding technique using Python 3 | # 4 | import python 5 | 6 | Py_Initialize() 7 | var text_to_encode = "Hello world!" 8 | var py_text_to_encode = PyString_FromString(text_to_encode) 9 | var py_environment_module = PyImport_ImportModule("__main__") 10 | var py_environment_vars = PyModule_GetDict(py_environment_module) 11 | discard PyDict_SetItemString(py_environment_vars, "text", py_text_to_encode) 12 | discard PyRun_SimpleString("import md5") 13 | discard PyRun_SimpleString("encoded_text = md5.md5(text).hexdigest()") 14 | var py_encoded_text = PyDict_GetItemString(py_environment_vars, "encoded_text") 15 | var encoded_text = PyString_AsString(py_encoded_text) 16 | echo "Text: ", text_to_encode 17 | echo "Encoded Text: ", encoded_text 18 | Py_XDECREF(py_environment_module) 19 | Py_XDECREF(py_text_to_encode) 20 | Py_XDECREF(py_encoded_text) 21 | Py_Finalize() 22 | 23 | -------------------------------------------------------------------------------- /LICENSE.txt: -------------------------------------------------------------------------------- 1 | Copyright (C) 2015 Marco Antonio Pinto Orellana 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy of 4 | this software and associated documentation files (the "Software"), to deal in 5 | the Software without restriction, including without limitation the rights to 6 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies 7 | of the Software, and to permit persons to whom the Software is furnished to do 8 | so, subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in all 11 | copies or substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 19 | IN THE SOFTWARE. -------------------------------------------------------------------------------- /tests/function_tests.nim: -------------------------------------------------------------------------------- 1 | {.deadCodeElim: on.} 2 | import pythonize 3 | 4 | proc testReadingWritingVars() = 5 | pythonEnvironment["testVar1"] = 12.0 6 | execPython("testVar1 *= 4") 7 | assert pythonEnvironment["testVar1"].asFloat == 48.0 8 | 9 | proc testReadingVars() = 10 | execPython("testVar1 = 25.0") 11 | assert pythonEnvironment["testVar1"].asFloat == 25.0 12 | 13 | proc testReadingWritingArrays() = 14 | pythonEnvironment["array1"] = pythonify(@[1,2,3,4,5,11,7,8,9,10,11]) 15 | var array1 = pythonEnvironment["array1"].asList(int) 16 | execPython("lenArray1 = len(array1)") 17 | execPython("array1[3] = array1[3]**2") 18 | execPython("arrayPos5 = array1[5]") 19 | execPython("arrayPos3 = array1[3]") 20 | execPython("arrayLastPos = array1[-1]") 21 | execPython("import math") 22 | assert pythonEnvironment["lenArray1"].asInt == array1.len 23 | assert pythonEnvironment["arrayPos3"].asInt == array1[3]*array1[3] 24 | assert pythonEnvironment["arrayPos5"].asInt == array1[5] 25 | assert pythonEnvironment["arrayLastPos"].asInt == array1[array1.len-1] 26 | 27 | proc testReadingArrays() = 28 | var innerArray1 = @[1,2,3,4,5,11,7,8,9,10,11] 29 | var array1 = pythonify(innerArray1) 30 | assert array1.len == array1.len 31 | array1[3] = "aaa" 32 | assert array1[5].asInt == innerArray1[5] 33 | assert "bcd" == "bcd" 34 | assert array1[3].asString == "aaa" 35 | 36 | proc testReadingAttributes() = 37 | var innerArray1 = @[1,2,3,4,5,11,7,8,9,10,11] 38 | var array1 = pythonify(innerArray1) 39 | pythonEnvironment["array1"] = array1 40 | execPython("class Foo: myattribute1 = 1234 ") 41 | execPython("Foo.myattribute2 = array1 ") 42 | assert 1234 == pythonEnvironment["Foo"].attrs["myattribute1"].asInt 43 | assert 4 == pythonEnvironment["Foo"].attrs["myattribute2"].asList(int)[3] 44 | 45 | proc testWritingAttributes() = 46 | var innerArray1 = @[1,2,3,4,5,11,7,8,9,10,11] 47 | var array1 = pythonify(innerArray1) 48 | pythonEnvironment["array1"] = array1 49 | execPython("class Foo: myattribute1 = 1234.5 ") 50 | execPython("Foo.myattribute2 = array1 ") 51 | pythonEnvironment["Foo"].attrs.setItem("myattribute3","cdef") 52 | pythonEnvironment["Foo"].attrs["myattribute3"] = "cdef" 53 | assert pythonEnvironment["Foo"].attrs["myattribute1"].asFloat == 1234.5 54 | assert pythonEnvironment["Foo"].attrs["myattribute2"].asPyList[2].asInt == 3 55 | assert pythonEnvironment["Foo"].attrs["myattribute3"].asString == "cdef" 56 | 57 | 58 | if isMainModule: 59 | echo "::testReadingWritingVars" 60 | testReadingWritingVars() 61 | echo "::testReadingVars" 62 | testReadingVars() 63 | echo "::testReadingWritingArrays" 64 | testReadingWritingArrays() 65 | echo "::testReadingArrays" 66 | testReadingArrays() 67 | echo "::testReadingAttributes" 68 | testReadingAttributes() 69 | echo "::testWritingAttributes" 70 | testWritingAttributes() 71 | 72 | releasePythonObjects() #Mandatory to free the memory used by the Python interpreter 73 | -------------------------------------------------------------------------------- /tests/nimcache/etcpriv.c: -------------------------------------------------------------------------------- 1 | /* Generated by Nim Compiler v0.12.0 */ 2 | /* (c) 2015 Andreas Rumpf */ 3 | /* The generated code is subject to the original license. */ 4 | /* Compiled for: Linux, amd64, gcc */ 5 | /* Command for C compiler: 6 | gcc -c -w -g3 -O0 -I/media/marco/Research/Applications/aporia/Nim/lib -o /home/marco/.nimble/pkgs/Pythonize27-1.0.0/tests/nimcache/etcpriv.o /home/marco/.nimble/pkgs/Pythonize27-1.0.0/tests/nimcache/etcpriv.c */ 7 | #define NIM_INTBITS 64 8 | 9 | #include "nimbase.h" 10 | static N_INLINE(NIM_BOOL, ismagicidentseparatorrune_106010)(NCSTRING cs, NI i); 11 | static N_INLINE(NI, addInt)(NI a, NI b); 12 | N_NOINLINE(void, raiseOverflow)(void); 13 | static N_INLINE(void, nimFrame)(TFrame* s); 14 | N_NOINLINE(void, stackoverflow_23601)(void); 15 | static N_INLINE(void, popFrame)(void); 16 | extern TFrame* frameptr_20842; 17 | 18 | static N_INLINE(NI, addInt)(NI a, NI b) { 19 | NI result; 20 | { result = 0; 21 | result = (NI)((NU64)(a) + (NU64)(b)); 22 | { 23 | NIM_BOOL LOC3; 24 | LOC3 = 0; 25 | LOC3 = (((NI) 0) <= (NI)(result ^ a)); 26 | if (LOC3) goto LA4; 27 | LOC3 = (((NI) 0) <= (NI)(result ^ b)); 28 | LA4: ; 29 | if (!LOC3) goto LA5; 30 | goto BeforeRet; 31 | } 32 | LA5: ; 33 | raiseOverflow(); 34 | }BeforeRet: ; 35 | return result; 36 | } 37 | 38 | static N_INLINE(void, nimFrame)(TFrame* s) { 39 | NI LOC1; 40 | LOC1 = 0; 41 | { 42 | if (!(frameptr_20842 == NIM_NIL)) goto LA4; 43 | LOC1 = ((NI) 0); 44 | } 45 | goto LA2; 46 | LA4: ; 47 | { 48 | LOC1 = ((NI) ((NI16)((*frameptr_20842).calldepth + ((NI16) 1)))); 49 | } 50 | LA2: ; 51 | (*s).calldepth = ((NI16) (LOC1)); 52 | (*s).prev = frameptr_20842; 53 | frameptr_20842 = s; 54 | { 55 | if (!((*s).calldepth == ((NI16) 2000))) goto LA9; 56 | stackoverflow_23601(); 57 | } 58 | LA9: ; 59 | } 60 | 61 | static N_INLINE(void, popFrame)(void) { 62 | frameptr_20842 = (*frameptr_20842).prev; 63 | } 64 | 65 | static N_INLINE(NIM_BOOL, ismagicidentseparatorrune_106010)(NCSTRING cs, NI i) { 66 | NIM_BOOL result; 67 | NIM_BOOL LOC1; 68 | NIM_BOOL LOC2; 69 | NI TMP288; 70 | NI TMP289; 71 | nimfr("isMagicIdentSeparatorRune", "etcpriv.nim") 72 | result = 0; 73 | nimln(21, "etcpriv.nim"); 74 | nimln(22, "etcpriv.nim"); 75 | LOC1 = 0; 76 | nimln(21, "etcpriv.nim"); 77 | LOC2 = 0; 78 | LOC2 = ((NU8)(cs[i]) == (NU8)(226)); 79 | if (!(LOC2)) goto LA3; 80 | nimln(22, "etcpriv.nim"); 81 | TMP288 = addInt(i, ((NI) 1)); 82 | LOC2 = ((NU8)(cs[(NI)(TMP288)]) == (NU8)(128)); 83 | LA3: ; 84 | LOC1 = LOC2; 85 | if (!(LOC1)) goto LA4; 86 | nimln(23, "etcpriv.nim"); 87 | TMP289 = addInt(i, ((NI) 2)); 88 | LOC1 = ((NU8)(cs[(NI)(TMP289)]) == (NU8)(147)); 89 | LA4: ; 90 | result = LOC1; 91 | popFrame(); 92 | return result; 93 | } 94 | NIM_EXTERNC N_NOINLINE(void, HEX00_etcprivInit000)(void) { 95 | nimfr("etcpriv", "etcpriv.nim") 96 | popFrame(); 97 | } 98 | 99 | NIM_EXTERNC N_NOINLINE(void, HEX00_etcprivDatInit000)(void) { 100 | } 101 | 102 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Pythonize [![nimble](https://raw.githubusercontent.com/yglukhov/nimble-tag/master/nimble.png)](https://github.com/yglukhov/nimble-tag) 2 | 3 | Pythonize is a high-level wrapper to interface the Nim and Python programming languages. It is focused on making the interaction more easy using the pythonify/depythonify functions. 4 | 5 | Do you want to plot something? 6 | 7 | ```nim 8 | import pythonize 9 | 10 | pythonEnvironment["signal"] = @[0, 2290, 4001, 5122, 5686, 5756, 5419, 11 | 4773, 3919, 2955, 1966, 1026, 188, 0].pythonify 12 | execPython("import pylab") 13 | execPython("pylab.fill(signal)") 14 | execPython("pylab.show()") 15 | 16 | releasePythonObjects() 17 | ``` 18 | 19 | ![Plot screenshot](https://raw.githubusercontent.com/marcoapintoo/nim-pythonize/master/tests/plot_screenshot.png) 20 | 21 | # Another Python API? 22 | 23 | Already there is a wrapper for the Python C-API in the Nimble repository (https://github.com/nim-lang/python), so why another wrapper? 24 | 25 | Nim is a great and fast language, but there is a lack of several libraries to do other tasks. And in the opposite, Python is full with libraries for almost anything (with different quality levels, of course). Thus, the most logical attitude is to make a bridge between both languages using the low-level API for Python. 26 | 27 | For example, to find the md5 code for a sample text using the md5 Python library: 28 | 29 | ```nim 30 | import python 31 | 32 | # Initialize Python 33 | Py_Initialize() 34 | # Define parameters 35 | var text_to_encode = "Hello world!" 36 | # Interface with Python 37 | var py_text_to_encode = PyString_FromString(text_to_encode) 38 | var py_environment_module = PyImport_ImportModule("__main__") 39 | var py_environment_vars = PyModule_GetDict(py_environment_module) 40 | discard PyDict_SetItemString(py_environment_vars, "text", py_text_to_encode) 41 | discard PyRun_SimpleString("import md5") 42 | discard PyRun_SimpleString("encoded_text = md5.md5(text).hexdigest()") 43 | var py_encoded_text = PyDict_GetItemString(py_environment_vars, "encoded_text") 44 | # Recover results and show them 45 | var encoded_text = PyString_AsString(py_encoded_text) 46 | echo "Text: ", text_to_encode 47 | echo "Encoded Text: ", encoded_text 48 | # Freeing memory 49 | Py_XDECREF(py_environment_module) 50 | Py_XDECREF(py_text_to_encode) 51 | Py_XDECREF(py_encoded_text) 52 | Py_Finalize() 53 | ``` 54 | 55 | The code will work successfully, but it seems a... little ugly. 56 | 57 | Pythonize uses several abstractions to reduce the repetitive code 58 | 59 | ```nim 60 | import pythonize # Implicit Python initialization 61 | # Define parameters 62 | var text_to_encode = "Hello world!" 63 | # Interface with Python 64 | pythonEnvironment["text"] = text_to_encode 65 | execPython("import md5") 66 | execPython("encoded_text = md5.md5(text).hexdigest()") 67 | # Recover results and show them 68 | var encoded_text = pythonEnvironment["encoded_text"].depythonify(string) 69 | # Alternatively: var encoded_text = pythonEnvironment["encoded_text"].asString 70 | echo "Text: ", text_to_encode 71 | echo "Encoded Text: ", encoded_text 72 | # Freeing memory 73 | releasePythonObjects() # To free the memory used by Python 74 | ``` 75 | 76 | # More examples 77 | 78 | ## Reading simple variables 79 | 80 | ```nim 81 | proc testReadingVars() = 82 | execPython("testVar1 = 25.0") 83 | assert pythonEnvironment["testVar1"].asFloat == 25.0 84 | ``` 85 | 86 | ## Reading & writing simple values 87 | 88 | ```nim 89 | pythonEnvironment["testVar1"] = 12.0 90 | execPython("testVar1 *= 4") 91 | assert pythonEnvironment["testVar1"].asFloat == 48.0 92 | ``` 93 | 94 | ## Reading sequences 95 | 96 | ```nim 97 | var innerArray1 = @[1,2,3,4,5,11,7,8,9,10,11] 98 | var array1 = pythonify(innerArray1) 99 | assert array1.len == array1.len 100 | array1[3] = "aaa" 101 | assert array1[5].asInt == innerArray1[5] 102 | assert "bcd" == "bcd" 103 | assert array1[3].asString == "aaa" 104 | ``` 105 | 106 | ## Reading & writing sequences 107 | 108 | ```nim 109 | pythonEnvironment["array1"] = pythonify(@[1,2,3,4,5,11,7,8,9,10,11]) 110 | var array1 = pythonEnvironment["array1"].asList(int) 111 | execPython("lenArray1 = len(array1)") 112 | execPython("array1[3] = array1[3]**2") 113 | execPython("arrayPos5 = array1[5]") 114 | execPython("arrayPos3 = array1[3]") 115 | execPython("arrayLastPos = array1[-1]") 116 | execPython("import math") 117 | assert pythonEnvironment["lenArray1"].asInt == array1.len 118 | assert pythonEnvironment["arrayPos3"].asInt == array1[3]*array1[3] 119 | assert pythonEnvironment["arrayPos5"].asInt == array1[5] 120 | assert pythonEnvironment["arrayLastPos"].asInt == array1[array1.len-1] 121 | ``` 122 | 123 | ## Reading attributes 124 | 125 | ```nim 126 | var innerArray1 = @[1,2,3,4,5,11,7,8,9,10,11] 127 | var array1 = pythonify(innerArray1) 128 | pythonEnvironment["array1"] = array1 129 | execPython("class Foo: myattribute1 = 1234 ") 130 | execPython("Foo.myattribute2 = array1 ") 131 | assert 1234 == pythonEnvironment["Foo"].attrs["myattribute1"].asInt 132 | assert 4 == pythonEnvironment["Foo"].attrs["myattribute2"].asList(int)[3] 133 | ``` 134 | 135 | ## Reading & writing object attributes 136 | 137 | ```nim 138 | var innerArray1 = @[1,2,3,4,5,11,7,8,9,10,11] 139 | var array1 = pythonify(innerArray1) 140 | pythonEnvironment["array1"] = array1 141 | execPython("class Foo: myattribute1 = 1234.5 ") 142 | execPython("Foo.myattribute2 = array1 ") 143 | pythonEnvironment["Foo"].attrs["myattribute3"] = "cdef" 144 | assert pythonEnvironment["Foo"].attrs["myattribute1"].asFloat == 1234.5 145 | assert pythonEnvironment["Foo"].attrs["myattribute2"].asPyList[2].asInt == 3 146 | assert pythonEnvironment["Foo"].attrs["myattribute3"].asString == "cdef" 147 | ``` 148 | 149 | # License 150 | 151 | The source code is delivered under a MIT License. 152 | 153 | 154 | # Current status 155 | 156 | The project is under development according to my current needs and it is possible it will change during the process. 157 | 158 | 159 | 160 | 161 | 162 | 163 | -------------------------------------------------------------------------------- /tests/nimcache/tables.c: -------------------------------------------------------------------------------- 1 | /* Generated by Nim Compiler v0.12.0 */ 2 | /* (c) 2015 Andreas Rumpf */ 3 | /* The generated code is subject to the original license. */ 4 | /* Compiled for: Linux, amd64, gcc */ 5 | /* Command for C compiler: 6 | gcc -c -w -g3 -O0 -I/media/marco/Research/Applications/aporia/Nim/lib -o /home/marco/.nimble/pkgs/Pythonize27-1.0.0/tests/nimcache/tables.o /home/marco/.nimble/pkgs/Pythonize27-1.0.0/tests/nimcache/tables.c */ 7 | #define NIM_INTBITS 64 8 | 9 | #include "nimbase.h" 10 | typedef struct NimStringDesc NimStringDesc; 11 | typedef struct TGenericSeq TGenericSeq; 12 | struct TGenericSeq { 13 | NI len; 14 | NI reserved; 15 | }; 16 | struct NimStringDesc { 17 | TGenericSeq Sup; 18 | NIM_CHAR data[SEQ_DECL_SIZE]; 19 | }; 20 | static N_INLINE(NIM_BOOL, isempty_120274)(NI hcode); 21 | static N_INLINE(void, nimFrame)(TFrame* s); 22 | N_NOINLINE(void, stackoverflow_23601)(void); 23 | static N_INLINE(void, popFrame)(void); 24 | static N_INLINE(NIM_BOOL, isfilled_120281)(NI hcode); 25 | static N_INLINE(NIM_BOOL, mustrehash_120289)(NI length, NI counter); 26 | N_NIMCALL(void, failedassertimpl_91603)(NimStringDesc* msg); 27 | N_NIMCALL(NI, mulInt)(NI a, NI b); 28 | static N_INLINE(NI, subInt)(NI a, NI b); 29 | N_NOINLINE(void, raiseOverflow)(void); 30 | static N_INLINE(NI, nexttry_120404)(NI h, NI maxhash); 31 | static N_INLINE(NI, addInt)(NI a, NI b); 32 | static N_INLINE(NI, rightsize_120541)(NI count); 33 | N_NIMCALL(NI, nextpoweroftwo_116248)(NI x); 34 | static N_INLINE(NI, divInt)(NI a, NI b); 35 | N_NOINLINE(void, raiseDivByZero)(void); 36 | STRING_LITERAL(TMP453, "\012 counter < length ", 20); 37 | extern TFrame* frameptr_20842; 38 | 39 | static N_INLINE(void, nimFrame)(TFrame* s) { 40 | NI LOC1; 41 | LOC1 = 0; 42 | { 43 | if (!(frameptr_20842 == NIM_NIL)) goto LA4; 44 | LOC1 = ((NI) 0); 45 | } 46 | goto LA2; 47 | LA4: ; 48 | { 49 | LOC1 = ((NI) ((NI16)((*frameptr_20842).calldepth + ((NI16) 1)))); 50 | } 51 | LA2: ; 52 | (*s).calldepth = ((NI16) (LOC1)); 53 | (*s).prev = frameptr_20842; 54 | frameptr_20842 = s; 55 | { 56 | if (!((*s).calldepth == ((NI16) 2000))) goto LA9; 57 | stackoverflow_23601(); 58 | } 59 | LA9: ; 60 | } 61 | 62 | static N_INLINE(void, popFrame)(void) { 63 | frameptr_20842 = (*frameptr_20842).prev; 64 | } 65 | 66 | static N_INLINE(NIM_BOOL, isempty_120274)(NI hcode) { 67 | NIM_BOOL result; 68 | nimfr("isEmpty", "tableimpl.nim") 69 | result = 0; 70 | nimln(15, "tableimpl.nim"); 71 | result = (hcode == ((NI) 0)); 72 | popFrame(); 73 | return result; 74 | } 75 | 76 | static N_INLINE(NIM_BOOL, isfilled_120281)(NI hcode) { 77 | NIM_BOOL result; 78 | nimfr("isFilled", "tableimpl.nim") 79 | result = 0; 80 | nimln(18, "tableimpl.nim"); 81 | nimln(349, "system.nim"); 82 | result = !((hcode == ((NI) 0))); 83 | popFrame(); 84 | return result; 85 | } 86 | 87 | static N_INLINE(NI, subInt)(NI a, NI b) { 88 | NI result; 89 | { result = 0; 90 | result = (NI)((NU64)(a) - (NU64)(b)); 91 | { 92 | NIM_BOOL LOC3; 93 | LOC3 = 0; 94 | LOC3 = (((NI) 0) <= (NI)(result ^ a)); 95 | if (LOC3) goto LA4; 96 | LOC3 = (((NI) 0) <= (NI)(result ^ (NI)((NU64) ~(b)))); 97 | LA4: ; 98 | if (!LOC3) goto LA5; 99 | goto BeforeRet; 100 | } 101 | LA5: ; 102 | raiseOverflow(); 103 | }BeforeRet: ; 104 | return result; 105 | } 106 | 107 | static N_INLINE(NIM_BOOL, mustrehash_120289)(NI length, NI counter) { 108 | NIM_BOOL result; 109 | NIM_BOOL LOC5; 110 | NI TMP454; 111 | NI TMP455; 112 | NI TMP456; 113 | nimfr("mustRehash", "tableimpl.nim") 114 | result = 0; 115 | nimln(24, "tableimpl.nim"); 116 | { 117 | if (!!((counter < length))) goto LA3; 118 | failedassertimpl_91603(((NimStringDesc*) &TMP453)); 119 | } 120 | LA3: ; 121 | nimln(25, "tableimpl.nim"); 122 | LOC5 = 0; 123 | TMP454 = mulInt(length, ((NI) 2)); 124 | TMP455 = mulInt(counter, ((NI) 3)); 125 | LOC5 = ((NI)(TMP454) < (NI)(TMP455)); 126 | if (LOC5) goto LA6; 127 | TMP456 = subInt(length, counter); 128 | LOC5 = ((NI)(TMP456) < ((NI) 4)); 129 | LA6: ; 130 | result = LOC5; 131 | popFrame(); 132 | return result; 133 | } 134 | 135 | static N_INLINE(NI, addInt)(NI a, NI b) { 136 | NI result; 137 | { result = 0; 138 | result = (NI)((NU64)(a) + (NU64)(b)); 139 | { 140 | NIM_BOOL LOC3; 141 | LOC3 = 0; 142 | LOC3 = (((NI) 0) <= (NI)(result ^ a)); 143 | if (LOC3) goto LA4; 144 | LOC3 = (((NI) 0) <= (NI)(result ^ b)); 145 | LA4: ; 146 | if (!LOC3) goto LA5; 147 | goto BeforeRet; 148 | } 149 | LA5: ; 150 | raiseOverflow(); 151 | }BeforeRet: ; 152 | return result; 153 | } 154 | 155 | static N_INLINE(NI, nexttry_120404)(NI h, NI maxhash) { 156 | NI result; 157 | NI TMP457; 158 | nimfr("nextTry", "tableimpl.nim") 159 | result = 0; 160 | nimln(28, "tableimpl.nim"); 161 | TMP457 = addInt(h, ((NI) 1)); 162 | result = (NI)((NI)(TMP457) & maxhash); 163 | popFrame(); 164 | return result; 165 | } 166 | 167 | static N_INLINE(NI, divInt)(NI a, NI b) { 168 | NI result; 169 | { result = 0; 170 | { 171 | if (!(b == ((NI) 0))) goto LA3; 172 | raiseDivByZero(); 173 | } 174 | LA3: ; 175 | { 176 | NIM_BOOL LOC7; 177 | LOC7 = 0; 178 | LOC7 = (a == ((NI) (IL64(-9223372036854775807) - IL64(1)))); 179 | if (!(LOC7)) goto LA8; 180 | LOC7 = (b == ((NI) -1)); 181 | LA8: ; 182 | if (!LOC7) goto LA9; 183 | raiseOverflow(); 184 | } 185 | LA9: ; 186 | result = (NI)(a / b); 187 | goto BeforeRet; 188 | }BeforeRet: ; 189 | return result; 190 | } 191 | 192 | static N_INLINE(NI, rightsize_120541)(NI count) { 193 | NI result; 194 | NI TMP458; 195 | NI TMP459; 196 | NI TMP460; 197 | nimfr("rightSize", "tables.nim") 198 | result = 0; 199 | nimln(95, "tables.nim"); 200 | TMP458 = mulInt(((NI) (count)), ((NI) 3)); 201 | TMP459 = divInt(((NI) ((NI)(TMP458))), ((NI) 2)); 202 | TMP460 = addInt(((NI) ((NI)(TMP459))), ((NI) 4)); 203 | result = nextpoweroftwo_116248(((NI) ((NI)(TMP460)))); 204 | popFrame(); 205 | return result; 206 | } 207 | NIM_EXTERNC N_NOINLINE(void, HEX00_tablesInit000)(void) { 208 | nimfr("tables", "tables.nim") 209 | popFrame(); 210 | } 211 | 212 | NIM_EXTERNC N_NOINLINE(void, HEX00_tablesDatInit000)(void) { 213 | } 214 | 215 | -------------------------------------------------------------------------------- /tests/nimcache/dynlib.c: -------------------------------------------------------------------------------- 1 | /* Generated by Nim Compiler v0.12.0 */ 2 | /* (c) 2015 Andreas Rumpf */ 3 | /* The generated code is subject to the original license. */ 4 | /* Compiled for: Linux, amd64, gcc */ 5 | /* Command for C compiler: 6 | gcc -c -w -g3 -O0 -I/media/marco/Research/Applications/aporia/Nim/lib -o /home/marco/.nimble/pkgs/Pythonize27-1.0.0/tests/nimcache/dynlib.o /home/marco/.nimble/pkgs/Pythonize27-1.0.0/tests/nimcache/dynlib.c */ 7 | #define NIM_INTBITS 64 8 | 9 | #include "nimbase.h" 10 | #include 11 | #include 12 | typedef struct Libraryerror4035 Libraryerror4035; 13 | typedef struct Oserror4033 Oserror4033; 14 | typedef struct Systemerror4029 Systemerror4029; 15 | typedef struct Exception Exception; 16 | typedef struct TNimObject TNimObject; 17 | typedef struct TNimType TNimType; 18 | typedef struct TNimNode TNimNode; 19 | typedef struct NimStringDesc NimStringDesc; 20 | typedef struct TGenericSeq TGenericSeq; 21 | typedef struct Cell49347 Cell49347; 22 | typedef struct Cellseq49363 Cellseq49363; 23 | typedef struct Gcheap51418 Gcheap51418; 24 | typedef struct Gcstack51416 Gcstack51416; 25 | typedef struct Cellset49359 Cellset49359; 26 | typedef struct Pagedesc49355 Pagedesc49355; 27 | typedef struct Memregion31291 Memregion31291; 28 | typedef struct Smallchunk31243 Smallchunk31243; 29 | typedef struct Llchunk31285 Llchunk31285; 30 | typedef struct Bigchunk31245 Bigchunk31245; 31 | typedef struct Intset31217 Intset31217; 32 | typedef struct Trunk31213 Trunk31213; 33 | typedef struct Avlnode31289 Avlnode31289; 34 | typedef struct Gcstat51414 Gcstat51414; 35 | typedef struct Basechunk31241 Basechunk31241; 36 | typedef struct Freecell31233 Freecell31233; 37 | typedef N_NIMCALL_PTR(void, TY3889) (void* p, NI op); 38 | typedef N_NIMCALL_PTR(void*, TY3894) (void* p); 39 | struct TNimType { 40 | NI size; 41 | NU8 kind; 42 | NU8 flags; 43 | TNimType* base; 44 | TNimNode* node; 45 | void* finalizer; 46 | TY3889 marker; 47 | TY3894 deepcopy; 48 | }; 49 | struct TNimObject { 50 | TNimType* m_type; 51 | }; 52 | struct TGenericSeq { 53 | NI len; 54 | NI reserved; 55 | }; 56 | struct NimStringDesc { 57 | TGenericSeq Sup; 58 | NIM_CHAR data[SEQ_DECL_SIZE]; 59 | }; 60 | struct Exception { 61 | TNimObject Sup; 62 | Exception* parent; 63 | NCSTRING name; 64 | NimStringDesc* message; 65 | NimStringDesc* trace; 66 | }; 67 | struct Systemerror4029 { 68 | Exception Sup; 69 | }; 70 | struct Oserror4033 { 71 | Systemerror4029 Sup; 72 | NI32 errorcode; 73 | }; 74 | struct Libraryerror4035 { 75 | Oserror4033 Sup; 76 | }; 77 | struct TNimNode { 78 | NU8 kind; 79 | NI offset; 80 | TNimType* typ; 81 | NCSTRING name; 82 | NI len; 83 | TNimNode** sons; 84 | }; 85 | struct Cell49347 { 86 | NI refcount; 87 | TNimType* typ; 88 | }; 89 | struct Cellseq49363 { 90 | NI len; 91 | NI cap; 92 | Cell49347** d; 93 | }; 94 | struct Cellset49359 { 95 | NI counter; 96 | NI max; 97 | Pagedesc49355* head; 98 | Pagedesc49355** data; 99 | }; 100 | typedef Smallchunk31243* TY31306[512]; 101 | typedef Trunk31213* Trunkbuckets31215[256]; 102 | struct Intset31217 { 103 | Trunkbuckets31215 data; 104 | }; 105 | struct Memregion31291 { 106 | NI minlargeobj; 107 | NI maxlargeobj; 108 | TY31306 freesmallchunks; 109 | Llchunk31285* llmem; 110 | NI currmem; 111 | NI maxmem; 112 | NI freemem; 113 | NI lastsize; 114 | Bigchunk31245* freechunkslist; 115 | Intset31217 chunkstarts; 116 | Avlnode31289* root; 117 | Avlnode31289* deleted; 118 | Avlnode31289* last; 119 | Avlnode31289* freeavlnodes; 120 | }; 121 | struct Gcstat51414 { 122 | NI stackscans; 123 | NI cyclecollections; 124 | NI maxthreshold; 125 | NI maxstacksize; 126 | NI maxstackcells; 127 | NI cycletablesize; 128 | NI64 maxpause; 129 | }; 130 | struct Gcheap51418 { 131 | Gcstack51416* stack; 132 | void* stackbottom; 133 | NI cyclethreshold; 134 | Cellseq49363 zct; 135 | Cellseq49363 decstack; 136 | Cellset49359 cycleroots; 137 | Cellseq49363 tempstack; 138 | NI recgclock; 139 | Memregion31291 region; 140 | Gcstat51414 stat; 141 | }; 142 | struct Gcstack51416 { 143 | Gcstack51416* prev; 144 | Gcstack51416* next; 145 | void* starts; 146 | void* pos; 147 | NI maxstacksize; 148 | }; 149 | typedef NI TY31222[8]; 150 | struct Pagedesc49355 { 151 | Pagedesc49355* next; 152 | NI key; 153 | TY31222 bits; 154 | }; 155 | struct Basechunk31241 { 156 | NI prevsize; 157 | NI size; 158 | NIM_BOOL used; 159 | }; 160 | struct Smallchunk31243 { 161 | Basechunk31241 Sup; 162 | Smallchunk31243* next; 163 | Smallchunk31243* prev; 164 | Freecell31233* freelist; 165 | NI free; 166 | NI acc; 167 | NF data; 168 | }; 169 | struct Llchunk31285 { 170 | NI size; 171 | NI acc; 172 | Llchunk31285* next; 173 | }; 174 | struct Bigchunk31245 { 175 | Basechunk31241 Sup; 176 | Bigchunk31245* next; 177 | Bigchunk31245* prev; 178 | NI align; 179 | NF data; 180 | }; 181 | struct Trunk31213 { 182 | Trunk31213* next; 183 | NI key; 184 | TY31222 bits; 185 | }; 186 | typedef Avlnode31289* TY31296[2]; 187 | struct Avlnode31289 { 188 | TY31296 link; 189 | NI key; 190 | NI upperbound; 191 | NI level; 192 | }; 193 | struct Freecell31233 { 194 | Freecell31233* next; 195 | NI zerofield; 196 | }; 197 | N_NOINLINE(void, raiseinvalidlibrary_124041)(NCSTRING name) __attribute__((noreturn)); 198 | N_NIMCALL(void*, newObj)(TNimType* typ, NI size); 199 | static N_INLINE(void, appendString)(NimStringDesc* dest, NimStringDesc* src); 200 | N_NIMCALL(NimStringDesc*, cstrToNimstr)(NCSTRING str); 201 | N_NIMCALL(NimStringDesc*, rawNewString)(NI space); 202 | static N_INLINE(void, asgnRefNoCycle)(void** dest, void* src); 203 | static N_INLINE(Cell49347*, usrtocell_53046)(void* usr); 204 | static N_INLINE(void, nimFrame)(TFrame* s); 205 | N_NOINLINE(void, stackoverflow_23601)(void); 206 | static N_INLINE(void, popFrame)(void); 207 | static N_INLINE(void, rtladdzct_54604)(Cell49347* c); 208 | N_NOINLINE(void, addzct_53017)(Cellseq49363* s, Cell49347* c); 209 | N_NIMCALL(void, raiseException)(Exception* e, NCSTRING ename); 210 | N_NIMCALL(void*, checkedsymaddr_124068)(void* lib, NCSTRING name); 211 | N_NIMCALL(void*, loadlib_124023)(NimStringDesc* path, NIM_BOOL globalsymbols); 212 | N_NIMCALL(void*, loadlib_124030)(void); 213 | N_NIMCALL(void, unloadlib_124035)(void* lib); 214 | N_NIMCALL(void*, symaddr_124061)(void* lib, NCSTRING name); 215 | STRING_LITERAL(TMP466, "could not find symbol: ", 23); 216 | extern TNimType NTI124044; /* ref LibraryError */ 217 | extern TNimType NTI4035; /* LibraryError */ 218 | extern TFrame* frameptr_20842; 219 | extern Gcheap51418 gch_51459; 220 | 221 | static N_INLINE(void, appendString)(NimStringDesc* dest, NimStringDesc* src) { 222 | memcpy(((NCSTRING) ((&(*dest).data[((*dest).Sup.len)- 0]))), ((NCSTRING) ((*src).data)), (NI)((*src).Sup.len + ((NI) 1))); 223 | (*dest).Sup.len += (*src).Sup.len; 224 | } 225 | 226 | static N_INLINE(void, nimFrame)(TFrame* s) { 227 | NI LOC1; 228 | LOC1 = 0; 229 | { 230 | if (!(frameptr_20842 == NIM_NIL)) goto LA4; 231 | LOC1 = ((NI) 0); 232 | } 233 | goto LA2; 234 | LA4: ; 235 | { 236 | LOC1 = ((NI) ((NI16)((*frameptr_20842).calldepth + ((NI16) 1)))); 237 | } 238 | LA2: ; 239 | (*s).calldepth = ((NI16) (LOC1)); 240 | (*s).prev = frameptr_20842; 241 | frameptr_20842 = s; 242 | { 243 | if (!((*s).calldepth == ((NI16) 2000))) goto LA9; 244 | stackoverflow_23601(); 245 | } 246 | LA9: ; 247 | } 248 | 249 | static N_INLINE(void, popFrame)(void) { 250 | frameptr_20842 = (*frameptr_20842).prev; 251 | } 252 | 253 | static N_INLINE(Cell49347*, usrtocell_53046)(void* usr) { 254 | Cell49347* result; 255 | nimfr("usrToCell", "gc.nim") 256 | result = 0; 257 | nimln(131, "gc.nim"); 258 | result = ((Cell49347*) ((NI)((NU64)(((NI) (usr))) - (NU64)(((NI)sizeof(Cell49347)))))); 259 | popFrame(); 260 | return result; 261 | } 262 | 263 | static N_INLINE(void, rtladdzct_54604)(Cell49347* c) { 264 | nimfr("rtlAddZCT", "gc.nim") 265 | nimln(212, "gc.nim"); 266 | addzct_53017((&gch_51459.zct), c); 267 | popFrame(); 268 | } 269 | 270 | static N_INLINE(void, asgnRefNoCycle)(void** dest, void* src) { 271 | nimfr("asgnRefNoCycle", "gc.nim") 272 | nimln(264, "gc.nim"); 273 | { 274 | Cell49347* c; 275 | nimln(349, "system.nim"); 276 | if (!!((src == NIM_NIL))) goto LA3; 277 | nimln(265, "gc.nim"); 278 | c = usrtocell_53046(src); 279 | nimln(182, "gc.nim"); 280 | (*c).refcount += ((NI) 8); 281 | } 282 | LA3: ; 283 | nimln(267, "gc.nim"); 284 | { 285 | Cell49347* c; 286 | nimln(349, "system.nim"); 287 | if (!!(((*dest) == NIM_NIL))) goto LA7; 288 | nimln(268, "gc.nim"); 289 | c = usrtocell_53046((*dest)); 290 | nimln(269, "gc.nim"); 291 | { 292 | nimln(180, "gc.nim"); 293 | (*c).refcount -= ((NI) 8); 294 | nimln(181, "gc.nim"); 295 | if (!((NU64)((*c).refcount) < (NU64)(((NI) 8)))) goto LA11; 296 | nimln(270, "gc.nim"); 297 | rtladdzct_54604(c); 298 | } 299 | LA11: ; 300 | } 301 | LA7: ; 302 | nimln(271, "gc.nim"); 303 | (*dest) = src; 304 | popFrame(); 305 | } 306 | 307 | N_NOINLINE(void, raiseinvalidlibrary_124041)(NCSTRING name) { 308 | Libraryerror4035* e; 309 | NimStringDesc* LOC1; 310 | NimStringDesc* LOC2; 311 | nimfr("raiseInvalidLibrary", "dynlib.nim") 312 | e = 0; 313 | nimln(33, "dynlib.nim"); 314 | e = (Libraryerror4035*) newObj((&NTI124044), sizeof(Libraryerror4035)); 315 | (*e).Sup.Sup.Sup.Sup.m_type = (&NTI4035); 316 | nimln(34, "dynlib.nim"); 317 | LOC1 = 0; 318 | LOC2 = 0; 319 | LOC2 = cstrToNimstr(name); 320 | LOC1 = rawNewString(LOC2->Sup.len + 23); 321 | appendString(LOC1, ((NimStringDesc*) &TMP466)); 322 | appendString(LOC1, LOC2); 323 | asgnRefNoCycle((void**) (&(*e).Sup.Sup.Sup.message), LOC1); 324 | nimln(35, "dynlib.nim"); 325 | raiseException((Exception*)e, "LibraryError"); 326 | popFrame(); 327 | } 328 | 329 | N_NIMCALL(void*, checkedsymaddr_124068)(void* lib, NCSTRING name) { 330 | void* result; 331 | nimfr("checkedSymAddr", "dynlib.nim") 332 | result = 0; 333 | nimln(44, "dynlib.nim"); 334 | result = symaddr_124061(lib, name); 335 | nimln(45, "dynlib.nim"); 336 | { 337 | if (!(result == NIM_NIL)) goto LA3; 338 | raiseinvalidlibrary_124041(name); 339 | } 340 | LA3: ; 341 | popFrame(); 342 | return result; 343 | } 344 | 345 | N_NIMCALL(void*, loadlib_124023)(NimStringDesc* path, NIM_BOOL globalsymbols) { 346 | void* result; 347 | NI flags; 348 | nimfr("loadLib", "dynlib.nim") 349 | { result = 0; 350 | nimln(67, "dynlib.nim"); 351 | flags = RTLD_NOW; 352 | nimln(68, "dynlib.nim"); 353 | { 354 | if (!globalsymbols) goto LA3; 355 | flags = (NI)(flags | RTLD_GLOBAL); 356 | } 357 | LA3: ; 358 | nimln(69, "dynlib.nim"); 359 | result = dlopen(path->data, flags); 360 | goto BeforeRet; 361 | }BeforeRet: ; 362 | popFrame(); 363 | return result; 364 | } 365 | 366 | N_NIMCALL(void*, loadlib_124030)(void) { 367 | void* result; 368 | nimfr("loadLib", "dynlib.nim") 369 | { result = 0; 370 | nimln(70, "dynlib.nim"); 371 | result = dlopen(NIM_NIL, RTLD_NOW); 372 | goto BeforeRet; 373 | }BeforeRet: ; 374 | popFrame(); 375 | return result; 376 | } 377 | 378 | N_NIMCALL(void, unloadlib_124035)(void* lib) { 379 | nimfr("unloadLib", "dynlib.nim") 380 | nimln(71, "dynlib.nim"); 381 | dlclose(lib); 382 | popFrame(); 383 | } 384 | 385 | N_NIMCALL(void*, symaddr_124061)(void* lib, NCSTRING name) { 386 | void* result; 387 | nimfr("symAddr", "dynlib.nim") 388 | { result = 0; 389 | nimln(73, "dynlib.nim"); 390 | result = dlsym(lib, name); 391 | goto BeforeRet; 392 | }BeforeRet: ; 393 | popFrame(); 394 | return result; 395 | } 396 | NIM_EXTERNC N_NOINLINE(void, HEX00_dynlibInit000)(void) { 397 | nimfr("dynlib", "dynlib.nim") 398 | popFrame(); 399 | } 400 | 401 | NIM_EXTERNC N_NOINLINE(void, HEX00_dynlibDatInit000)(void) { 402 | } 403 | 404 | -------------------------------------------------------------------------------- /tests/nimcache/math.c: -------------------------------------------------------------------------------- 1 | /* Generated by Nim Compiler v0.12.0 */ 2 | /* (c) 2015 Andreas Rumpf */ 3 | /* The generated code is subject to the original license. */ 4 | /* Compiled for: Linux, amd64, gcc */ 5 | /* Command for C compiler: 6 | gcc -c -w -g3 -O0 -I/media/marco/Research/Applications/aporia/Nim/lib -o /home/marco/.nimble/pkgs/Pythonize27-1.0.0/tests/nimcache/math.o /home/marco/.nimble/pkgs/Pythonize27-1.0.0/tests/nimcache/math.c */ 7 | #define NIM_INTBITS 64 8 | 9 | #include "nimbase.h" 10 | #include 11 | #include 12 | typedef struct Runningstat118269 Runningstat118269; 13 | struct Runningstat118269 { 14 | NI n; 15 | NF sum; 16 | NF min; 17 | NF max; 18 | NF mean; 19 | NF oldm; 20 | NF olds; 21 | NF news; 22 | }; 23 | N_NIMCALL(NI, binom_110208)(NI n, NI k); 24 | N_NIMCALL(NI, mulInt)(NI a, NI b); 25 | static N_INLINE(NI, subInt)(NI a, NI b); 26 | N_NOINLINE(void, raiseOverflow)(void); 27 | static N_INLINE(NI, addInt)(NI a, NI b); 28 | static N_INLINE(NI, divInt)(NI a, NI b); 29 | N_NOINLINE(void, raiseDivByZero)(void); 30 | static N_INLINE(void, nimFrame)(TFrame* s); 31 | N_NOINLINE(void, stackoverflow_23601)(void); 32 | static N_INLINE(void, popFrame)(void); 33 | N_NIMCALL(NI, fac_110248)(NI n); 34 | N_NIMCALL(NU8, classify_116226)(NF x); 35 | N_NIMCALL(NIM_BOOL, ispoweroftwo_116238)(NI x); 36 | N_NIMCALL(NI, nextpoweroftwo_116248)(NI x); 37 | N_NIMCALL(NI, countbits32_116825)(NI32 n); 38 | N_NIMCALL(NF, log2_117025)(NF x); 39 | N_NIMCALL(NF, random_116935)(NF max); 40 | N_NIMCALL(void, randomize_116941)(void); 41 | N_NIMCALL(void, randomize_117004)(NI seed); 42 | N_NIMCALL(NF, ntepochTime)(void); 43 | N_NIMCALL(NI, random_116929)(NI max); 44 | N_NIMCALL(NF, mod_118229)(NF x, NF y); 45 | N_NIMCALL(void, push_118286)(Runningstat118269* s, NF x); 46 | N_NIMCALL(void, push_118306)(Runningstat118269* s, NI x); 47 | N_NIMCALL(NF, variance_118317)(Runningstat118269* s); 48 | N_NIMCALL(NF, standarddeviation_118327)(Runningstat118269* s); 49 | extern TFrame* frameptr_20842; 50 | 51 | static N_INLINE(NI, subInt)(NI a, NI b) { 52 | NI result; 53 | { result = 0; 54 | result = (NI)((NU64)(a) - (NU64)(b)); 55 | { 56 | NIM_BOOL LOC3; 57 | LOC3 = 0; 58 | LOC3 = (((NI) 0) <= (NI)(result ^ a)); 59 | if (LOC3) goto LA4; 60 | LOC3 = (((NI) 0) <= (NI)(result ^ (NI)((NU64) ~(b)))); 61 | LA4: ; 62 | if (!LOC3) goto LA5; 63 | goto BeforeRet; 64 | } 65 | LA5: ; 66 | raiseOverflow(); 67 | }BeforeRet: ; 68 | return result; 69 | } 70 | 71 | static N_INLINE(NI, addInt)(NI a, NI b) { 72 | NI result; 73 | { result = 0; 74 | result = (NI)((NU64)(a) + (NU64)(b)); 75 | { 76 | NIM_BOOL LOC3; 77 | LOC3 = 0; 78 | LOC3 = (((NI) 0) <= (NI)(result ^ a)); 79 | if (LOC3) goto LA4; 80 | LOC3 = (((NI) 0) <= (NI)(result ^ b)); 81 | LA4: ; 82 | if (!LOC3) goto LA5; 83 | goto BeforeRet; 84 | } 85 | LA5: ; 86 | raiseOverflow(); 87 | }BeforeRet: ; 88 | return result; 89 | } 90 | 91 | static N_INLINE(NI, divInt)(NI a, NI b) { 92 | NI result; 93 | { result = 0; 94 | { 95 | if (!(b == ((NI) 0))) goto LA3; 96 | raiseDivByZero(); 97 | } 98 | LA3: ; 99 | { 100 | NIM_BOOL LOC7; 101 | LOC7 = 0; 102 | LOC7 = (a == ((NI) (IL64(-9223372036854775807) - IL64(1)))); 103 | if (!(LOC7)) goto LA8; 104 | LOC7 = (b == ((NI) -1)); 105 | LA8: ; 106 | if (!LOC7) goto LA9; 107 | raiseOverflow(); 108 | } 109 | LA9: ; 110 | result = (NI)(a / b); 111 | goto BeforeRet; 112 | }BeforeRet: ; 113 | return result; 114 | } 115 | 116 | static N_INLINE(void, nimFrame)(TFrame* s) { 117 | NI LOC1; 118 | LOC1 = 0; 119 | { 120 | if (!(frameptr_20842 == NIM_NIL)) goto LA4; 121 | LOC1 = ((NI) 0); 122 | } 123 | goto LA2; 124 | LA4: ; 125 | { 126 | LOC1 = ((NI) ((NI16)((*frameptr_20842).calldepth + ((NI16) 1)))); 127 | } 128 | LA2: ; 129 | (*s).calldepth = ((NI16) (LOC1)); 130 | (*s).prev = frameptr_20842; 131 | frameptr_20842 = s; 132 | { 133 | if (!((*s).calldepth == ((NI16) 2000))) goto LA9; 134 | stackoverflow_23601(); 135 | } 136 | LA9: ; 137 | } 138 | 139 | static N_INLINE(void, popFrame)(void) { 140 | frameptr_20842 = (*frameptr_20842).prev; 141 | } 142 | 143 | N_NIMCALL(NI, binom_110208)(NI n, NI k) { 144 | NI result; 145 | nimfr("binom", "math.nim") 146 | { result = 0; 147 | nimln(26, "math.nim"); 148 | { 149 | if (!(k <= ((NI) 0))) goto LA3; 150 | result = ((NI) 1); 151 | goto BeforeRet; 152 | } 153 | LA3: ; 154 | nimln(27, "math.nim"); 155 | { 156 | NI TMP312; 157 | NI TMP313; 158 | nimln(357, "system.nim"); 159 | nimln(27, "math.nim"); 160 | TMP312 = mulInt(((NI) 2), k); 161 | if (!(n < (NI)(TMP312))) goto LA7; 162 | TMP313 = subInt(n, k); 163 | result = binom_110208(n, (NI)(TMP313)); 164 | goto BeforeRet; 165 | } 166 | LA7: ; 167 | nimln(28, "math.nim"); 168 | result = n; 169 | { 170 | NI i_110225; 171 | NI res_110229; 172 | i_110225 = 0; 173 | nimln(1874, "system.nim"); 174 | res_110229 = ((NI) 2); 175 | { 176 | nimln(1875, "system.nim"); 177 | while (1) { 178 | NI TMP314; 179 | NI TMP315; 180 | NI TMP316; 181 | NI TMP317; 182 | NI TMP318; 183 | if (!(res_110229 <= k)) goto LA11; 184 | nimln(1876, "system.nim"); 185 | i_110225 = res_110229; 186 | nimln(30, "math.nim"); 187 | TMP314 = addInt(n, ((NI) 1)); 188 | TMP315 = subInt((NI)(TMP314), i_110225); 189 | TMP316 = mulInt(result, (NI)(TMP315)); 190 | TMP317 = divInt((NI)(TMP316), i_110225); 191 | result = (NI)(TMP317); 192 | nimln(1890, "system.nim"); 193 | TMP318 = addInt(res_110229, ((NI) 1)); 194 | res_110229 = (NI)(TMP318); 195 | } LA11: ; 196 | } 197 | } 198 | }BeforeRet: ; 199 | popFrame(); 200 | return result; 201 | } 202 | 203 | N_NIMCALL(NI, fac_110248)(NI n) { 204 | NI result; 205 | nimfr("fac", "math.nim") 206 | result = 0; 207 | nimln(34, "math.nim"); 208 | result = ((NI) 1); 209 | { 210 | NI i_110264; 211 | NI res_110268; 212 | i_110264 = 0; 213 | nimln(1874, "system.nim"); 214 | res_110268 = ((NI) 2); 215 | { 216 | nimln(1875, "system.nim"); 217 | while (1) { 218 | NI TMP319; 219 | NI TMP320; 220 | if (!(res_110268 <= n)) goto LA3; 221 | nimln(1876, "system.nim"); 222 | i_110264 = res_110268; 223 | nimln(36, "math.nim"); 224 | TMP319 = mulInt(result, i_110264); 225 | result = (NI)(TMP319); 226 | nimln(1890, "system.nim"); 227 | TMP320 = addInt(res_110268, ((NI) 1)); 228 | res_110268 = (NI)(TMP320); 229 | } LA3: ; 230 | } 231 | } 232 | popFrame(); 233 | return result; 234 | } 235 | 236 | N_NIMCALL(NU8, classify_116226)(NF x) { 237 | NU8 result; 238 | { result = 0; 239 | { 240 | if (!(x == 0.0)) goto LA3; 241 | { 242 | if (!(((NF)(1.0000000000000000e+00) / (NF)(x)) == INF)) goto LA7; 243 | result = ((NU8) 2); 244 | goto BeforeRet; 245 | } 246 | goto LA5; 247 | LA7: ; 248 | { 249 | result = ((NU8) 3); 250 | goto BeforeRet; 251 | } 252 | LA5: ; 253 | } 254 | LA3: ; 255 | { 256 | if (!(((NF)(x) * (NF)(5.0000000000000000e-01)) == x)) goto LA12; 257 | { 258 | if (!(0.0 < x)) goto LA16; 259 | result = ((NU8) 5); 260 | goto BeforeRet; 261 | } 262 | goto LA14; 263 | LA16: ; 264 | { 265 | result = ((NU8) 6); 266 | goto BeforeRet; 267 | } 268 | LA14: ; 269 | } 270 | LA12: ; 271 | { 272 | if (!!((x == x))) goto LA21; 273 | result = ((NU8) 4); 274 | goto BeforeRet; 275 | } 276 | LA21: ; 277 | result = ((NU8) 0); 278 | goto BeforeRet; 279 | }BeforeRet: ; 280 | return result; 281 | } 282 | 283 | N_NIMCALL(NIM_BOOL, ispoweroftwo_116238)(NI x) { 284 | NIM_BOOL result; 285 | NIM_BOOL LOC1; 286 | { result = 0; 287 | LOC1 = 0; 288 | LOC1 = (((NI) 0) < x); 289 | if (!(LOC1)) goto LA2; 290 | LOC1 = ((NI)(x & (NI)(x - ((NI) 1))) == ((NI) 0)); 291 | LA2: ; 292 | result = LOC1; 293 | goto BeforeRet; 294 | }BeforeRet: ; 295 | return result; 296 | } 297 | 298 | N_NIMCALL(NI, nextpoweroftwo_116248)(NI x) { 299 | NI result; 300 | result = 0; 301 | result = (NI)(x - ((NI) 1)); 302 | result = (NI)(result | (NI)((NU64)(result) >> (NU64)(((NI) 32)))); 303 | result = (NI)(result | (NI)((NU64)(result) >> (NU64)(((NI) 16)))); 304 | result = (NI)(result | (NI)((NU64)(result) >> (NU64)(((NI) 8)))); 305 | result = (NI)(result | (NI)((NU64)(result) >> (NU64)(((NI) 4)))); 306 | result = (NI)(result | (NI)((NU64)(result) >> (NU64)(((NI) 2)))); 307 | result = (NI)(result | (NI)((NU64)(result) >> (NU64)(((NI) 1)))); 308 | result += ((NI) ((NI)(((NI) 1) + ((NI) ((x <= ((NI) 0))))))); 309 | return result; 310 | } 311 | 312 | N_NIMCALL(NI, countbits32_116825)(NI32 n) { 313 | NI result; 314 | NI32 v; 315 | result = 0; 316 | v = n; 317 | v = (NI32)((NU32)(v) - (NU32)((NI32)((NI32)((NU32)(v) >> (NU32)(((NI32) 1))) & ((NI32) 1431655765)))); 318 | v = (NI32)((NU32)((NI32)(v & ((NI32) 858993459))) + (NU32)((NI32)((NI32)((NU32)(v) >> (NU32)(((NI32) 2))) & ((NI32) 858993459)))); 319 | result = ((NI) ((NI32)((NU32)((NI32)((NU32)((NI32)((NI32)((NU32)(v) + (NU32)((NI32)((NU32)(v) >> (NU32)(((NI32) 4))))) & ((NI32) 252645135))) * (NU32)(((NI32) 16843009)))) >> (NU32)(((NI32) 24))))); 320 | return result; 321 | } 322 | 323 | N_NIMCALL(NF, log2_117025)(NF x) { 324 | NF result; 325 | NF LOC1; 326 | NF LOC2; 327 | { result = 0; 328 | LOC1 = 0; 329 | LOC1 = log(x); 330 | LOC2 = 0; 331 | LOC2 = log(2.0000000000000000e+00); 332 | result = ((NF)(LOC1) / (NF)(LOC2)); 333 | goto BeforeRet; 334 | }BeforeRet: ; 335 | return result; 336 | } 337 | 338 | N_NIMCALL(NF, random_116935)(NF max) { 339 | NF result; 340 | NF LOC1; 341 | result = 0; 342 | LOC1 = 0; 343 | LOC1 = drand48(); 344 | result = ((NF)(LOC1) * (NF)(max)); 345 | return result; 346 | } 347 | 348 | N_NIMCALL(void, randomize_117004)(NI seed) { 349 | srand(((int) (seed))); 350 | srand48(seed); 351 | } 352 | 353 | N_NIMCALL(void, randomize_116941)(void) { 354 | union { NF source; NI dest; } LOC1; 355 | LOC1.source = ntepochTime(); 356 | randomize_117004(LOC1.dest); 357 | } 358 | 359 | N_NIMCALL(NI, random_116929)(NI max) { 360 | NI result; 361 | int LOC1; 362 | result = 0; 363 | LOC1 = 0; 364 | LOC1 = rand(); 365 | result = (NI)(((NI) (LOC1)) % max); 366 | return result; 367 | } 368 | 369 | N_NIMCALL(NF, mod_118229)(NF x, NF y) { 370 | NF result; 371 | result = 0; 372 | { 373 | if (!(y == 0.0)) goto LA3; 374 | result = x; 375 | } 376 | goto LA1; 377 | LA3: ; 378 | { 379 | NF LOC6; 380 | LOC6 = 0; 381 | LOC6 = floor(((NF)(x) / (NF)(y))); 382 | result = ((NF)(x) - (NF)(((NF)(y) * (NF)(LOC6)))); 383 | } 384 | LA1: ; 385 | return result; 386 | } 387 | 388 | N_NIMCALL(void, push_118286)(Runningstat118269* s, NF x) { 389 | (*s).n += ((NI) 1); 390 | { 391 | if (!((*s).n == ((NI) 1))) goto LA3; 392 | (*s).min = x; 393 | (*s).max = x; 394 | (*s).oldm = x; 395 | (*s).mean = x; 396 | (*s).olds = 0.0; 397 | } 398 | goto LA1; 399 | LA3: ; 400 | { 401 | { 402 | if (!(x < (*s).min)) goto LA8; 403 | (*s).min = x; 404 | } 405 | LA8: ; 406 | { 407 | if (!((*s).max < x)) goto LA12; 408 | (*s).max = x; 409 | } 410 | LA12: ; 411 | (*s).mean = ((NF)((*s).oldm) + (NF)(((NF)(((NF)(x) - (NF)((*s).oldm))) / (NF)(((double) ((*s).n)))))); 412 | (*s).news = ((NF)((*s).olds) + (NF)(((NF)(((NF)(x) - (NF)((*s).oldm))) * (NF)(((NF)(x) - (NF)((*s).mean)))))); 413 | (*s).oldm = (*s).mean; 414 | (*s).olds = (*s).news; 415 | } 416 | LA1: ; 417 | (*s).sum = ((NF)((*s).sum) + (NF)(x)); 418 | } 419 | 420 | N_NIMCALL(void, push_118306)(Runningstat118269* s, NI x) { 421 | push_118286(s, ((double) (x))); 422 | } 423 | 424 | N_NIMCALL(NF, variance_118317)(Runningstat118269* s) { 425 | NF result; 426 | result = 0; 427 | { 428 | if (!(((NI) 1) < (*s).n)) goto LA3; 429 | result = ((NF)((*s).news) / (NF)(((double) ((NI)((*s).n - ((NI) 1)))))); 430 | } 431 | LA3: ; 432 | return result; 433 | } 434 | 435 | N_NIMCALL(NF, standarddeviation_118327)(Runningstat118269* s) { 436 | NF result; 437 | NF LOC1; 438 | result = 0; 439 | LOC1 = 0; 440 | LOC1 = variance_118317(s); 441 | result = sqrt(LOC1); 442 | return result; 443 | } 444 | NIM_EXTERNC N_NOINLINE(void, HEX00_mathInit000)(void) { 445 | nimfr("math", "math.nim") 446 | popFrame(); 447 | } 448 | 449 | NIM_EXTERNC N_NOINLINE(void, HEX00_mathDatInit000)(void) { 450 | } 451 | 452 | -------------------------------------------------------------------------------- /tests/nimcache/parseutils.c: -------------------------------------------------------------------------------- 1 | /* Generated by Nim Compiler v0.12.0 */ 2 | /* (c) 2015 Andreas Rumpf */ 3 | /* The generated code is subject to the original license. */ 4 | /* Compiled for: Linux, amd64, gcc */ 5 | /* Command for C compiler: 6 | gcc -c -w -g3 -O0 -I/media/marco/Research/Applications/aporia/Nim/lib -o /home/marco/.nimble/pkgs/Pythonize27-1.0.0/tests/nimcache/parseutils.o /home/marco/.nimble/pkgs/Pythonize27-1.0.0/tests/nimcache/parseutils.c */ 7 | #define NIM_INTBITS 64 8 | 9 | #include "nimbase.h" 10 | #include 11 | #include 12 | typedef struct NimStringDesc NimStringDesc; 13 | typedef struct TGenericSeq TGenericSeq; 14 | typedef struct Overflowerror4043 Overflowerror4043; 15 | typedef struct Arithmeticerror4039 Arithmeticerror4039; 16 | typedef struct Exception Exception; 17 | typedef struct TNimObject TNimObject; 18 | typedef struct TNimType TNimType; 19 | typedef struct TNimNode TNimNode; 20 | typedef struct Memregion31291 Memregion31291; 21 | typedef struct Gcheap51418 Gcheap51418; 22 | typedef struct Gcstack51416 Gcstack51416; 23 | typedef struct Cellseq49363 Cellseq49363; 24 | typedef struct Cell49347 Cell49347; 25 | typedef struct Cellset49359 Cellset49359; 26 | typedef struct Pagedesc49355 Pagedesc49355; 27 | typedef struct Smallchunk31243 Smallchunk31243; 28 | typedef struct Llchunk31285 Llchunk31285; 29 | typedef struct Bigchunk31245 Bigchunk31245; 30 | typedef struct Intset31217 Intset31217; 31 | typedef struct Trunk31213 Trunk31213; 32 | typedef struct Avlnode31289 Avlnode31289; 33 | typedef struct Gcstat51414 Gcstat51414; 34 | typedef struct Basechunk31241 Basechunk31241; 35 | typedef struct Freecell31233 Freecell31233; 36 | struct TGenericSeq { 37 | NI len; 38 | NI reserved; 39 | }; 40 | struct NimStringDesc { 41 | TGenericSeq Sup; 42 | NIM_CHAR data[SEQ_DECL_SIZE]; 43 | }; 44 | typedef N_NIMCALL_PTR(void, TY3889) (void* p, NI op); 45 | typedef N_NIMCALL_PTR(void*, TY3894) (void* p); 46 | struct TNimType { 47 | NI size; 48 | NU8 kind; 49 | NU8 flags; 50 | TNimType* base; 51 | TNimNode* node; 52 | void* finalizer; 53 | TY3889 marker; 54 | TY3894 deepcopy; 55 | }; 56 | struct TNimObject { 57 | TNimType* m_type; 58 | }; 59 | struct Exception { 60 | TNimObject Sup; 61 | Exception* parent; 62 | NCSTRING name; 63 | NimStringDesc* message; 64 | NimStringDesc* trace; 65 | }; 66 | struct Arithmeticerror4039 { 67 | Exception Sup; 68 | }; 69 | struct Overflowerror4043 { 70 | Arithmeticerror4039 Sup; 71 | }; 72 | struct TNimNode { 73 | NU8 kind; 74 | NI offset; 75 | TNimType* typ; 76 | NCSTRING name; 77 | NI len; 78 | TNimNode** sons; 79 | }; 80 | struct Cellseq49363 { 81 | NI len; 82 | NI cap; 83 | Cell49347** d; 84 | }; 85 | struct Cellset49359 { 86 | NI counter; 87 | NI max; 88 | Pagedesc49355* head; 89 | Pagedesc49355** data; 90 | }; 91 | typedef Smallchunk31243* TY31306[512]; 92 | typedef Trunk31213* Trunkbuckets31215[256]; 93 | struct Intset31217 { 94 | Trunkbuckets31215 data; 95 | }; 96 | struct Memregion31291 { 97 | NI minlargeobj; 98 | NI maxlargeobj; 99 | TY31306 freesmallchunks; 100 | Llchunk31285* llmem; 101 | NI currmem; 102 | NI maxmem; 103 | NI freemem; 104 | NI lastsize; 105 | Bigchunk31245* freechunkslist; 106 | Intset31217 chunkstarts; 107 | Avlnode31289* root; 108 | Avlnode31289* deleted; 109 | Avlnode31289* last; 110 | Avlnode31289* freeavlnodes; 111 | }; 112 | struct Gcstat51414 { 113 | NI stackscans; 114 | NI cyclecollections; 115 | NI maxthreshold; 116 | NI maxstacksize; 117 | NI maxstackcells; 118 | NI cycletablesize; 119 | NI64 maxpause; 120 | }; 121 | struct Gcheap51418 { 122 | Gcstack51416* stack; 123 | void* stackbottom; 124 | NI cyclethreshold; 125 | Cellseq49363 zct; 126 | Cellseq49363 decstack; 127 | Cellset49359 cycleroots; 128 | Cellseq49363 tempstack; 129 | NI recgclock; 130 | Memregion31291 region; 131 | Gcstat51414 stat; 132 | }; 133 | struct Cell49347 { 134 | NI refcount; 135 | TNimType* typ; 136 | }; 137 | struct Gcstack51416 { 138 | Gcstack51416* prev; 139 | Gcstack51416* next; 140 | void* starts; 141 | void* pos; 142 | NI maxstacksize; 143 | }; 144 | typedef NI TY31222[8]; 145 | struct Pagedesc49355 { 146 | Pagedesc49355* next; 147 | NI key; 148 | TY31222 bits; 149 | }; 150 | struct Basechunk31241 { 151 | NI prevsize; 152 | NI size; 153 | NIM_BOOL used; 154 | }; 155 | struct Smallchunk31243 { 156 | Basechunk31241 Sup; 157 | Smallchunk31243* next; 158 | Smallchunk31243* prev; 159 | Freecell31233* freelist; 160 | NI free; 161 | NI acc; 162 | NF data; 163 | }; 164 | struct Llchunk31285 { 165 | NI size; 166 | NI acc; 167 | Llchunk31285* next; 168 | }; 169 | struct Bigchunk31245 { 170 | Basechunk31241 Sup; 171 | Bigchunk31245* next; 172 | Bigchunk31245* prev; 173 | NI align; 174 | NF data; 175 | }; 176 | struct Trunk31213 { 177 | Trunk31213* next; 178 | NI key; 179 | TY31222 bits; 180 | }; 181 | typedef Avlnode31289* TY31296[2]; 182 | struct Avlnode31289 { 183 | TY31296 link; 184 | NI key; 185 | NI upperbound; 186 | NI level; 187 | }; 188 | struct Freecell31233 { 189 | Freecell31233* next; 190 | NI zerofield; 191 | }; 192 | N_NIMCALL(NI, npuParseBiggestInt)(NimStringDesc* s, NI64* number, NI start); 193 | N_NIMCALL(NI, rawparseint_96914)(NimStringDesc* s, NI64* b, NI start); 194 | N_NOINLINE(void, raiseIndexError)(void); 195 | static N_INLINE(NI, addInt)(NI a, NI b); 196 | N_NOINLINE(void, raiseOverflow)(void); 197 | N_NIMCALL(NI64, mulInt64)(NI64 a, NI64 b); 198 | static N_INLINE(NI, subInt)(NI a, NI b); 199 | static N_INLINE(NI64, subInt64)(NI64 a, NI64 b); 200 | static N_INLINE(void, nimFrame)(TFrame* s); 201 | N_NOINLINE(void, stackoverflow_23601)(void); 202 | static N_INLINE(void, popFrame)(void); 203 | N_NIMCALL(void*, newObj)(TNimType* typ, NI size); 204 | N_NIMCALL(NimStringDesc*, copyStringRC1)(NimStringDesc* src); 205 | static N_INLINE(void, nimGCunrefNoCycle)(void* p); 206 | N_NIMCALL(NIM_BOOL, allocinv_38411)(Memregion31291* a); 207 | static N_INLINE(Cell49347*, usrtocell_53046)(void* usr); 208 | N_NIMCALL(NIM_BOOL, isallocatedptr_38407)(Memregion31291* a, void* p); 209 | static N_INLINE(void, Gcdisable_11201)(void); 210 | N_NIMCALL(void, writestacktrace_20207)(void); 211 | static N_INLINE(void, rtladdzct_54604)(Cell49347* c); 212 | N_NOINLINE(void, addzct_53017)(Cellseq49363* s, Cell49347* c); 213 | N_NIMCALL(void, raiseException)(Exception* e, NCSTRING ename); 214 | STRING_LITERAL(TMP392, "overflow", 8); 215 | STRING_LITERAL(TMP393, "[SYSASSERT] ", 12); 216 | STRING_LITERAL(TMP394, "begin nimGCunrefNoCycle", 23); 217 | STRING_LITERAL(TMP395, "[GCASSERT] ", 11); 218 | STRING_LITERAL(TMP396, "nimGCunrefNoCycle: isAllocatedPtr", 33); 219 | STRING_LITERAL(TMP397, "end nimGCunrefNoCycle 2", 23); 220 | STRING_LITERAL(TMP398, "end nimGCunrefNoCycle 5", 23); 221 | extern TFrame* frameptr_20842; 222 | extern TNimType NTI25717; /* ref OverflowError */ 223 | extern TNimType NTI4043; /* OverflowError */ 224 | extern Gcheap51418 gch_51459; 225 | 226 | static N_INLINE(NI, addInt)(NI a, NI b) { 227 | NI result; 228 | { result = 0; 229 | result = (NI)((NU64)(a) + (NU64)(b)); 230 | { 231 | NIM_BOOL LOC3; 232 | LOC3 = 0; 233 | LOC3 = (((NI) 0) <= (NI)(result ^ a)); 234 | if (LOC3) goto LA4; 235 | LOC3 = (((NI) 0) <= (NI)(result ^ b)); 236 | LA4: ; 237 | if (!LOC3) goto LA5; 238 | goto BeforeRet; 239 | } 240 | LA5: ; 241 | raiseOverflow(); 242 | }BeforeRet: ; 243 | return result; 244 | } 245 | 246 | static N_INLINE(NI, subInt)(NI a, NI b) { 247 | NI result; 248 | { result = 0; 249 | result = (NI)((NU64)(a) - (NU64)(b)); 250 | { 251 | NIM_BOOL LOC3; 252 | LOC3 = 0; 253 | LOC3 = (((NI) 0) <= (NI)(result ^ a)); 254 | if (LOC3) goto LA4; 255 | LOC3 = (((NI) 0) <= (NI)(result ^ (NI)((NU64) ~(b)))); 256 | LA4: ; 257 | if (!LOC3) goto LA5; 258 | goto BeforeRet; 259 | } 260 | LA5: ; 261 | raiseOverflow(); 262 | }BeforeRet: ; 263 | return result; 264 | } 265 | 266 | static N_INLINE(NI64, subInt64)(NI64 a, NI64 b) { 267 | NI64 result; 268 | { result = 0; 269 | result = (NI64)((NU64)(a) - (NU64)(b)); 270 | { 271 | NIM_BOOL LOC3; 272 | LOC3 = 0; 273 | LOC3 = (IL64(0) <= (NI64)(result ^ a)); 274 | if (LOC3) goto LA4; 275 | LOC3 = (IL64(0) <= (NI64)(result ^ (NI64)((NU64) ~(b)))); 276 | LA4: ; 277 | if (!LOC3) goto LA5; 278 | goto BeforeRet; 279 | } 280 | LA5: ; 281 | raiseOverflow(); 282 | }BeforeRet: ; 283 | return result; 284 | } 285 | 286 | static N_INLINE(void, nimFrame)(TFrame* s) { 287 | NI LOC1; 288 | LOC1 = 0; 289 | { 290 | if (!(frameptr_20842 == NIM_NIL)) goto LA4; 291 | LOC1 = ((NI) 0); 292 | } 293 | goto LA2; 294 | LA4: ; 295 | { 296 | LOC1 = ((NI) ((NI16)((*frameptr_20842).calldepth + ((NI16) 1)))); 297 | } 298 | LA2: ; 299 | (*s).calldepth = ((NI16) (LOC1)); 300 | (*s).prev = frameptr_20842; 301 | frameptr_20842 = s; 302 | { 303 | if (!((*s).calldepth == ((NI16) 2000))) goto LA9; 304 | stackoverflow_23601(); 305 | } 306 | LA9: ; 307 | } 308 | 309 | static N_INLINE(void, popFrame)(void) { 310 | frameptr_20842 = (*frameptr_20842).prev; 311 | } 312 | 313 | N_NIMCALL(NI, rawparseint_96914)(NimStringDesc* s, NI64* b, NI start) { 314 | NI result; 315 | NI64 sign; 316 | NI i; 317 | nimfr("rawParseInt", "parseutils.nim") 318 | result = 0; 319 | nimln(194, "parseutils.nim"); 320 | sign = IL64(-1); 321 | nimln(195, "parseutils.nim"); 322 | i = start; 323 | nimln(196, "parseutils.nim"); 324 | { 325 | NI TMP383; 326 | if ((NU)(i) > (NU)(s->Sup.len)) raiseIndexError(); 327 | if (!((NU8)(s->data[i]) == (NU8)(43))) goto LA3; 328 | TMP383 = addInt(i, ((NI) 1)); 329 | i = (NI)(TMP383); 330 | } 331 | goto LA1; 332 | LA3: ; 333 | { 334 | NI TMP384; 335 | nimln(197, "parseutils.nim"); 336 | if ((NU)(i) > (NU)(s->Sup.len)) raiseIndexError(); 337 | if (!((NU8)(s->data[i]) == (NU8)(45))) goto LA6; 338 | nimln(198, "parseutils.nim"); 339 | TMP384 = addInt(i, ((NI) 1)); 340 | i = (NI)(TMP384); 341 | nimln(199, "parseutils.nim"); 342 | sign = IL64(1); 343 | } 344 | goto LA1; 345 | LA6: ; 346 | LA1: ; 347 | nimln(200, "parseutils.nim"); 348 | { 349 | NI64 TMP390; 350 | NI TMP391; 351 | nimln(1098, "system.nim"); 352 | if ((NU)(i) > (NU)(s->Sup.len)) raiseIndexError(); 353 | if (!(((NU8)(s->data[i])) >= ((NU8)(48)) && ((NU8)(s->data[i])) <= ((NU8)(57)))) goto LA10; 354 | nimln(201, "parseutils.nim"); 355 | (*b) = IL64(0); 356 | { 357 | nimln(202, "parseutils.nim"); 358 | while (1) { 359 | NI64 TMP385; 360 | NI TMP386; 361 | NI64 TMP387; 362 | NI TMP388; 363 | nimln(1098, "system.nim"); 364 | if ((NU)(i) > (NU)(s->Sup.len)) raiseIndexError(); 365 | if (!(((NU8)(s->data[i])) >= ((NU8)(48)) && ((NU8)(s->data[i])) <= ((NU8)(57)))) goto LA13; 366 | nimln(203, "parseutils.nim"); 367 | TMP385 = mulInt64((*b), IL64(10)); 368 | if ((NU)(i) > (NU)(s->Sup.len)) raiseIndexError(); 369 | TMP386 = subInt(((NI) (((NU8)(s->data[i])))), ((NI) 48)); 370 | TMP387 = subInt64((NI64)(TMP385), ((NI64) ((NI)(TMP386)))); 371 | (*b) = (NI64)(TMP387); 372 | nimln(204, "parseutils.nim"); 373 | TMP388 = addInt(i, ((NI) 1)); 374 | i = (NI)(TMP388); 375 | { 376 | nimln(205, "parseutils.nim"); 377 | while (1) { 378 | NI TMP389; 379 | if ((NU)(i) > (NU)(s->Sup.len)) raiseIndexError(); 380 | if (!((NU8)(s->data[i]) == (NU8)(95))) goto LA15; 381 | TMP389 = addInt(i, ((NI) 1)); 382 | i = (NI)(TMP389); 383 | } LA15: ; 384 | } 385 | } LA13: ; 386 | } 387 | nimln(206, "parseutils.nim"); 388 | TMP390 = mulInt64((*b), sign); 389 | (*b) = (NI64)(TMP390); 390 | nimln(207, "parseutils.nim"); 391 | TMP391 = subInt(i, start); 392 | result = (NI)(TMP391); 393 | } 394 | LA10: ; 395 | popFrame(); 396 | return result; 397 | } 398 | 399 | N_NIMCALL(NI, npuParseBiggestInt)(NimStringDesc* s, NI64* number, NI start) { 400 | NI result; 401 | NI64 res; 402 | nimfr("parseBiggestInt", "parseutils.nim") 403 | result = 0; 404 | res = 0; 405 | nimln(218, "parseutils.nim"); 406 | result = rawparseint_96914(s, (&res), start); 407 | nimln(219, "parseutils.nim"); 408 | (*number) = res; 409 | popFrame(); 410 | return result; 411 | } 412 | 413 | static N_INLINE(Cell49347*, usrtocell_53046)(void* usr) { 414 | Cell49347* result; 415 | nimfr("usrToCell", "gc.nim") 416 | result = 0; 417 | nimln(131, "gc.nim"); 418 | result = ((Cell49347*) ((NI)((NU64)(((NI) (usr))) - (NU64)(((NI)sizeof(Cell49347)))))); 419 | popFrame(); 420 | return result; 421 | } 422 | 423 | static N_INLINE(void, Gcdisable_11201)(void) { 424 | nimfr("GC_disable", "gc.nim") 425 | nimln(976, "gc.nim"); 426 | gch_51459.recgclock += ((NI) 1); 427 | popFrame(); 428 | } 429 | 430 | static N_INLINE(void, rtladdzct_54604)(Cell49347* c) { 431 | nimfr("rtlAddZCT", "gc.nim") 432 | nimln(212, "gc.nim"); 433 | addzct_53017((&gch_51459.zct), c); 434 | popFrame(); 435 | } 436 | 437 | static N_INLINE(void, nimGCunrefNoCycle)(void* p) { 438 | Cell49347* c; 439 | nimfr("nimGCunrefNoCycle", "gc.nim") 440 | nimln(1365, "system.nim"); 441 | { 442 | NIM_BOOL LOC3; 443 | nimln(245, "gc.nim"); 444 | LOC3 = 0; 445 | LOC3 = allocinv_38411((&gch_51459.region)); 446 | if (!!(LOC3)) goto LA4; 447 | nimln(1366, "system.nim"); 448 | printf("%s%s\012", ((NimStringDesc*) &TMP393)? (((NimStringDesc*) &TMP393))->data:"nil", ((NimStringDesc*) &TMP394)? (((NimStringDesc*) &TMP394))->data:"nil"); 449 | nimln(1367, "system.nim"); 450 | exit(((NI) 1)); 451 | } 452 | LA4: ; 453 | nimln(246, "gc.nim"); 454 | c = usrtocell_53046(p); 455 | nimln(114, "gc.nim"); 456 | { 457 | NIM_BOOL LOC8; 458 | nimln(247, "gc.nim"); 459 | LOC8 = 0; 460 | LOC8 = isallocatedptr_38407((&gch_51459.region), ((void*) (c))); 461 | if (!!(LOC8)) goto LA9; 462 | nimln(115, "gc.nim"); 463 | printf("%s%s\012", ((NimStringDesc*) &TMP395)? (((NimStringDesc*) &TMP395))->data:"nil", ((NimStringDesc*) &TMP396)? (((NimStringDesc*) &TMP396))->data:"nil"); 464 | nimln(116, "gc.nim"); 465 | Gcdisable_11201(); 466 | nimln(117, "gc.nim"); 467 | writestacktrace_20207(); 468 | nimln(118, "gc.nim"); 469 | exit(((NI) 1)); 470 | } 471 | LA9: ; 472 | nimln(248, "gc.nim"); 473 | { 474 | nimln(180, "gc.nim"); 475 | (*c).refcount -= ((NI) 8); 476 | nimln(181, "gc.nim"); 477 | if (!((NU64)((*c).refcount) < (NU64)(((NI) 8)))) goto LA13; 478 | nimln(249, "gc.nim"); 479 | rtladdzct_54604(c); 480 | nimln(1365, "system.nim"); 481 | { 482 | NIM_BOOL LOC17; 483 | nimln(250, "gc.nim"); 484 | LOC17 = 0; 485 | LOC17 = allocinv_38411((&gch_51459.region)); 486 | if (!!(LOC17)) goto LA18; 487 | nimln(1366, "system.nim"); 488 | printf("%s%s\012", ((NimStringDesc*) &TMP393)? (((NimStringDesc*) &TMP393))->data:"nil", ((NimStringDesc*) &TMP397)? (((NimStringDesc*) &TMP397))->data:"nil"); 489 | nimln(1367, "system.nim"); 490 | exit(((NI) 1)); 491 | } 492 | LA18: ; 493 | } 494 | LA13: ; 495 | nimln(1365, "system.nim"); 496 | { 497 | NIM_BOOL LOC22; 498 | nimln(251, "gc.nim"); 499 | LOC22 = 0; 500 | LOC22 = allocinv_38411((&gch_51459.region)); 501 | if (!!(LOC22)) goto LA23; 502 | nimln(1366, "system.nim"); 503 | printf("%s%s\012", ((NimStringDesc*) &TMP393)? (((NimStringDesc*) &TMP393))->data:"nil", ((NimStringDesc*) &TMP398)? (((NimStringDesc*) &TMP398))->data:"nil"); 504 | nimln(1367, "system.nim"); 505 | exit(((NI) 1)); 506 | } 507 | LA23: ; 508 | popFrame(); 509 | } 510 | 511 | N_NIMCALL(NI, npuParseInt)(NimStringDesc* s, NI* number, NI start) { 512 | NI result; 513 | NI64 res; 514 | nimfr("parseInt", "parseutils.nim") 515 | result = 0; 516 | res = 0; 517 | nimln(227, "parseutils.nim"); 518 | result = npuParseBiggestInt(s, (&res), start); 519 | nimln(228, "parseutils.nim"); 520 | { 521 | NIM_BOOL LOC3; 522 | NIM_BOOL LOC5; 523 | Overflowerror4043* e_97055; 524 | NimStringDesc* LOC9; 525 | LOC3 = 0; 526 | LOC3 = NIM_FALSE; 527 | if (!(LOC3)) goto LA4; 528 | nimln(229, "parseutils.nim"); 529 | LOC5 = 0; 530 | LOC5 = (res < (IL64(-9223372036854775807) - IL64(1))); 531 | if (LOC5) goto LA6; 532 | nimln(357, "system.nim"); 533 | LOC5 = (IL64(9223372036854775807) < res); 534 | LA6: ; 535 | LOC3 = LOC5; 536 | LA4: ; 537 | if (!LOC3) goto LA7; 538 | e_97055 = 0; 539 | nimln(2507, "system.nim"); 540 | e_97055 = (Overflowerror4043*) newObj((&NTI25717), sizeof(Overflowerror4043)); 541 | (*e_97055).Sup.Sup.Sup.m_type = (&NTI4043); 542 | nimln(2508, "system.nim"); 543 | LOC9 = 0; 544 | LOC9 = (*e_97055).Sup.Sup.message; (*e_97055).Sup.Sup.message = copyStringRC1(((NimStringDesc*) &TMP392)); 545 | if (LOC9) nimGCunrefNoCycle(LOC9); 546 | nimln(230, "parseutils.nim"); 547 | raiseException((Exception*)e_97055, "OverflowError"); 548 | } 549 | goto LA1; 550 | LA7: ; 551 | { 552 | nimln(349, "system.nim"); 553 | if (!!((result == ((NI) 0)))) goto LA11; 554 | nimln(232, "parseutils.nim"); 555 | (*number) = ((NI) (res)); 556 | } 557 | goto LA1; 558 | LA11: ; 559 | LA1: ; 560 | popFrame(); 561 | return result; 562 | } 563 | NIM_EXTERNC N_NOINLINE(void, HEX00_parseutilsInit000)(void) { 564 | nimfr("parseutils", "parseutils.nim") 565 | popFrame(); 566 | } 567 | 568 | NIM_EXTERNC N_NOINLINE(void, HEX00_parseutilsDatInit000)(void) { 569 | } 570 | 571 | -------------------------------------------------------------------------------- /tests/nimcache/hashes.c: -------------------------------------------------------------------------------- 1 | /* Generated by Nim Compiler v0.12.0 */ 2 | /* (c) 2015 Andreas Rumpf */ 3 | /* The generated code is subject to the original license. */ 4 | /* Compiled for: Linux, amd64, gcc */ 5 | /* Command for C compiler: 6 | gcc -c -w -g3 -O0 -I/media/marco/Research/Applications/aporia/Nim/lib -o /home/marco/.nimble/pkgs/Pythonize27-1.0.0/tests/nimcache/hashes.o /home/marco/.nimble/pkgs/Pythonize27-1.0.0/tests/nimcache/hashes.c */ 7 | #define NIM_INTBITS 64 8 | 9 | #include "nimbase.h" 10 | typedef struct NimStringDesc NimStringDesc; 11 | typedef struct TGenericSeq TGenericSeq; 12 | struct TGenericSeq { 13 | NI len; 14 | NI reserved; 15 | }; 16 | struct NimStringDesc { 17 | TGenericSeq Sup; 18 | NIM_CHAR data[SEQ_DECL_SIZE]; 19 | }; 20 | static N_INLINE(NI, HEX21HEX26_107013)(NI h, NI val); 21 | static N_INLINE(void, nimFrame)(TFrame* s); 22 | N_NOINLINE(void, stackoverflow_23601)(void); 23 | static N_INLINE(void, popFrame)(void); 24 | static N_INLINE(NI, HEX21HEX24_107042)(NI h); 25 | N_NIMCALL(NI, hashdata_107070)(void* data, NI size); 26 | static N_INLINE(NI, addInt)(NI a, NI b); 27 | N_NOINLINE(void, raiseOverflow)(void); 28 | static N_INLINE(NI, subInt)(NI a, NI b); 29 | static N_INLINE(NI, hash_107401)(void* x); 30 | static N_INLINE(NI, hash_107804)(NI x); 31 | static N_INLINE(NI, hash_107814)(NI64 x); 32 | static N_INLINE(NI, hash_107824)(NIM_CHAR x); 33 | N_NIMCALL(NI, hash_107851)(NimStringDesc* x); 34 | N_NOINLINE(void, raiseIndexError)(void); 35 | N_NIMCALL(NI, hash_107899)(NimStringDesc* sbuf, NI spos, NI epos); 36 | N_NIMCALL(NI, hashignorestyle_107948)(NimStringDesc* x); 37 | static N_INLINE(NIM_BOOL, ismagicidentseparatorrune_106010)(NCSTRING cs, NI i); 38 | static N_INLINE(NI, chckRange)(NI i, NI a, NI b); 39 | N_NOINLINE(void, raiseRangeError)(NI64 val); 40 | N_NIMCALL(NI, hashignorestyle_108043)(NimStringDesc* sbuf, NI spos, NI epos); 41 | N_NIMCALL(NI, hashignorecase_108139)(NimStringDesc* x); 42 | N_NIMCALL(NI, hashignorecase_108226)(NimStringDesc* sbuf, NI spos, NI epos); 43 | static N_INLINE(NI, hash_108314)(NF x); 44 | extern TFrame* frameptr_20842; 45 | 46 | static N_INLINE(void, nimFrame)(TFrame* s) { 47 | NI LOC1; 48 | LOC1 = 0; 49 | { 50 | if (!(frameptr_20842 == NIM_NIL)) goto LA4; 51 | LOC1 = ((NI) 0); 52 | } 53 | goto LA2; 54 | LA4: ; 55 | { 56 | LOC1 = ((NI) ((NI16)((*frameptr_20842).calldepth + ((NI16) 1)))); 57 | } 58 | LA2: ; 59 | (*s).calldepth = ((NI16) (LOC1)); 60 | (*s).prev = frameptr_20842; 61 | frameptr_20842 = s; 62 | { 63 | if (!((*s).calldepth == ((NI16) 2000))) goto LA9; 64 | stackoverflow_23601(); 65 | } 66 | LA9: ; 67 | } 68 | 69 | static N_INLINE(void, popFrame)(void) { 70 | frameptr_20842 = (*frameptr_20842).prev; 71 | } 72 | 73 | static N_INLINE(NI, HEX21HEX26_107013)(NI h, NI val) { 74 | NI result; 75 | nimfr("!&", "hashes.nim") 76 | result = 0; 77 | nimln(53, "hashes.nim"); 78 | result = (NI)((NU64)(h) + (NU64)(val)); 79 | nimln(54, "hashes.nim"); 80 | result = (NI)((NU64)(result) + (NU64)((NI)((NU64)(result) << (NU64)(((NI) 10))))); 81 | nimln(55, "hashes.nim"); 82 | result = (NI)(result ^ (NI)((NU64)(result) >> (NU64)(((NI) 6)))); 83 | popFrame(); 84 | return result; 85 | } 86 | 87 | static N_INLINE(NI, HEX21HEX24_107042)(NI h) { 88 | NI result; 89 | nimfr("!$", "hashes.nim") 90 | result = 0; 91 | nimln(60, "hashes.nim"); 92 | result = (NI)((NU64)(h) + (NU64)((NI)((NU64)(h) << (NU64)(((NI) 3))))); 93 | nimln(61, "hashes.nim"); 94 | result = (NI)(result ^ (NI)((NU64)(result) >> (NU64)(((NI) 11)))); 95 | nimln(62, "hashes.nim"); 96 | result = (NI)((NU64)(result) + (NU64)((NI)((NU64)(result) << (NU64)(((NI) 15))))); 97 | popFrame(); 98 | return result; 99 | } 100 | 101 | static N_INLINE(NI, addInt)(NI a, NI b) { 102 | NI result; 103 | { result = 0; 104 | result = (NI)((NU64)(a) + (NU64)(b)); 105 | { 106 | NIM_BOOL LOC3; 107 | LOC3 = 0; 108 | LOC3 = (((NI) 0) <= (NI)(result ^ a)); 109 | if (LOC3) goto LA4; 110 | LOC3 = (((NI) 0) <= (NI)(result ^ b)); 111 | LA4: ; 112 | if (!LOC3) goto LA5; 113 | goto BeforeRet; 114 | } 115 | LA5: ; 116 | raiseOverflow(); 117 | }BeforeRet: ; 118 | return result; 119 | } 120 | 121 | static N_INLINE(NI, subInt)(NI a, NI b) { 122 | NI result; 123 | { result = 0; 124 | result = (NI)((NU64)(a) - (NU64)(b)); 125 | { 126 | NIM_BOOL LOC3; 127 | LOC3 = 0; 128 | LOC3 = (((NI) 0) <= (NI)(result ^ a)); 129 | if (LOC3) goto LA4; 130 | LOC3 = (((NI) 0) <= (NI)(result ^ (NI)((NU64) ~(b)))); 131 | LA4: ; 132 | if (!LOC3) goto LA5; 133 | goto BeforeRet; 134 | } 135 | LA5: ; 136 | raiseOverflow(); 137 | }BeforeRet: ; 138 | return result; 139 | } 140 | 141 | N_NIMCALL(NI, hashdata_107070)(void* data, NI size) { 142 | NI result; 143 | NI h; 144 | NCSTRING p; 145 | NI i; 146 | NI s; 147 | nimfr("hashData", "hashes.nim") 148 | result = 0; 149 | nimln(66, "hashes.nim"); 150 | h = ((NI) 0); 151 | nimln(71, "hashes.nim"); 152 | p = ((NCSTRING) (data)); 153 | nimln(72, "hashes.nim"); 154 | i = ((NI) 0); 155 | nimln(73, "hashes.nim"); 156 | s = size; 157 | { 158 | nimln(74, "hashes.nim"); 159 | while (1) { 160 | NI TMP290; 161 | NI TMP291; 162 | nimln(357, "system.nim"); 163 | if (!(((NI) 0) < s)) goto LA2; 164 | nimln(75, "hashes.nim"); 165 | h = HEX21HEX26_107013(h, ((NI) (((NU8)(p[i]))))); 166 | nimln(76, "hashes.nim"); 167 | TMP290 = addInt(i, ((NI) 1)); 168 | i = (NI)(TMP290); 169 | nimln(77, "hashes.nim"); 170 | TMP291 = subInt(s, ((NI) 1)); 171 | s = (NI)(TMP291); 172 | } LA2: ; 173 | } 174 | nimln(78, "hashes.nim"); 175 | result = HEX21HEX24_107042(h); 176 | popFrame(); 177 | return result; 178 | } 179 | 180 | static N_INLINE(NI, hash_107401)(void* x) { 181 | NI result; 182 | nimfr("hash", "hashes.nim") 183 | result = 0; 184 | nimln(97, "hashes.nim"); 185 | result = (NI)((NU64)(((NI) (x))) >> (NU64)(((NI) 3))); 186 | popFrame(); 187 | return result; 188 | } 189 | 190 | static N_INLINE(NI, hash_107804)(NI x) { 191 | NI result; 192 | nimfr("hash", "hashes.nim") 193 | result = 0; 194 | nimln(109, "hashes.nim"); 195 | result = x; 196 | popFrame(); 197 | return result; 198 | } 199 | 200 | static N_INLINE(NI, hash_107814)(NI64 x) { 201 | NI result; 202 | nimfr("hash", "hashes.nim") 203 | result = 0; 204 | nimln(113, "hashes.nim"); 205 | result = ((NI) (((NI32)(NU32)(NU64)(x)))); 206 | popFrame(); 207 | return result; 208 | } 209 | 210 | static N_INLINE(NI, hash_107824)(NIM_CHAR x) { 211 | NI result; 212 | nimfr("hash", "hashes.nim") 213 | result = 0; 214 | nimln(117, "hashes.nim"); 215 | result = ((NI) (((NU8)(x)))); 216 | popFrame(); 217 | return result; 218 | } 219 | 220 | N_NIMCALL(NI, hash_107851)(NimStringDesc* x) { 221 | NI result; 222 | NI h; 223 | nimfr("hash", "hashes.nim") 224 | result = 0; 225 | nimln(125, "hashes.nim"); 226 | h = ((NI) 0); 227 | { 228 | NI i_107866; 229 | NI HEX3Atmp_107877; 230 | NI TMP292; 231 | NI res_107880; 232 | i_107866 = 0; 233 | HEX3Atmp_107877 = 0; 234 | nimln(126, "hashes.nim"); 235 | TMP292 = subInt((x ? x->Sup.len : 0), ((NI) 1)); 236 | HEX3Atmp_107877 = (NI)(TMP292); 237 | nimln(1874, "system.nim"); 238 | res_107880 = ((NI) 0); 239 | { 240 | nimln(1875, "system.nim"); 241 | while (1) { 242 | NI TMP293; 243 | if (!(res_107880 <= HEX3Atmp_107877)) goto LA3; 244 | nimln(1876, "system.nim"); 245 | i_107866 = res_107880; 246 | nimln(127, "hashes.nim"); 247 | if ((NU)(i_107866) > (NU)(x->Sup.len)) raiseIndexError(); 248 | h = HEX21HEX26_107013(h, ((NI) (((NU8)(x->data[i_107866]))))); 249 | nimln(1895, "system.nim"); 250 | TMP293 = addInt(res_107880, ((NI) 1)); 251 | res_107880 = (NI)(TMP293); 252 | } LA3: ; 253 | } 254 | } 255 | nimln(128, "hashes.nim"); 256 | result = HEX21HEX24_107042(h); 257 | popFrame(); 258 | return result; 259 | } 260 | 261 | N_NIMCALL(NI, hash_107899)(NimStringDesc* sbuf, NI spos, NI epos) { 262 | NI result; 263 | NI h; 264 | nimfr("hash", "hashes.nim") 265 | result = 0; 266 | nimln(135, "hashes.nim"); 267 | h = ((NI) 0); 268 | { 269 | NI i_107916; 270 | NI res_107929; 271 | i_107916 = 0; 272 | nimln(1874, "system.nim"); 273 | res_107929 = spos; 274 | { 275 | nimln(1875, "system.nim"); 276 | while (1) { 277 | NI TMP294; 278 | if (!(res_107929 <= epos)) goto LA3; 279 | nimln(1876, "system.nim"); 280 | i_107916 = res_107929; 281 | nimln(137, "hashes.nim"); 282 | if ((NU)(i_107916) > (NU)(sbuf->Sup.len)) raiseIndexError(); 283 | h = HEX21HEX26_107013(h, ((NI) (((NU8)(sbuf->data[i_107916]))))); 284 | nimln(1895, "system.nim"); 285 | TMP294 = addInt(res_107929, ((NI) 1)); 286 | res_107929 = (NI)(TMP294); 287 | } LA3: ; 288 | } 289 | } 290 | nimln(138, "hashes.nim"); 291 | result = HEX21HEX24_107042(h); 292 | popFrame(); 293 | return result; 294 | } 295 | 296 | static N_INLINE(NIM_BOOL, ismagicidentseparatorrune_106010)(NCSTRING cs, NI i) { 297 | NIM_BOOL result; 298 | NIM_BOOL LOC1; 299 | NIM_BOOL LOC2; 300 | NI TMP296; 301 | NI TMP297; 302 | nimfr("isMagicIdentSeparatorRune", "etcpriv.nim") 303 | result = 0; 304 | nimln(21, "etcpriv.nim"); 305 | nimln(22, "etcpriv.nim"); 306 | LOC1 = 0; 307 | nimln(21, "etcpriv.nim"); 308 | LOC2 = 0; 309 | LOC2 = ((NU8)(cs[i]) == (NU8)(226)); 310 | if (!(LOC2)) goto LA3; 311 | nimln(22, "etcpriv.nim"); 312 | TMP296 = addInt(i, ((NI) 1)); 313 | LOC2 = ((NU8)(cs[(NI)(TMP296)]) == (NU8)(128)); 314 | LA3: ; 315 | LOC1 = LOC2; 316 | if (!(LOC1)) goto LA4; 317 | nimln(23, "etcpriv.nim"); 318 | TMP297 = addInt(i, ((NI) 2)); 319 | LOC1 = ((NU8)(cs[(NI)(TMP297)]) == (NU8)(147)); 320 | LA4: ; 321 | result = LOC1; 322 | popFrame(); 323 | return result; 324 | } 325 | 326 | static N_INLINE(NI, chckRange)(NI i, NI a, NI b) { 327 | NI result; 328 | { result = 0; 329 | { 330 | NIM_BOOL LOC3; 331 | LOC3 = 0; 332 | LOC3 = (a <= i); 333 | if (!(LOC3)) goto LA4; 334 | LOC3 = (i <= b); 335 | LA4: ; 336 | if (!LOC3) goto LA5; 337 | result = i; 338 | goto BeforeRet; 339 | } 340 | goto LA1; 341 | LA5: ; 342 | { 343 | raiseRangeError(((NI64) (i))); 344 | } 345 | LA1: ; 346 | }BeforeRet: ; 347 | return result; 348 | } 349 | 350 | N_NIMCALL(NI, hashignorestyle_107948)(NimStringDesc* x) { 351 | NI result; 352 | NI h; 353 | NI i; 354 | NI xlen; 355 | nimfr("hashIgnoreStyle", "hashes.nim") 356 | result = 0; 357 | nimln(142, "hashes.nim"); 358 | h = ((NI) 0); 359 | nimln(143, "hashes.nim"); 360 | i = ((NI) 0); 361 | nimln(144, "hashes.nim"); 362 | xlen = (x ? x->Sup.len : 0); 363 | { 364 | nimln(145, "hashes.nim"); 365 | while (1) { 366 | NIM_CHAR c; 367 | if (!(i < xlen)) goto LA2; 368 | nimln(146, "hashes.nim"); 369 | if ((NU)(i) > (NU)(x->Sup.len)) raiseIndexError(); 370 | c = x->data[i]; 371 | nimln(147, "hashes.nim"); 372 | { 373 | NI TMP295; 374 | if (!((NU8)(c) == (NU8)(95))) goto LA5; 375 | nimln(148, "hashes.nim"); 376 | TMP295 = addInt(i, ((NI) 1)); 377 | i = (NI)(TMP295); 378 | } 379 | goto LA3; 380 | LA5: ; 381 | { 382 | NIM_BOOL LOC8; 383 | NI TMP298; 384 | nimln(149, "hashes.nim"); 385 | LOC8 = 0; 386 | LOC8 = ismagicidentseparatorrune_106010(x->data, i); 387 | if (!LOC8) goto LA9; 388 | nimln(150, "hashes.nim"); 389 | TMP298 = addInt(i, ((NI) 3)); 390 | i = (NI)(TMP298); 391 | } 392 | goto LA3; 393 | LA9: ; 394 | { 395 | NI TMP300; 396 | nimln(152, "hashes.nim"); 397 | { 398 | NI TMP299; 399 | nimln(1098, "system.nim"); 400 | if (!(((NU8)(c)) >= ((NU8)(65)) && ((NU8)(c)) <= ((NU8)(90)))) goto LA14; 401 | nimln(153, "hashes.nim"); 402 | TMP299 = addInt(((NI) (((NU8)(c)))), ((NI) 32)); 403 | c = ((NIM_CHAR) (((NI)chckRange((NI)(TMP299), ((NI) 0), ((NI) 255))))); 404 | } 405 | LA14: ; 406 | nimln(154, "hashes.nim"); 407 | h = HEX21HEX26_107013(h, ((NI) (((NU8)(c))))); 408 | nimln(155, "hashes.nim"); 409 | TMP300 = addInt(i, ((NI) 1)); 410 | i = (NI)(TMP300); 411 | } 412 | LA3: ; 413 | } LA2: ; 414 | } 415 | nimln(157, "hashes.nim"); 416 | result = HEX21HEX24_107042(h); 417 | popFrame(); 418 | return result; 419 | } 420 | 421 | N_NIMCALL(NI, hashignorestyle_108043)(NimStringDesc* sbuf, NI spos, NI epos) { 422 | NI result; 423 | NI h; 424 | NI i; 425 | nimfr("hashIgnoreStyle", "hashes.nim") 426 | result = 0; 427 | nimln(165, "hashes.nim"); 428 | h = ((NI) 0); 429 | nimln(166, "hashes.nim"); 430 | i = spos; 431 | { 432 | nimln(167, "hashes.nim"); 433 | while (1) { 434 | NIM_CHAR c; 435 | if (!(i <= epos)) goto LA2; 436 | nimln(168, "hashes.nim"); 437 | if ((NU)(i) > (NU)(sbuf->Sup.len)) raiseIndexError(); 438 | c = sbuf->data[i]; 439 | nimln(169, "hashes.nim"); 440 | { 441 | NI TMP301; 442 | if (!((NU8)(c) == (NU8)(95))) goto LA5; 443 | nimln(170, "hashes.nim"); 444 | TMP301 = addInt(i, ((NI) 1)); 445 | i = (NI)(TMP301); 446 | } 447 | goto LA3; 448 | LA5: ; 449 | { 450 | NIM_BOOL LOC8; 451 | NI TMP302; 452 | nimln(171, "hashes.nim"); 453 | LOC8 = 0; 454 | LOC8 = ismagicidentseparatorrune_106010(sbuf->data, i); 455 | if (!LOC8) goto LA9; 456 | nimln(172, "hashes.nim"); 457 | TMP302 = addInt(i, ((NI) 3)); 458 | i = (NI)(TMP302); 459 | } 460 | goto LA3; 461 | LA9: ; 462 | { 463 | NI TMP304; 464 | nimln(174, "hashes.nim"); 465 | { 466 | NI TMP303; 467 | nimln(1098, "system.nim"); 468 | if (!(((NU8)(c)) >= ((NU8)(65)) && ((NU8)(c)) <= ((NU8)(90)))) goto LA14; 469 | nimln(175, "hashes.nim"); 470 | TMP303 = addInt(((NI) (((NU8)(c)))), ((NI) 32)); 471 | c = ((NIM_CHAR) (((NI)chckRange((NI)(TMP303), ((NI) 0), ((NI) 255))))); 472 | } 473 | LA14: ; 474 | nimln(176, "hashes.nim"); 475 | h = HEX21HEX26_107013(h, ((NI) (((NU8)(c))))); 476 | nimln(177, "hashes.nim"); 477 | TMP304 = addInt(i, ((NI) 1)); 478 | i = (NI)(TMP304); 479 | } 480 | LA3: ; 481 | } LA2: ; 482 | } 483 | nimln(178, "hashes.nim"); 484 | result = HEX21HEX24_107042(h); 485 | popFrame(); 486 | return result; 487 | } 488 | 489 | N_NIMCALL(NI, hashignorecase_108139)(NimStringDesc* x) { 490 | NI result; 491 | NI h; 492 | nimfr("hashIgnoreCase", "hashes.nim") 493 | result = 0; 494 | nimln(182, "hashes.nim"); 495 | h = ((NI) 0); 496 | { 497 | NI i_108154; 498 | NI HEX3Atmp_108204; 499 | NI TMP305; 500 | NI res_108207; 501 | i_108154 = 0; 502 | HEX3Atmp_108204 = 0; 503 | nimln(183, "hashes.nim"); 504 | TMP305 = subInt((x ? x->Sup.len : 0), ((NI) 1)); 505 | HEX3Atmp_108204 = (NI)(TMP305); 506 | nimln(1874, "system.nim"); 507 | res_108207 = ((NI) 0); 508 | { 509 | nimln(1875, "system.nim"); 510 | while (1) { 511 | NIM_CHAR c; 512 | NI TMP307; 513 | if (!(res_108207 <= HEX3Atmp_108204)) goto LA3; 514 | nimln(1876, "system.nim"); 515 | i_108154 = res_108207; 516 | nimln(184, "hashes.nim"); 517 | if ((NU)(i_108154) > (NU)(x->Sup.len)) raiseIndexError(); 518 | c = x->data[i_108154]; 519 | nimln(185, "hashes.nim"); 520 | { 521 | NI TMP306; 522 | nimln(1098, "system.nim"); 523 | if (!(((NU8)(c)) >= ((NU8)(65)) && ((NU8)(c)) <= ((NU8)(90)))) goto LA6; 524 | nimln(186, "hashes.nim"); 525 | TMP306 = addInt(((NI) (((NU8)(c)))), ((NI) 32)); 526 | c = ((NIM_CHAR) (((NI)chckRange((NI)(TMP306), ((NI) 0), ((NI) 255))))); 527 | } 528 | LA6: ; 529 | nimln(187, "hashes.nim"); 530 | h = HEX21HEX26_107013(h, ((NI) (((NU8)(c))))); 531 | nimln(1895, "system.nim"); 532 | TMP307 = addInt(res_108207, ((NI) 1)); 533 | res_108207 = (NI)(TMP307); 534 | } LA3: ; 535 | } 536 | } 537 | nimln(188, "hashes.nim"); 538 | result = HEX21HEX24_107042(h); 539 | popFrame(); 540 | return result; 541 | } 542 | 543 | N_NIMCALL(NI, hashignorecase_108226)(NimStringDesc* sbuf, NI spos, NI epos) { 544 | NI result; 545 | NI h; 546 | nimfr("hashIgnoreCase", "hashes.nim") 547 | result = 0; 548 | nimln(196, "hashes.nim"); 549 | h = ((NI) 0); 550 | { 551 | NI i_108243; 552 | NI res_108295; 553 | i_108243 = 0; 554 | nimln(1874, "system.nim"); 555 | res_108295 = spos; 556 | { 557 | nimln(1875, "system.nim"); 558 | while (1) { 559 | NIM_CHAR c; 560 | NI TMP309; 561 | if (!(res_108295 <= epos)) goto LA3; 562 | nimln(1876, "system.nim"); 563 | i_108243 = res_108295; 564 | nimln(198, "hashes.nim"); 565 | if ((NU)(i_108243) > (NU)(sbuf->Sup.len)) raiseIndexError(); 566 | c = sbuf->data[i_108243]; 567 | nimln(199, "hashes.nim"); 568 | { 569 | NI TMP308; 570 | nimln(1098, "system.nim"); 571 | if (!(((NU8)(c)) >= ((NU8)(65)) && ((NU8)(c)) <= ((NU8)(90)))) goto LA6; 572 | nimln(200, "hashes.nim"); 573 | TMP308 = addInt(((NI) (((NU8)(c)))), ((NI) 32)); 574 | c = ((NIM_CHAR) (((NI)chckRange((NI)(TMP308), ((NI) 0), ((NI) 255))))); 575 | } 576 | LA6: ; 577 | nimln(201, "hashes.nim"); 578 | h = HEX21HEX26_107013(h, ((NI) (((NU8)(c))))); 579 | nimln(1895, "system.nim"); 580 | TMP309 = addInt(res_108295, ((NI) 1)); 581 | res_108295 = (NI)(TMP309); 582 | } LA3: ; 583 | } 584 | } 585 | nimln(202, "hashes.nim"); 586 | result = HEX21HEX24_107042(h); 587 | popFrame(); 588 | return result; 589 | } 590 | 591 | static N_INLINE(NI, hash_108314)(NF x) { 592 | NI result; 593 | NF y; 594 | nimfr("hash", "hashes.nim") 595 | result = 0; 596 | nimln(206, "hashes.nim"); 597 | y = ((NF)(x) + (NF)(1.0000000000000000e+00)); 598 | nimln(207, "hashes.nim"); 599 | result = (*((NI*) ((&y)))); 600 | popFrame(); 601 | return result; 602 | } 603 | NIM_EXTERNC N_NOINLINE(void, HEX00_hashesInit000)(void) { 604 | nimfr("hashes", "hashes.nim") 605 | popFrame(); 606 | } 607 | 608 | NIM_EXTERNC N_NOINLINE(void, HEX00_hashesDatInit000)(void) { 609 | } 610 | 611 | -------------------------------------------------------------------------------- /tests/nimcache/strutils.c: -------------------------------------------------------------------------------- 1 | /* Generated by Nim Compiler v0.12.0 */ 2 | /* (c) 2015 Andreas Rumpf */ 3 | /* The generated code is subject to the original license. */ 4 | /* Compiled for: Linux, amd64, gcc */ 5 | /* Command for C compiler: 6 | gcc -c -w -g3 -O0 -I/media/marco/Research/Applications/aporia/Nim/lib -o /home/marco/.nimble/pkgs/Pythonize27-1.0.0/tests/nimcache/strutils.o /home/marco/.nimble/pkgs/Pythonize27-1.0.0/tests/nimcache/strutils.c */ 7 | #define NIM_INTBITS 64 8 | 9 | #include "nimbase.h" 10 | #include 11 | typedef struct NimStringDesc NimStringDesc; 12 | typedef struct TGenericSeq TGenericSeq; 13 | typedef struct Valueerror4049 Valueerror4049; 14 | typedef struct Exception Exception; 15 | typedef struct TNimObject TNimObject; 16 | typedef struct TNimType TNimType; 17 | typedef struct TNimNode TNimNode; 18 | typedef struct Cell49347 Cell49347; 19 | typedef struct Cellseq49363 Cellseq49363; 20 | typedef struct Gcheap51418 Gcheap51418; 21 | typedef struct Gcstack51416 Gcstack51416; 22 | typedef struct Cellset49359 Cellset49359; 23 | typedef struct Pagedesc49355 Pagedesc49355; 24 | typedef struct Memregion31291 Memregion31291; 25 | typedef struct Smallchunk31243 Smallchunk31243; 26 | typedef struct Llchunk31285 Llchunk31285; 27 | typedef struct Bigchunk31245 Bigchunk31245; 28 | typedef struct Intset31217 Intset31217; 29 | typedef struct Trunk31213 Trunk31213; 30 | typedef struct Avlnode31289 Avlnode31289; 31 | typedef struct Gcstat51414 Gcstat51414; 32 | typedef struct Basechunk31241 Basechunk31241; 33 | typedef struct Freecell31233 Freecell31233; 34 | struct TGenericSeq { 35 | NI len; 36 | NI reserved; 37 | }; 38 | struct NimStringDesc { 39 | TGenericSeq Sup; 40 | NIM_CHAR data[SEQ_DECL_SIZE]; 41 | }; 42 | typedef N_NIMCALL_PTR(void, TY3889) (void* p, NI op); 43 | typedef N_NIMCALL_PTR(void*, TY3894) (void* p); 44 | struct TNimType { 45 | NI size; 46 | NU8 kind; 47 | NU8 flags; 48 | TNimType* base; 49 | TNimNode* node; 50 | void* finalizer; 51 | TY3889 marker; 52 | TY3894 deepcopy; 53 | }; 54 | struct TNimObject { 55 | TNimType* m_type; 56 | }; 57 | struct Exception { 58 | TNimObject Sup; 59 | Exception* parent; 60 | NCSTRING name; 61 | NimStringDesc* message; 62 | NimStringDesc* trace; 63 | }; 64 | struct Valueerror4049 { 65 | Exception Sup; 66 | }; 67 | struct TNimNode { 68 | NU8 kind; 69 | NI offset; 70 | TNimType* typ; 71 | NCSTRING name; 72 | NI len; 73 | TNimNode** sons; 74 | }; 75 | struct Cell49347 { 76 | NI refcount; 77 | TNimType* typ; 78 | }; 79 | struct Cellseq49363 { 80 | NI len; 81 | NI cap; 82 | Cell49347** d; 83 | }; 84 | struct Cellset49359 { 85 | NI counter; 86 | NI max; 87 | Pagedesc49355* head; 88 | Pagedesc49355** data; 89 | }; 90 | typedef Smallchunk31243* TY31306[512]; 91 | typedef Trunk31213* Trunkbuckets31215[256]; 92 | struct Intset31217 { 93 | Trunkbuckets31215 data; 94 | }; 95 | struct Memregion31291 { 96 | NI minlargeobj; 97 | NI maxlargeobj; 98 | TY31306 freesmallchunks; 99 | Llchunk31285* llmem; 100 | NI currmem; 101 | NI maxmem; 102 | NI freemem; 103 | NI lastsize; 104 | Bigchunk31245* freechunkslist; 105 | Intset31217 chunkstarts; 106 | Avlnode31289* root; 107 | Avlnode31289* deleted; 108 | Avlnode31289* last; 109 | Avlnode31289* freeavlnodes; 110 | }; 111 | struct Gcstat51414 { 112 | NI stackscans; 113 | NI cyclecollections; 114 | NI maxthreshold; 115 | NI maxstacksize; 116 | NI maxstackcells; 117 | NI cycletablesize; 118 | NI64 maxpause; 119 | }; 120 | struct Gcheap51418 { 121 | Gcstack51416* stack; 122 | void* stackbottom; 123 | NI cyclethreshold; 124 | Cellseq49363 zct; 125 | Cellseq49363 decstack; 126 | Cellset49359 cycleroots; 127 | Cellseq49363 tempstack; 128 | NI recgclock; 129 | Memregion31291 region; 130 | Gcstat51414 stat; 131 | }; 132 | struct Gcstack51416 { 133 | Gcstack51416* prev; 134 | Gcstack51416* next; 135 | void* starts; 136 | void* pos; 137 | NI maxstacksize; 138 | }; 139 | typedef NI TY31222[8]; 140 | struct Pagedesc49355 { 141 | Pagedesc49355* next; 142 | NI key; 143 | TY31222 bits; 144 | }; 145 | struct Basechunk31241 { 146 | NI prevsize; 147 | NI size; 148 | NIM_BOOL used; 149 | }; 150 | struct Smallchunk31243 { 151 | Basechunk31241 Sup; 152 | Smallchunk31243* next; 153 | Smallchunk31243* prev; 154 | Freecell31233* freelist; 155 | NI free; 156 | NI acc; 157 | NF data; 158 | }; 159 | struct Llchunk31285 { 160 | NI size; 161 | NI acc; 162 | Llchunk31285* next; 163 | }; 164 | struct Bigchunk31245 { 165 | Basechunk31241 Sup; 166 | Bigchunk31245* next; 167 | Bigchunk31245* prev; 168 | NI align; 169 | NF data; 170 | }; 171 | struct Trunk31213 { 172 | Trunk31213* next; 173 | NI key; 174 | TY31222 bits; 175 | }; 176 | typedef Avlnode31289* TY31296[2]; 177 | struct Avlnode31289 { 178 | TY31296 link; 179 | NI key; 180 | NI upperbound; 181 | NI level; 182 | }; 183 | struct Freecell31233 { 184 | Freecell31233* next; 185 | NI zerofield; 186 | }; 187 | N_NIMCALL(NimStringDesc*, nimIntToStr)(NI x); 188 | static N_INLINE(void, appendChar)(NimStringDesc* dest, NIM_CHAR c); 189 | static N_INLINE(void, appendString)(NimStringDesc* dest, NimStringDesc* src); 190 | N_NIMCALL(NimStringDesc*, rawNewString)(NI space); 191 | static N_INLINE(void, nimFrame)(TFrame* s); 192 | N_NOINLINE(void, stackoverflow_23601)(void); 193 | static N_INLINE(void, popFrame)(void); 194 | N_NIMCALL(NimStringDesc*, mnewString)(NI len); 195 | N_NIMCALL(NimStringDesc*, mnewString)(NI len); 196 | N_NIMCALL(NI, npuParseInt)(NimStringDesc* s, NI* number, NI start); 197 | N_NIMCALL(void*, newObj)(TNimType* typ, NI size); 198 | static N_INLINE(void, asgnRefNoCycle)(void** dest, void* src); 199 | static N_INLINE(Cell49347*, usrtocell_53046)(void* usr); 200 | static N_INLINE(void, rtladdzct_54604)(Cell49347* c); 201 | N_NOINLINE(void, addzct_53017)(Cellseq49363* s, Cell49347* c); 202 | N_NIMCALL(void, raiseException)(Exception* e, NCSTRING ename); 203 | static N_INLINE(NI, chckRange)(NI i, NI a, NI b); 204 | N_NOINLINE(void, raiseRangeError)(NI64 val); 205 | static N_INLINE(NI, subInt)(NI a, NI b); 206 | N_NOINLINE(void, raiseOverflow)(void); 207 | N_NOINLINE(void, raiseIndexError)(void); 208 | N_NIMCALL(NIM_CHAR, nsuToLowerChar)(NIM_CHAR c); 209 | static N_INLINE(NI, addInt)(NI a, NI b); 210 | N_NIMCALL(NIM_CHAR, nsuToUpperChar)(NIM_CHAR c); 211 | STRING_LITERAL(TMP399, "invalid integer: ", 17); 212 | extern TFrame* frameptr_20842; 213 | extern TNimType NTI25428; /* ref ValueError */ 214 | extern TNimType NTI4049; /* ValueError */ 215 | extern Gcheap51418 gch_51459; 216 | 217 | static N_INLINE(void, appendChar)(NimStringDesc* dest, NIM_CHAR c) { 218 | (*dest).data[((*dest).Sup.len)- 0] = c; 219 | (*dest).data[((NI)((*dest).Sup.len + ((NI) 1)))- 0] = 0; 220 | (*dest).Sup.len += ((NI) 1); 221 | } 222 | 223 | static N_INLINE(void, appendString)(NimStringDesc* dest, NimStringDesc* src) { 224 | memcpy(((NCSTRING) ((&(*dest).data[((*dest).Sup.len)- 0]))), ((NCSTRING) ((*src).data)), (NI)((*src).Sup.len + ((NI) 1))); 225 | (*dest).Sup.len += (*src).Sup.len; 226 | } 227 | 228 | static N_INLINE(void, nimFrame)(TFrame* s) { 229 | NI LOC1; 230 | LOC1 = 0; 231 | { 232 | if (!(frameptr_20842 == NIM_NIL)) goto LA4; 233 | LOC1 = ((NI) 0); 234 | } 235 | goto LA2; 236 | LA4: ; 237 | { 238 | LOC1 = ((NI) ((NI16)((*frameptr_20842).calldepth + ((NI16) 1)))); 239 | } 240 | LA2: ; 241 | (*s).calldepth = ((NI16) (LOC1)); 242 | (*s).prev = frameptr_20842; 243 | frameptr_20842 = s; 244 | { 245 | if (!((*s).calldepth == ((NI16) 2000))) goto LA9; 246 | stackoverflow_23601(); 247 | } 248 | LA9: ; 249 | } 250 | 251 | static N_INLINE(void, popFrame)(void) { 252 | frameptr_20842 = (*frameptr_20842).prev; 253 | } 254 | 255 | N_NIMCALL(NimStringDesc*, nsuIntToStr)(NI x, NI minchars) { 256 | NimStringDesc* result; 257 | nimfr("intToStr", "strutils.nim") 258 | result = 0; 259 | result = nimIntToStr((x > 0? (x) : -(x))); 260 | { 261 | NI i_101062; 262 | NI HEX3Atmp_101064; 263 | NI res_101067; 264 | i_101062 = 0; 265 | HEX3Atmp_101064 = 0; 266 | HEX3Atmp_101064 = (NI)(((NI) (minchars)) - (result ? result->Sup.len : 0)); 267 | res_101067 = ((NI) 1); 268 | { 269 | while (1) { 270 | NimStringDesc* LOC4; 271 | if (!(res_101067 <= HEX3Atmp_101064)) goto LA3; 272 | i_101062 = res_101067; 273 | LOC4 = 0; 274 | LOC4 = rawNewString(result->Sup.len + 1); 275 | appendChar(LOC4, 48); 276 | appendString(LOC4, result); 277 | result = LOC4; 278 | res_101067 += ((NI) 1); 279 | } LA3: ; 280 | } 281 | } 282 | { 283 | NimStringDesc* LOC9; 284 | if (!(x < ((NI) 0))) goto LA7; 285 | LOC9 = 0; 286 | LOC9 = rawNewString(result->Sup.len + 1); 287 | appendChar(LOC9, 45); 288 | appendString(LOC9, result); 289 | result = LOC9; 290 | } 291 | LA7: ; 292 | popFrame(); 293 | return result; 294 | } 295 | 296 | N_NIMCALL(NimStringDesc*, nsuRepeatChar)(NIM_CHAR c, NI count) { 297 | NimStringDesc* result; 298 | nimfr("repeat", "strutils.nim") 299 | result = 0; 300 | result = mnewString(count); 301 | { 302 | NI i_101378; 303 | NI HEX3Atmp_101380; 304 | NI res_101383; 305 | i_101378 = 0; 306 | HEX3Atmp_101380 = 0; 307 | HEX3Atmp_101380 = (NI)(((NI) (count)) - ((NI) 1)); 308 | res_101383 = ((NI) 0); 309 | { 310 | while (1) { 311 | if (!(res_101383 <= ((NI) (HEX3Atmp_101380)))) goto LA3; 312 | i_101378 = ((NI) (res_101383)); 313 | result->data[i_101378] = c; 314 | res_101383 += ((NI) 1); 315 | } LA3: ; 316 | } 317 | } 318 | popFrame(); 319 | return result; 320 | } 321 | 322 | static N_INLINE(Cell49347*, usrtocell_53046)(void* usr) { 323 | Cell49347* result; 324 | nimfr("usrToCell", "gc.nim") 325 | result = 0; 326 | nimln(131, "gc.nim"); 327 | result = ((Cell49347*) ((NI)((NU64)(((NI) (usr))) - (NU64)(((NI)sizeof(Cell49347)))))); 328 | popFrame(); 329 | return result; 330 | } 331 | 332 | static N_INLINE(void, rtladdzct_54604)(Cell49347* c) { 333 | nimfr("rtlAddZCT", "gc.nim") 334 | nimln(212, "gc.nim"); 335 | addzct_53017((&gch_51459.zct), c); 336 | popFrame(); 337 | } 338 | 339 | static N_INLINE(void, asgnRefNoCycle)(void** dest, void* src) { 340 | nimfr("asgnRefNoCycle", "gc.nim") 341 | nimln(264, "gc.nim"); 342 | { 343 | Cell49347* c; 344 | nimln(349, "system.nim"); 345 | if (!!((src == NIM_NIL))) goto LA3; 346 | nimln(265, "gc.nim"); 347 | c = usrtocell_53046(src); 348 | nimln(182, "gc.nim"); 349 | (*c).refcount += ((NI) 8); 350 | } 351 | LA3: ; 352 | nimln(267, "gc.nim"); 353 | { 354 | Cell49347* c; 355 | nimln(349, "system.nim"); 356 | if (!!(((*dest) == NIM_NIL))) goto LA7; 357 | nimln(268, "gc.nim"); 358 | c = usrtocell_53046((*dest)); 359 | nimln(269, "gc.nim"); 360 | { 361 | nimln(180, "gc.nim"); 362 | (*c).refcount -= ((NI) 8); 363 | nimln(181, "gc.nim"); 364 | if (!((NU64)((*c).refcount) < (NU64)(((NI) 8)))) goto LA11; 365 | nimln(270, "gc.nim"); 366 | rtladdzct_54604(c); 367 | } 368 | LA11: ; 369 | } 370 | LA7: ; 371 | nimln(271, "gc.nim"); 372 | (*dest) = src; 373 | popFrame(); 374 | } 375 | 376 | N_NIMCALL(NI, nsuParseInt)(NimStringDesc* s) { 377 | NI result; 378 | NI L; 379 | nimfr("parseInt", "strutils.nim") 380 | result = 0; 381 | L = npuParseInt(s, (&result), ((NI) 0)); 382 | { 383 | NIM_BOOL LOC3; 384 | Valueerror4049* e_101095; 385 | NimStringDesc* LOC7; 386 | LOC3 = 0; 387 | LOC3 = !((L == (s ? s->Sup.len : 0))); 388 | if (LOC3) goto LA4; 389 | LOC3 = (L == ((NI) 0)); 390 | LA4: ; 391 | if (!LOC3) goto LA5; 392 | e_101095 = 0; 393 | e_101095 = (Valueerror4049*) newObj((&NTI25428), sizeof(Valueerror4049)); 394 | (*e_101095).Sup.Sup.m_type = (&NTI4049); 395 | LOC7 = 0; 396 | LOC7 = rawNewString(s->Sup.len + 17); 397 | appendString(LOC7, ((NimStringDesc*) &TMP399)); 398 | appendString(LOC7, s); 399 | asgnRefNoCycle((void**) (&(*e_101095).Sup.message), LOC7); 400 | raiseException((Exception*)e_101095, "ValueError"); 401 | } 402 | LA5: ; 403 | popFrame(); 404 | return result; 405 | } 406 | 407 | static N_INLINE(NI, chckRange)(NI i, NI a, NI b) { 408 | NI result; 409 | { result = 0; 410 | { 411 | NIM_BOOL LOC3; 412 | LOC3 = 0; 413 | LOC3 = (a <= i); 414 | if (!(LOC3)) goto LA4; 415 | LOC3 = (i <= b); 416 | LA4: ; 417 | if (!LOC3) goto LA5; 418 | result = i; 419 | goto BeforeRet; 420 | } 421 | goto LA1; 422 | LA5: ; 423 | { 424 | raiseRangeError(((NI64) (i))); 425 | } 426 | LA1: ; 427 | }BeforeRet: ; 428 | return result; 429 | } 430 | 431 | static N_INLINE(NI, subInt)(NI a, NI b) { 432 | NI result; 433 | { result = 0; 434 | result = (NI)((NU64)(a) - (NU64)(b)); 435 | { 436 | NIM_BOOL LOC3; 437 | LOC3 = 0; 438 | LOC3 = (((NI) 0) <= (NI)(result ^ a)); 439 | if (LOC3) goto LA4; 440 | LOC3 = (((NI) 0) <= (NI)(result ^ (NI)((NU64) ~(b)))); 441 | LA4: ; 442 | if (!LOC3) goto LA5; 443 | goto BeforeRet; 444 | } 445 | LA5: ; 446 | raiseOverflow(); 447 | }BeforeRet: ; 448 | return result; 449 | } 450 | 451 | static N_INLINE(NI, addInt)(NI a, NI b) { 452 | NI result; 453 | { result = 0; 454 | result = (NI)((NU64)(a) + (NU64)(b)); 455 | { 456 | NIM_BOOL LOC3; 457 | LOC3 = 0; 458 | LOC3 = (((NI) 0) <= (NI)(result ^ a)); 459 | if (LOC3) goto LA4; 460 | LOC3 = (((NI) 0) <= (NI)(result ^ b)); 461 | LA4: ; 462 | if (!LOC3) goto LA5; 463 | goto BeforeRet; 464 | } 465 | LA5: ; 466 | raiseOverflow(); 467 | }BeforeRet: ; 468 | return result; 469 | } 470 | 471 | N_NIMCALL(NIM_CHAR, nsuToLowerChar)(NIM_CHAR c) { 472 | NIM_CHAR result; 473 | nimfr("toLower", "strutils.nim") 474 | result = 0; 475 | nimln(198, "strutils.nim"); 476 | { 477 | NI TMP401; 478 | nimln(1098, "system.nim"); 479 | if (!(((NU8)(c)) >= ((NU8)(65)) && ((NU8)(c)) <= ((NU8)(90)))) goto LA3; 480 | nimln(199, "strutils.nim"); 481 | TMP401 = addInt(((NI) (((NU8)(c)))), ((NI) 32)); 482 | result = ((NIM_CHAR) (((NI)chckRange((NI)(TMP401), ((NI) 0), ((NI) 255))))); 483 | } 484 | goto LA1; 485 | LA3: ; 486 | { 487 | nimln(201, "strutils.nim"); 488 | result = c; 489 | } 490 | LA1: ; 491 | popFrame(); 492 | return result; 493 | } 494 | 495 | N_NIMCALL(NimStringDesc*, nsuToLowerStr)(NimStringDesc* s) { 496 | NimStringDesc* result; 497 | nimfr("toLower", "strutils.nim") 498 | result = 0; 499 | nimln(210, "strutils.nim"); 500 | result = mnewString(((NI)chckRange((s ? s->Sup.len : 0), ((NI) 0), ((NI) IL64(9223372036854775807))))); 501 | { 502 | NI i_99592; 503 | NI HEX3Atmp_99594; 504 | NI TMP400; 505 | NI res_99597; 506 | i_99592 = 0; 507 | HEX3Atmp_99594 = 0; 508 | nimln(211, "strutils.nim"); 509 | TMP400 = subInt((s ? s->Sup.len : 0), ((NI) 1)); 510 | HEX3Atmp_99594 = (NI)(TMP400); 511 | nimln(1874, "system.nim"); 512 | res_99597 = ((NI) 0); 513 | { 514 | nimln(1875, "system.nim"); 515 | while (1) { 516 | NI TMP402; 517 | if (!(res_99597 <= HEX3Atmp_99594)) goto LA3; 518 | nimln(1876, "system.nim"); 519 | i_99592 = res_99597; 520 | nimln(212, "strutils.nim"); 521 | if ((NU)(i_99592) > (NU)(result->Sup.len)) raiseIndexError(); 522 | if ((NU)(i_99592) > (NU)(s->Sup.len)) raiseIndexError(); 523 | result->data[i_99592] = nsuToLowerChar(s->data[i_99592]); 524 | nimln(1895, "system.nim"); 525 | TMP402 = addInt(res_99597, ((NI) 1)); 526 | res_99597 = (NI)(TMP402); 527 | } LA3: ; 528 | } 529 | } 530 | popFrame(); 531 | return result; 532 | } 533 | 534 | N_NIMCALL(NI, nsuCmpIgnoreCase)(NimStringDesc* a, NimStringDesc* b) { 535 | NI result; 536 | NI i; 537 | NI m; 538 | NI TMP413; 539 | nimfr("cmpIgnoreCase", "strutils.nim") 540 | { result = 0; 541 | nimln(268, "strutils.nim"); 542 | i = ((NI) 0); 543 | nimln(269, "strutils.nim"); 544 | m = (((a ? a->Sup.len : 0) <= (b ? b->Sup.len : 0)) ? (a ? a->Sup.len : 0) : (b ? b->Sup.len : 0)); 545 | { 546 | nimln(270, "strutils.nim"); 547 | while (1) { 548 | NIM_CHAR LOC3; 549 | NIM_CHAR LOC4; 550 | NI TMP411; 551 | NI TMP412; 552 | if (!(i < m)) goto LA2; 553 | nimln(271, "strutils.nim"); 554 | if ((NU)(i) > (NU)(a->Sup.len)) raiseIndexError(); 555 | LOC3 = 0; 556 | LOC3 = nsuToLowerChar(a->data[i]); 557 | if ((NU)(i) > (NU)(b->Sup.len)) raiseIndexError(); 558 | LOC4 = 0; 559 | LOC4 = nsuToLowerChar(b->data[i]); 560 | TMP411 = subInt(((NI) (((NU8)(LOC3)))), ((NI) (((NU8)(LOC4))))); 561 | result = (NI)(TMP411); 562 | nimln(272, "strutils.nim"); 563 | { 564 | nimln(349, "system.nim"); 565 | if (!!((result == ((NI) 0)))) goto LA7; 566 | nimln(272, "strutils.nim"); 567 | goto BeforeRet; 568 | } 569 | LA7: ; 570 | nimln(273, "strutils.nim"); 571 | TMP412 = addInt(i, ((NI) 1)); 572 | i = (NI)(TMP412); 573 | } LA2: ; 574 | } 575 | nimln(274, "strutils.nim"); 576 | TMP413 = subInt((a ? a->Sup.len : 0), (b ? b->Sup.len : 0)); 577 | result = (NI)(TMP413); 578 | }BeforeRet: ; 579 | popFrame(); 580 | return result; 581 | } 582 | 583 | N_NIMCALL(NIM_CHAR, nsuToUpperChar)(NIM_CHAR c) { 584 | NIM_CHAR result; 585 | nimfr("toUpper", "strutils.nim") 586 | result = 0; 587 | nimln(221, "strutils.nim"); 588 | { 589 | NI TMP451; 590 | nimln(1098, "system.nim"); 591 | if (!(((NU8)(c)) >= ((NU8)(97)) && ((NU8)(c)) <= ((NU8)(122)))) goto LA3; 592 | nimln(222, "strutils.nim"); 593 | TMP451 = subInt(((NI) (((NU8)(c)))), ((NI) 32)); 594 | result = ((NIM_CHAR) (((NI)chckRange((NI)(TMP451), ((NI) 0), ((NI) 255))))); 595 | } 596 | goto LA1; 597 | LA3: ; 598 | { 599 | nimln(224, "strutils.nim"); 600 | result = c; 601 | } 602 | LA1: ; 603 | popFrame(); 604 | return result; 605 | } 606 | 607 | N_NIMCALL(NimStringDesc*, nsuToUpperStr)(NimStringDesc* s) { 608 | NimStringDesc* result; 609 | nimfr("toUpper", "strutils.nim") 610 | result = 0; 611 | nimln(233, "strutils.nim"); 612 | result = mnewString(((NI)chckRange((s ? s->Sup.len : 0), ((NI) 0), ((NI) IL64(9223372036854775807))))); 613 | { 614 | NI i_99678; 615 | NI HEX3Atmp_99680; 616 | NI TMP450; 617 | NI res_99683; 618 | i_99678 = 0; 619 | HEX3Atmp_99680 = 0; 620 | nimln(234, "strutils.nim"); 621 | TMP450 = subInt((s ? s->Sup.len : 0), ((NI) 1)); 622 | HEX3Atmp_99680 = (NI)(TMP450); 623 | nimln(1874, "system.nim"); 624 | res_99683 = ((NI) 0); 625 | { 626 | nimln(1875, "system.nim"); 627 | while (1) { 628 | NI TMP452; 629 | if (!(res_99683 <= HEX3Atmp_99680)) goto LA3; 630 | nimln(1876, "system.nim"); 631 | i_99678 = res_99683; 632 | nimln(235, "strutils.nim"); 633 | if ((NU)(i_99678) > (NU)(result->Sup.len)) raiseIndexError(); 634 | if ((NU)(i_99678) > (NU)(s->Sup.len)) raiseIndexError(); 635 | result->data[i_99678] = nsuToUpperChar(s->data[i_99678]); 636 | nimln(1895, "system.nim"); 637 | TMP452 = addInt(res_99683, ((NI) 1)); 638 | res_99683 = (NI)(TMP452); 639 | } LA3: ; 640 | } 641 | } 642 | popFrame(); 643 | return result; 644 | } 645 | NIM_EXTERNC N_NOINLINE(void, HEX00_strutilsInit000)(void) { 646 | nimfr("strutils", "strutils.nim") 647 | popFrame(); 648 | } 649 | 650 | NIM_EXTERNC N_NOINLINE(void, HEX00_strutilsDatInit000)(void) { 651 | } 652 | 653 | -------------------------------------------------------------------------------- /tests/nimcache/pythonize_md5_python.c: -------------------------------------------------------------------------------- 1 | /* Generated by Nim Compiler v0.12.0 */ 2 | /* (c) 2015 Andreas Rumpf */ 3 | /* The generated code is subject to the original license. */ 4 | /* Compiled for: Linux, amd64, gcc */ 5 | /* Command for C compiler: 6 | gcc -c -w -g3 -O0 -I/media/marco/Research/Applications/aporia/Nim/lib -o nimcache/pythonize_md5_python.o nimcache/pythonize_md5_python.c */ 7 | #define NIM_INTBITS 64 8 | 9 | #include "nimbase.h" 10 | #include 11 | #include 12 | typedef struct NimStringDesc NimStringDesc; 13 | typedef struct TGenericSeq TGenericSeq; 14 | typedef struct Memregion31291 Memregion31291; 15 | typedef struct Gcheap51418 Gcheap51418; 16 | typedef struct Gcstack51416 Gcstack51416; 17 | typedef struct Cellseq49363 Cellseq49363; 18 | typedef struct Cell49347 Cell49347; 19 | typedef struct Cellset49359 Cellset49359; 20 | typedef struct Pagedesc49355 Pagedesc49355; 21 | typedef struct Smallchunk31243 Smallchunk31243; 22 | typedef struct Llchunk31285 Llchunk31285; 23 | typedef struct Bigchunk31245 Bigchunk31245; 24 | typedef struct Intset31217 Intset31217; 25 | typedef struct Trunk31213 Trunk31213; 26 | typedef struct Avlnode31289 Avlnode31289; 27 | typedef struct Gcstat51414 Gcstat51414; 28 | typedef struct TNimType TNimType; 29 | typedef struct Tpyobject96574 Tpyobject96574; 30 | typedef struct Tpytypeobject96626 Tpytypeobject96626; 31 | typedef struct Tpynumbermethods96556 Tpynumbermethods96556; 32 | typedef struct Tpysequencemethods96560 Tpysequencemethods96560; 33 | typedef struct Tpymappingmethods96564 Tpymappingmethods96564; 34 | typedef struct Tpybufferprocs96568 Tpybufferprocs96568; 35 | typedef struct Tpymethoddef96586 Tpymethoddef96586; 36 | typedef struct Tpymemberdef96590 Tpymemberdef96590; 37 | typedef struct Tpygetsetdef96598 Tpygetsetdef96598; 38 | typedef struct Basechunk31241 Basechunk31241; 39 | typedef struct Freecell31233 Freecell31233; 40 | typedef struct TNimNode TNimNode; 41 | typedef N_CDECL_PTR(void, TY97559) (void); 42 | struct TGenericSeq { 43 | NI len; 44 | NI reserved; 45 | }; 46 | struct NimStringDesc { 47 | TGenericSeq Sup; 48 | NIM_CHAR data[SEQ_DECL_SIZE]; 49 | }; 50 | struct Cellseq49363 { 51 | NI len; 52 | NI cap; 53 | Cell49347** d; 54 | }; 55 | struct Cellset49359 { 56 | NI counter; 57 | NI max; 58 | Pagedesc49355* head; 59 | Pagedesc49355** data; 60 | }; 61 | typedef Smallchunk31243* TY31306[512]; 62 | typedef Trunk31213* Trunkbuckets31215[256]; 63 | struct Intset31217 { 64 | Trunkbuckets31215 data; 65 | }; 66 | struct Memregion31291 { 67 | NI minlargeobj; 68 | NI maxlargeobj; 69 | TY31306 freesmallchunks; 70 | Llchunk31285* llmem; 71 | NI currmem; 72 | NI maxmem; 73 | NI freemem; 74 | NI lastsize; 75 | Bigchunk31245* freechunkslist; 76 | Intset31217 chunkstarts; 77 | Avlnode31289* root; 78 | Avlnode31289* deleted; 79 | Avlnode31289* last; 80 | Avlnode31289* freeavlnodes; 81 | }; 82 | struct Gcstat51414 { 83 | NI stackscans; 84 | NI cyclecollections; 85 | NI maxthreshold; 86 | NI maxstacksize; 87 | NI maxstackcells; 88 | NI cycletablesize; 89 | NI64 maxpause; 90 | }; 91 | struct Gcheap51418 { 92 | Gcstack51416* stack; 93 | void* stackbottom; 94 | NI cyclethreshold; 95 | Cellseq49363 zct; 96 | Cellseq49363 decstack; 97 | Cellset49359 cycleroots; 98 | Cellseq49363 tempstack; 99 | NI recgclock; 100 | Memregion31291 region; 101 | Gcstat51414 stat; 102 | }; 103 | struct Cell49347 { 104 | NI refcount; 105 | TNimType* typ; 106 | }; 107 | typedef N_CDECL_PTR(Tpyobject96574*, TY97702) (NCSTRING str); 108 | typedef N_CDECL_PTR(Tpyobject96574*, TY97880) (NCSTRING name); 109 | typedef N_CDECL_PTR(Tpyobject96574*, TY97669) (Tpyobject96574* module); 110 | typedef N_CDECL_PTR(NI, TY97655) (Tpyobject96574* dp, NCSTRING key, Tpyobject96574* item); 111 | typedef N_CDECL_PTR(NI, TY97690) (NCSTRING str); 112 | typedef N_CDECL_PTR(Tpyobject96574*, TY97648) (Tpyobject96574* dp, NCSTRING key); 113 | typedef N_CDECL_PTR(NCSTRING, TY97696) (Tpyobject96574* ob); 114 | struct Tpyobject96574 { 115 | NI obrefcnt; 116 | Tpytypeobject96626* obtype; 117 | }; 118 | typedef N_CDECL_PTR(void, Tpydestructor96508) (Tpyobject96574* ob); 119 | typedef N_CDECL_PTR(NI, Tprintfunc96510) (Tpyobject96574* ob, FILE* f, NI i); 120 | typedef N_CDECL_PTR(Tpyobject96574*, Tgetattrfunc96512) (Tpyobject96574* ob1, NCSTRING name); 121 | typedef N_CDECL_PTR(NI, Tsetattrfunc96514) (Tpyobject96574* ob1, NCSTRING name, Tpyobject96574* ob2); 122 | typedef N_CDECL_PTR(NI, Tcmpfunc96516) (Tpyobject96574* ob1, Tpyobject96574* ob2); 123 | typedef N_CDECL_PTR(Tpyobject96574*, Treprfunc96518) (Tpyobject96574* ob); 124 | typedef N_CDECL_PTR(NI32, Thashfunc96520) (Tpyobject96574* ob); 125 | typedef N_CDECL_PTR(Tpyobject96574*, Tternaryfunc96492) (Tpyobject96574* ob1, Tpyobject96574* ob2, Tpyobject96574* ob3); 126 | typedef N_CDECL_PTR(Tpyobject96574*, Tgetattrofunc96522) (Tpyobject96574* ob1, Tpyobject96574* ob2); 127 | typedef N_CDECL_PTR(NI, Tsetattrofunc96524) (Tpyobject96574* ob1, Tpyobject96574* ob2, Tpyobject96574* ob3); 128 | typedef N_CDECL_PTR(NI, Tvisitproc96536) (Tpyobject96574* ob1, void* p); 129 | typedef N_CDECL_PTR(NI, Ttraverseproc96538) (Tpyobject96574* ob1, Tvisitproc96536 prc, void* p); 130 | typedef N_CDECL_PTR(NI, Tinquiry96494) (Tpyobject96574* ob1); 131 | typedef N_CDECL_PTR(Tpyobject96574*, Trichcmpfunc96540) (Tpyobject96574* ob1, Tpyobject96574* ob2, NI i); 132 | typedef N_CDECL_PTR(Tpyobject96574*, Tgetiterfunc96542) (Tpyobject96574* ob1); 133 | typedef N_CDECL_PTR(Tpyobject96574*, Titernextfunc96544) (Tpyobject96574* ob1); 134 | typedef N_CDECL_PTR(Tpyobject96574*, Tdescrgetfunc96546) (Tpyobject96574* ob1, Tpyobject96574* ob2, Tpyobject96574* ob3); 135 | typedef N_CDECL_PTR(NI, Tdescrsetfunc96548) (Tpyobject96574* ob1, Tpyobject96574* ob2, Tpyobject96574* ob3); 136 | typedef N_CDECL_PTR(NI, Tinitproc96550) (Tpyobject96574* self, Tpyobject96574* args, Tpyobject96574* kwds); 137 | typedef N_CDECL_PTR(Tpyobject96574*, Tallocfunc96554) (Tpytypeobject96626* self, NI nitems); 138 | typedef N_CDECL_PTR(Tpyobject96574*, Tnewfunc96552) (Tpytypeobject96626* subtype, Tpyobject96574* args, Tpyobject96574* kwds); 139 | struct Tpytypeobject96626 { 140 | Tpyobject96574 Sup; 141 | NI obsize; 142 | NCSTRING tpname; 143 | NI tpbasicsize; 144 | NI tpitemsize; 145 | Tpydestructor96508 tpdealloc; 146 | Tprintfunc96510 tpprint; 147 | Tgetattrfunc96512 tpgetattr; 148 | Tsetattrfunc96514 tpsetattr; 149 | Tcmpfunc96516 tpcompare; 150 | Treprfunc96518 tprepr; 151 | Tpynumbermethods96556* tpasnumber; 152 | Tpysequencemethods96560* tpassequence; 153 | Tpymappingmethods96564* tpasmapping; 154 | Thashfunc96520 tphash; 155 | Tternaryfunc96492 tpcall; 156 | Treprfunc96518 tpstr; 157 | Tgetattrofunc96522 tpgetattro; 158 | Tsetattrofunc96524 tpsetattro; 159 | Tpybufferprocs96568* tpasbuffer; 160 | NI32 tpflags; 161 | NCSTRING tpdoc; 162 | Ttraverseproc96538 tptraverse; 163 | Tinquiry96494 tpclear; 164 | Trichcmpfunc96540 tprichcompare; 165 | NI32 tpweaklistoffset; 166 | Tgetiterfunc96542 tpiter; 167 | Titernextfunc96544 tpiternext; 168 | Tpymethoddef96586* tpmethods; 169 | Tpymemberdef96590* tpmembers; 170 | Tpygetsetdef96598* tpgetset; 171 | Tpytypeobject96626* tpbase; 172 | Tpyobject96574* tpdict; 173 | Tdescrgetfunc96546 tpdescrget; 174 | Tdescrsetfunc96548 tpdescrset; 175 | NI32 tpdictoffset; 176 | Tinitproc96550 tpinit; 177 | Tallocfunc96554 tpalloc; 178 | Tnewfunc96552 tpnew; 179 | Tpydestructor96508 tpfree; 180 | Tinquiry96494 tpisgc; 181 | Tpyobject96574* tpbases; 182 | Tpyobject96574* tpmro; 183 | Tpyobject96574* tpcache; 184 | Tpyobject96574* tpsubclasses; 185 | Tpyobject96574* tpweaklist; 186 | void* tpxxx7; 187 | void* tpxxx8; 188 | }; 189 | typedef N_CDECL_PTR(void, TY98892) (void); 190 | struct Gcstack51416 { 191 | Gcstack51416* prev; 192 | Gcstack51416* next; 193 | void* starts; 194 | void* pos; 195 | NI maxstacksize; 196 | }; 197 | typedef NI TY31222[8]; 198 | struct Pagedesc49355 { 199 | Pagedesc49355* next; 200 | NI key; 201 | TY31222 bits; 202 | }; 203 | struct Basechunk31241 { 204 | NI prevsize; 205 | NI size; 206 | NIM_BOOL used; 207 | }; 208 | struct Smallchunk31243 { 209 | Basechunk31241 Sup; 210 | Smallchunk31243* next; 211 | Smallchunk31243* prev; 212 | Freecell31233* freelist; 213 | NI free; 214 | NI acc; 215 | NF data; 216 | }; 217 | struct Llchunk31285 { 218 | NI size; 219 | NI acc; 220 | Llchunk31285* next; 221 | }; 222 | struct Bigchunk31245 { 223 | Basechunk31241 Sup; 224 | Bigchunk31245* next; 225 | Bigchunk31245* prev; 226 | NI align; 227 | NF data; 228 | }; 229 | struct Trunk31213 { 230 | Trunk31213* next; 231 | NI key; 232 | TY31222 bits; 233 | }; 234 | typedef Avlnode31289* TY31296[2]; 235 | struct Avlnode31289 { 236 | TY31296 link; 237 | NI key; 238 | NI upperbound; 239 | NI level; 240 | }; 241 | typedef N_NIMCALL_PTR(void, TY3889) (void* p, NI op); 242 | typedef N_NIMCALL_PTR(void*, TY3894) (void* p); 243 | struct TNimType { 244 | NI size; 245 | NU8 kind; 246 | NU8 flags; 247 | TNimType* base; 248 | TNimNode* node; 249 | void* finalizer; 250 | TY3889 marker; 251 | TY3894 deepcopy; 252 | }; 253 | typedef N_CDECL_PTR(Tpyobject96574*, Tbinaryfunc96490) (Tpyobject96574* ob1, Tpyobject96574* ob2); 254 | typedef N_CDECL_PTR(Tpyobject96574*, Tunaryfunc96488) (Tpyobject96574* ob1); 255 | typedef N_CDECL_PTR(NI, Tcoercion96496) (Tpyobject96574** ob1, Tpyobject96574** ob2); 256 | struct Tpynumbermethods96556 { 257 | Tbinaryfunc96490 nbadd; 258 | Tbinaryfunc96490 nbsubstract; 259 | Tbinaryfunc96490 nbmultiply; 260 | Tbinaryfunc96490 nbdivide; 261 | Tbinaryfunc96490 nbremainder; 262 | Tbinaryfunc96490 nbdivmod; 263 | Tternaryfunc96492 nbpower; 264 | Tunaryfunc96488 nbnegative; 265 | Tunaryfunc96488 nbpositive; 266 | Tunaryfunc96488 nbabsolute; 267 | Tinquiry96494 nbnonzero; 268 | Tunaryfunc96488 nbinvert; 269 | Tbinaryfunc96490 nblshift; 270 | Tbinaryfunc96490 nbrshift; 271 | Tbinaryfunc96490 nband; 272 | Tbinaryfunc96490 nbxor; 273 | Tbinaryfunc96490 nbor; 274 | Tcoercion96496 nbcoerce; 275 | Tunaryfunc96488 nbint; 276 | Tunaryfunc96488 nblong; 277 | Tunaryfunc96488 nbfloat; 278 | Tunaryfunc96488 nboct; 279 | Tunaryfunc96488 nbhex; 280 | Tbinaryfunc96490 nbinplaceadd; 281 | Tbinaryfunc96490 nbinplacesubtract; 282 | Tbinaryfunc96490 nbinplacemultiply; 283 | Tbinaryfunc96490 nbinplacedivide; 284 | Tbinaryfunc96490 nbinplaceremainder; 285 | Tternaryfunc96492 nbinplacepower; 286 | Tbinaryfunc96490 nbinplacelshift; 287 | Tbinaryfunc96490 nbinplacershift; 288 | Tbinaryfunc96490 nbinplaceand; 289 | Tbinaryfunc96490 nbinplacexor; 290 | Tbinaryfunc96490 nbinplaceor; 291 | Tbinaryfunc96490 nbfloordivide; 292 | Tbinaryfunc96490 nbtruedivide; 293 | Tbinaryfunc96490 nbinplacefloordivide; 294 | Tbinaryfunc96490 nbinplacetruedivide; 295 | }; 296 | typedef N_CDECL_PTR(Tpyobject96574*, Tintargfunc96498) (Tpyobject96574* ob1, NI i); 297 | typedef N_CDECL_PTR(Tpyobject96574*, Tintintargfunc96500) (Tpyobject96574* ob1, NI i1, NI i2); 298 | typedef N_CDECL_PTR(NI, Tintobjargproc96502) (Tpyobject96574* ob1, NI i, Tpyobject96574* ob2); 299 | typedef N_CDECL_PTR(NI, Tintintobjargproc96504) (Tpyobject96574* ob1, NI i1, NI i2, Tpyobject96574* ob2); 300 | typedef N_CDECL_PTR(NI, Tobjobjproc96534) (Tpyobject96574* ob1, Tpyobject96574* ob2); 301 | struct Tpysequencemethods96560 { 302 | Tinquiry96494 sqlength; 303 | Tbinaryfunc96490 sqconcat; 304 | Tintargfunc96498 sqrepeat; 305 | Tintargfunc96498 sqitem; 306 | Tintintargfunc96500 sqslice; 307 | Tintobjargproc96502 sqassitem; 308 | Tintintobjargproc96504 sqassslice; 309 | Tobjobjproc96534 sqcontains; 310 | Tbinaryfunc96490 sqinplaceconcat; 311 | Tintargfunc96498 sqinplacerepeat; 312 | }; 313 | typedef N_CDECL_PTR(NI, Tobjobjargproc96506) (Tpyobject96574* ob1, Tpyobject96574* ob2, Tpyobject96574* ob3); 314 | struct Tpymappingmethods96564 { 315 | Tinquiry96494 mplength; 316 | Tbinaryfunc96490 mpsubscript; 317 | Tobjobjargproc96506 mpasssubscript; 318 | }; 319 | typedef N_CDECL_PTR(NI, Tgetreadbufferproc96526) (Tpyobject96574* ob1, NI i, void* p); 320 | typedef N_CDECL_PTR(NI, Tgetwritebufferproc96528) (Tpyobject96574* ob1, NI i, void* p); 321 | typedef N_CDECL_PTR(NI, Tgetsegcountproc96530) (Tpyobject96574* ob1, NI i); 322 | typedef N_CDECL_PTR(NI, Tgetcharbufferproc96532) (Tpyobject96574* ob1, NI i, NCSTRING pstr); 323 | struct Tpybufferprocs96568 { 324 | Tgetreadbufferproc96526 bfgetreadbuffer; 325 | Tgetwritebufferproc96528 bfgetwritebuffer; 326 | Tgetsegcountproc96530 bfgetsegcount; 327 | Tgetcharbufferproc96532 bfgetcharbuffer; 328 | }; 329 | typedef N_CDECL_PTR(Tpyobject96574*, Tpycfunction96486) (Tpyobject96574* self, Tpyobject96574* args); 330 | struct Tpymethoddef96586 { 331 | NCSTRING mlname; 332 | Tpycfunction96486 mlmeth; 333 | NI mlflags; 334 | NCSTRING mldoc; 335 | }; 336 | struct Tpymemberdef96590 { 337 | NCSTRING name; 338 | NI thetype; 339 | NI offset; 340 | NI flags; 341 | NCSTRING doc; 342 | }; 343 | typedef N_CDECL_PTR(Tpyobject96574*, Tgetter96592) (Tpyobject96574* obj, void* context); 344 | typedef N_CDECL_PTR(NI, Tsetter96594) (Tpyobject96574* obj, Tpyobject96574* value, void* context); 345 | struct Tpygetsetdef96598 { 346 | NCSTRING name; 347 | Tgetter96592 get; 348 | Tsetter96594 setter; 349 | NCSTRING doc; 350 | void* closure; 351 | }; 352 | struct Freecell31233 { 353 | Freecell31233* next; 354 | NI zerofield; 355 | }; 356 | struct TNimNode { 357 | NU8 kind; 358 | NI offset; 359 | TNimType* typ; 360 | NCSTRING name; 361 | NI len; 362 | TNimNode** sons; 363 | }; 364 | N_NIMCALL(NimStringDesc*, copyStringRC1)(NimStringDesc* src); 365 | static N_INLINE(void, nimGCunrefNoCycle)(void* p); 366 | N_NIMCALL(NIM_BOOL, allocinv_38411)(Memregion31291* a); 367 | static N_INLINE(Cell49347*, usrtocell_53046)(void* usr); 368 | static N_INLINE(void, nimFrame)(TFrame* s); 369 | N_NOINLINE(void, stackoverflow_23601)(void); 370 | static N_INLINE(void, popFrame)(void); 371 | N_NIMCALL(NIM_BOOL, isallocatedptr_38407)(Memregion31291* a, void* p); 372 | static N_INLINE(void, Gcdisable_11201)(void); 373 | N_NIMCALL(void, writestacktrace_20207)(void); 374 | static N_INLINE(void, rtladdzct_54604)(Cell49347* c); 375 | N_NOINLINE(void, addzct_53017)(Cellseq49363* s, Cell49347* c); 376 | N_NIMCALL(NimStringDesc*, cstrToNimstr)(NCSTRING str); 377 | static N_INLINE(void, Pyxdecref_99336)(Tpyobject96574* op); 378 | static N_INLINE(void, Pydecref_99297)(Tpyobject96574* op); 379 | static N_INLINE(NI, subInt)(NI a, NI b); 380 | N_NOINLINE(void, raiseOverflow)(void); 381 | static N_INLINE(void, initStackBottomWith)(void* locals); 382 | N_NOINLINE(void, setStackBottom)(void* thestackbottom); 383 | NIM_EXTERNC N_NOINLINE(void, systemInit000)(void); 384 | NIM_EXTERNC N_NOINLINE(void, systemDatInit000)(void); 385 | NIM_EXTERNC N_NOINLINE(void, HEX00_dynlibInit000)(void); 386 | NIM_EXTERNC N_NOINLINE(void, HEX00_dynlibDatInit000)(void); 387 | NIM_EXTERNC N_NOINLINE(void, python_pythonInit000)(void); 388 | NIM_EXTERNC N_NOINLINE(void, python_pythonDatInit000)(void); 389 | NIM_EXTERNC N_NOINLINE(void, md5_pythonInit000)(void); 390 | NIM_EXTERNC N_NOINLINE(void, md5_pythonDatInit000)(void); 391 | STRING_LITERAL(TMP312, "Hello world!", 12); 392 | STRING_LITERAL(TMP313, "[SYSASSERT] ", 12); 393 | STRING_LITERAL(TMP314, "begin nimGCunrefNoCycle", 23); 394 | STRING_LITERAL(TMP315, "[GCASSERT] ", 11); 395 | STRING_LITERAL(TMP316, "nimGCunrefNoCycle: isAllocatedPtr", 33); 396 | STRING_LITERAL(TMP317, "end nimGCunrefNoCycle 2", 23); 397 | STRING_LITERAL(TMP318, "end nimGCunrefNoCycle 5", 23); 398 | STRING_LITERAL(TMP319, "Text: ", 6); 399 | STRING_LITERAL(TMP320, "Encoded Text: ", 14); 400 | extern TY97559 Dl_97558; 401 | NimStringDesc* texttoencode_101007; 402 | extern Gcheap51418 gch_51459; 403 | extern TFrame* frameptr_20842; 404 | Tpyobject96574* pytexttoencode_101011; 405 | extern TY97702 Dl_97701; 406 | Tpyobject96574* pyenvironmentmodule_101015; 407 | extern TY97880 Dl_97879; 408 | Tpyobject96574* pyenvironmentvars_101019; 409 | extern TY97669 Dl_97668; 410 | extern TY97655 Dl_97654; 411 | extern TY97690 Dl_97689; 412 | Tpyobject96574* pyencodedtext_101032; 413 | extern TY97648 Dl_97647; 414 | NCSTRING encodedtext_101036; 415 | extern TY97696 Dl_97695; 416 | extern TY98892 Dl_98891; 417 | 418 | static N_INLINE(void, nimFrame)(TFrame* s) { 419 | NI LOC1; 420 | LOC1 = 0; 421 | { 422 | if (!(frameptr_20842 == NIM_NIL)) goto LA4; 423 | LOC1 = ((NI) 0); 424 | } 425 | goto LA2; 426 | LA4: ; 427 | { 428 | LOC1 = ((NI) ((NI16)((*frameptr_20842).calldepth + ((NI16) 1)))); 429 | } 430 | LA2: ; 431 | (*s).calldepth = ((NI16) (LOC1)); 432 | (*s).prev = frameptr_20842; 433 | frameptr_20842 = s; 434 | { 435 | if (!((*s).calldepth == ((NI16) 2000))) goto LA9; 436 | stackoverflow_23601(); 437 | } 438 | LA9: ; 439 | } 440 | 441 | static N_INLINE(void, popFrame)(void) { 442 | frameptr_20842 = (*frameptr_20842).prev; 443 | } 444 | 445 | static N_INLINE(Cell49347*, usrtocell_53046)(void* usr) { 446 | Cell49347* result; 447 | nimfr("usrToCell", "gc.nim") 448 | result = 0; 449 | nimln(131, "gc.nim"); 450 | result = ((Cell49347*) ((NI)((NU64)(((NI) (usr))) - (NU64)(((NI)sizeof(Cell49347)))))); 451 | popFrame(); 452 | return result; 453 | } 454 | 455 | static N_INLINE(void, Gcdisable_11201)(void) { 456 | nimfr("GC_disable", "gc.nim") 457 | nimln(976, "gc.nim"); 458 | gch_51459.recgclock += ((NI) 1); 459 | popFrame(); 460 | } 461 | 462 | static N_INLINE(void, rtladdzct_54604)(Cell49347* c) { 463 | nimfr("rtlAddZCT", "gc.nim") 464 | nimln(212, "gc.nim"); 465 | addzct_53017((&gch_51459.zct), c); 466 | popFrame(); 467 | } 468 | 469 | static N_INLINE(void, nimGCunrefNoCycle)(void* p) { 470 | Cell49347* c; 471 | nimfr("nimGCunrefNoCycle", "gc.nim") 472 | nimln(1365, "system.nim"); 473 | { 474 | NIM_BOOL LOC3; 475 | nimln(245, "gc.nim"); 476 | LOC3 = 0; 477 | LOC3 = allocinv_38411((&gch_51459.region)); 478 | if (!!(LOC3)) goto LA4; 479 | nimln(1366, "system.nim"); 480 | printf("%s%s\012", ((NimStringDesc*) &TMP313)? (((NimStringDesc*) &TMP313))->data:"nil", ((NimStringDesc*) &TMP314)? (((NimStringDesc*) &TMP314))->data:"nil"); 481 | nimln(1367, "system.nim"); 482 | exit(((NI) 1)); 483 | } 484 | LA4: ; 485 | nimln(246, "gc.nim"); 486 | c = usrtocell_53046(p); 487 | nimln(114, "gc.nim"); 488 | { 489 | NIM_BOOL LOC8; 490 | nimln(247, "gc.nim"); 491 | LOC8 = 0; 492 | LOC8 = isallocatedptr_38407((&gch_51459.region), ((void*) (c))); 493 | if (!!(LOC8)) goto LA9; 494 | nimln(115, "gc.nim"); 495 | printf("%s%s\012", ((NimStringDesc*) &TMP315)? (((NimStringDesc*) &TMP315))->data:"nil", ((NimStringDesc*) &TMP316)? (((NimStringDesc*) &TMP316))->data:"nil"); 496 | nimln(116, "gc.nim"); 497 | Gcdisable_11201(); 498 | nimln(117, "gc.nim"); 499 | writestacktrace_20207(); 500 | nimln(118, "gc.nim"); 501 | exit(((NI) 1)); 502 | } 503 | LA9: ; 504 | nimln(248, "gc.nim"); 505 | { 506 | nimln(180, "gc.nim"); 507 | (*c).refcount -= ((NI) 8); 508 | nimln(181, "gc.nim"); 509 | if (!((NU64)((*c).refcount) < (NU64)(((NI) 8)))) goto LA13; 510 | nimln(249, "gc.nim"); 511 | rtladdzct_54604(c); 512 | nimln(1365, "system.nim"); 513 | { 514 | NIM_BOOL LOC17; 515 | nimln(250, "gc.nim"); 516 | LOC17 = 0; 517 | LOC17 = allocinv_38411((&gch_51459.region)); 518 | if (!!(LOC17)) goto LA18; 519 | nimln(1366, "system.nim"); 520 | printf("%s%s\012", ((NimStringDesc*) &TMP313)? (((NimStringDesc*) &TMP313))->data:"nil", ((NimStringDesc*) &TMP317)? (((NimStringDesc*) &TMP317))->data:"nil"); 521 | nimln(1367, "system.nim"); 522 | exit(((NI) 1)); 523 | } 524 | LA18: ; 525 | } 526 | LA13: ; 527 | nimln(1365, "system.nim"); 528 | { 529 | NIM_BOOL LOC22; 530 | nimln(251, "gc.nim"); 531 | LOC22 = 0; 532 | LOC22 = allocinv_38411((&gch_51459.region)); 533 | if (!!(LOC22)) goto LA23; 534 | nimln(1366, "system.nim"); 535 | printf("%s%s\012", ((NimStringDesc*) &TMP313)? (((NimStringDesc*) &TMP313))->data:"nil", ((NimStringDesc*) &TMP318)? (((NimStringDesc*) &TMP318))->data:"nil"); 536 | nimln(1367, "system.nim"); 537 | exit(((NI) 1)); 538 | } 539 | LA23: ; 540 | popFrame(); 541 | } 542 | 543 | static N_INLINE(NI, subInt)(NI a, NI b) { 544 | NI result; 545 | { result = 0; 546 | result = (NI)((NU64)(a) - (NU64)(b)); 547 | { 548 | NIM_BOOL LOC3; 549 | LOC3 = 0; 550 | LOC3 = (((NI) 0) <= (NI)(result ^ a)); 551 | if (LOC3) goto LA4; 552 | LOC3 = (((NI) 0) <= (NI)(result ^ (NI)((NU64) ~(b)))); 553 | LA4: ; 554 | if (!LOC3) goto LA5; 555 | goto BeforeRet; 556 | } 557 | LA5: ; 558 | raiseOverflow(); 559 | }BeforeRet: ; 560 | return result; 561 | } 562 | 563 | static N_INLINE(void, Pydecref_99297)(Tpyobject96574* op) { 564 | NI TMP321; 565 | nimfr("Py_DECREF", "python.nim") 566 | nimln(1315, "python.nim"); 567 | TMP321 = subInt((*op).obrefcnt, ((NI) 1)); 568 | (*op).obrefcnt = (NI)(TMP321); 569 | nimln(1316, "python.nim"); 570 | { 571 | if (!((*op).obrefcnt == ((NI) 0))) goto LA3; 572 | nimln(1317, "python.nim"); 573 | (*(*op).obtype).tpdealloc(op); 574 | } 575 | LA3: ; 576 | popFrame(); 577 | } 578 | 579 | static N_INLINE(void, Pyxdecref_99336)(Tpyobject96574* op) { 580 | nimfr("Py_XDECREF", "python.nim") 581 | nimln(1323, "python.nim"); 582 | { 583 | nimln(349, "system.nim"); 584 | if (!!((op == NIM_NIL))) goto LA3; 585 | nimln(1323, "python.nim"); 586 | Pydecref_99297(op); 587 | } 588 | LA3: ; 589 | popFrame(); 590 | } 591 | 592 | static N_INLINE(void, initStackBottomWith)(void* locals) { 593 | setStackBottom(locals); 594 | } 595 | void PreMainInner() { 596 | systemInit000(); 597 | HEX00_dynlibDatInit000(); 598 | python_pythonDatInit000(); 599 | md5_pythonDatInit000(); 600 | HEX00_dynlibInit000(); 601 | python_pythonInit000(); 602 | } 603 | 604 | void PreMain() { 605 | void (*volatile inner)(); 606 | systemDatInit000(); 607 | inner = PreMainInner; 608 | initStackBottomWith((void *)&inner); 609 | (*inner)(); 610 | } 611 | 612 | int cmdCount; 613 | char** cmdLine; 614 | char** gEnv; 615 | N_CDECL(void, NimMainInner)(void) { 616 | md5_pythonInit000(); 617 | } 618 | 619 | N_CDECL(void, NimMain)(void) { 620 | void (*volatile inner)(); 621 | PreMain(); 622 | inner = NimMainInner; 623 | initStackBottomWith((void *)&inner); 624 | (*inner)(); 625 | } 626 | 627 | int main(int argc, char** args, char** env) { 628 | cmdLine = args; 629 | cmdCount = argc; 630 | gEnv = env; 631 | NimMain(); 632 | return nim_program_result; 633 | } 634 | 635 | NIM_EXTERNC N_NOINLINE(void, md5_pythonInit000)(void) { 636 | NimStringDesc* LOC1; 637 | NI LOC2; 638 | NI LOC3; 639 | NI LOC4; 640 | NimStringDesc* LOC5; 641 | nimfr("md5_python", "md5_python.nim") 642 | nimln(6, "md5_python.nim"); 643 | Dl_97558(); 644 | nimln(7, "md5_python.nim"); 645 | LOC1 = 0; 646 | LOC1 = texttoencode_101007; texttoencode_101007 = copyStringRC1(((NimStringDesc*) &TMP312)); 647 | if (LOC1) nimGCunrefNoCycle(LOC1); 648 | nimln(8, "md5_python.nim"); 649 | pytexttoencode_101011 = Dl_97701(texttoencode_101007->data); 650 | nimln(9, "md5_python.nim"); 651 | pyenvironmentmodule_101015 = Dl_97879("__main__"); 652 | nimln(10, "md5_python.nim"); 653 | pyenvironmentvars_101019 = Dl_97668(pyenvironmentmodule_101015); 654 | nimln(11, "md5_python.nim"); 655 | LOC2 = 0; 656 | LOC2 = Dl_97654(pyenvironmentvars_101019, "text", pytexttoencode_101011); 657 | nimln(12, "md5_python.nim"); 658 | LOC3 = 0; 659 | LOC3 = Dl_97689("import md5"); 660 | nimln(13, "md5_python.nim"); 661 | LOC4 = 0; 662 | LOC4 = Dl_97689("encoded_text = md5.md5(text).hexdigest()"); 663 | nimln(14, "md5_python.nim"); 664 | pyencodedtext_101032 = Dl_97647(pyenvironmentvars_101019, "encoded_text"); 665 | nimln(15, "md5_python.nim"); 666 | encodedtext_101036 = Dl_97695(pyencodedtext_101032); 667 | nimln(16, "md5_python.nim"); 668 | printf("%s%s\012", ((NimStringDesc*) &TMP319)? (((NimStringDesc*) &TMP319))->data:"nil", texttoencode_101007? (texttoencode_101007)->data:"nil"); 669 | nimln(17, "md5_python.nim"); 670 | LOC5 = 0; 671 | LOC5 = cstrToNimstr(encodedtext_101036); 672 | printf("%s%s\012", ((NimStringDesc*) &TMP320)? (((NimStringDesc*) &TMP320))->data:"nil", LOC5? (LOC5)->data:"nil"); 673 | nimln(18, "md5_python.nim"); 674 | Pyxdecref_99336(pyenvironmentmodule_101015); 675 | nimln(19, "md5_python.nim"); 676 | Pyxdecref_99336(pytexttoencode_101011); 677 | nimln(20, "md5_python.nim"); 678 | Pyxdecref_99336(pyencodedtext_101032); 679 | nimln(21, "md5_python.nim"); 680 | Dl_98891(); 681 | popFrame(); 682 | } 683 | 684 | NIM_EXTERNC N_NOINLINE(void, md5_pythonDatInit000)(void) { 685 | } 686 | 687 | -------------------------------------------------------------------------------- /tests/nimcache/pythonize_plotting.c: -------------------------------------------------------------------------------- 1 | /* Generated by Nim Compiler v0.12.0 */ 2 | /* (c) 2015 Andreas Rumpf */ 3 | /* The generated code is subject to the original license. */ 4 | /* Compiled for: Linux, amd64, gcc */ 5 | /* Command for C compiler: 6 | gcc -c -w -g3 -O0 -I/media/marco/Research/Applications/aporia/Nim/lib -o /home/marco/.nimble/pkgs/Pythonize27-1.0.0/tests/nimcache/pythonize_plotting.o /home/marco/.nimble/pkgs/Pythonize27-1.0.0/tests/nimcache/pythonize_plotting.c */ 7 | #define NIM_INTBITS 64 8 | 9 | #include "nimbase.h" 10 | #include 11 | typedef struct PythondictHEX3Aobjecttype130025 PythondictHEX3Aobjecttype130025; 12 | typedef struct NimStringDesc NimStringDesc; 13 | typedef struct TGenericSeq TGenericSeq; 14 | typedef struct PythonlistHEX3Aobjecttype130011 PythonlistHEX3Aobjecttype130011; 15 | typedef struct Tpyobject125574 Tpyobject125574; 16 | typedef struct TY132027 TY132027; 17 | typedef struct TY130058 TY130058; 18 | typedef struct Tpytypeobject125626 Tpytypeobject125626; 19 | typedef struct Tpynumbermethods125556 Tpynumbermethods125556; 20 | typedef struct Tpysequencemethods125560 Tpysequencemethods125560; 21 | typedef struct Tpymappingmethods125564 Tpymappingmethods125564; 22 | typedef struct Tpybufferprocs125568 Tpybufferprocs125568; 23 | typedef struct Tpymethoddef125586 Tpymethoddef125586; 24 | typedef struct Tpymemberdef125590 Tpymemberdef125590; 25 | typedef struct Tpygetsetdef125598 Tpygetsetdef125598; 26 | struct TGenericSeq { 27 | NI len; 28 | NI reserved; 29 | }; 30 | struct NimStringDesc { 31 | TGenericSeq Sup; 32 | NIM_CHAR data[SEQ_DECL_SIZE]; 33 | }; 34 | typedef N_CDECL_PTR(NI, TY126655) (Tpyobject125574* dp, NCSTRING key, Tpyobject125574* item); 35 | typedef N_CDECL_PTR(Tpyobject125574*, TY126953) (NI size); 36 | typedef N_CDECL_PTR(NI, TY126965) (Tpyobject125574* dp, NI idx, Tpyobject125574* item); 37 | typedef N_CDECL_PTR(Tpyobject125574*, TY127047) (NI64 val); 38 | typedef N_CDECL_PTR(Tpyobject125574*, TY126681) (NCSTRING str, NI start, Tpyobject125574* globals, Tpyobject125574* locals); 39 | typedef N_CDECL_PTR(void, TY126509) (void); 40 | typedef N_CDECL_PTR(void, TY127892) (void); 41 | struct Tpyobject125574 { 42 | NI obrefcnt; 43 | Tpytypeobject125626* obtype; 44 | }; 45 | struct PythondictHEX3Aobjecttype130025 { 46 | Tpyobject125574 Sup; 47 | }; 48 | struct PythonlistHEX3Aobjecttype130011 { 49 | Tpyobject125574 Sup; 50 | }; 51 | typedef N_CDECL_PTR(void, Tpydestructor125508) (Tpyobject125574* ob); 52 | typedef N_CDECL_PTR(NI, Tprintfunc125510) (Tpyobject125574* ob, FILE* f, NI i); 53 | typedef N_CDECL_PTR(Tpyobject125574*, Tgetattrfunc125512) (Tpyobject125574* ob1, NCSTRING name); 54 | typedef N_CDECL_PTR(NI, Tsetattrfunc125514) (Tpyobject125574* ob1, NCSTRING name, Tpyobject125574* ob2); 55 | typedef N_CDECL_PTR(NI, Tcmpfunc125516) (Tpyobject125574* ob1, Tpyobject125574* ob2); 56 | typedef N_CDECL_PTR(Tpyobject125574*, Treprfunc125518) (Tpyobject125574* ob); 57 | typedef N_CDECL_PTR(NI32, Thashfunc125520) (Tpyobject125574* ob); 58 | typedef N_CDECL_PTR(Tpyobject125574*, Tternaryfunc125492) (Tpyobject125574* ob1, Tpyobject125574* ob2, Tpyobject125574* ob3); 59 | typedef N_CDECL_PTR(Tpyobject125574*, Tgetattrofunc125522) (Tpyobject125574* ob1, Tpyobject125574* ob2); 60 | typedef N_CDECL_PTR(NI, Tsetattrofunc125524) (Tpyobject125574* ob1, Tpyobject125574* ob2, Tpyobject125574* ob3); 61 | typedef N_CDECL_PTR(NI, Tvisitproc125536) (Tpyobject125574* ob1, void* p); 62 | typedef N_CDECL_PTR(NI, Ttraverseproc125538) (Tpyobject125574* ob1, Tvisitproc125536 prc, void* p); 63 | typedef N_CDECL_PTR(NI, Tinquiry125494) (Tpyobject125574* ob1); 64 | typedef N_CDECL_PTR(Tpyobject125574*, Trichcmpfunc125540) (Tpyobject125574* ob1, Tpyobject125574* ob2, NI i); 65 | typedef N_CDECL_PTR(Tpyobject125574*, Tgetiterfunc125542) (Tpyobject125574* ob1); 66 | typedef N_CDECL_PTR(Tpyobject125574*, Titernextfunc125544) (Tpyobject125574* ob1); 67 | typedef N_CDECL_PTR(Tpyobject125574*, Tdescrgetfunc125546) (Tpyobject125574* ob1, Tpyobject125574* ob2, Tpyobject125574* ob3); 68 | typedef N_CDECL_PTR(NI, Tdescrsetfunc125548) (Tpyobject125574* ob1, Tpyobject125574* ob2, Tpyobject125574* ob3); 69 | typedef N_CDECL_PTR(NI, Tinitproc125550) (Tpyobject125574* self, Tpyobject125574* args, Tpyobject125574* kwds); 70 | typedef N_CDECL_PTR(Tpyobject125574*, Tallocfunc125554) (Tpytypeobject125626* self, NI nitems); 71 | typedef N_CDECL_PTR(Tpyobject125574*, Tnewfunc125552) (Tpytypeobject125626* subtype, Tpyobject125574* args, Tpyobject125574* kwds); 72 | struct Tpytypeobject125626 { 73 | Tpyobject125574 Sup; 74 | NI obsize; 75 | NCSTRING tpname; 76 | NI tpbasicsize; 77 | NI tpitemsize; 78 | Tpydestructor125508 tpdealloc; 79 | Tprintfunc125510 tpprint; 80 | Tgetattrfunc125512 tpgetattr; 81 | Tsetattrfunc125514 tpsetattr; 82 | Tcmpfunc125516 tpcompare; 83 | Treprfunc125518 tprepr; 84 | Tpynumbermethods125556* tpasnumber; 85 | Tpysequencemethods125560* tpassequence; 86 | Tpymappingmethods125564* tpasmapping; 87 | Thashfunc125520 tphash; 88 | Tternaryfunc125492 tpcall; 89 | Treprfunc125518 tpstr; 90 | Tgetattrofunc125522 tpgetattro; 91 | Tsetattrofunc125524 tpsetattro; 92 | Tpybufferprocs125568* tpasbuffer; 93 | NI32 tpflags; 94 | NCSTRING tpdoc; 95 | Ttraverseproc125538 tptraverse; 96 | Tinquiry125494 tpclear; 97 | Trichcmpfunc125540 tprichcompare; 98 | NI32 tpweaklistoffset; 99 | Tgetiterfunc125542 tpiter; 100 | Titernextfunc125544 tpiternext; 101 | Tpymethoddef125586* tpmethods; 102 | Tpymemberdef125590* tpmembers; 103 | Tpygetsetdef125598* tpgetset; 104 | Tpytypeobject125626* tpbase; 105 | Tpyobject125574* tpdict; 106 | Tdescrgetfunc125546 tpdescrget; 107 | Tdescrsetfunc125548 tpdescrset; 108 | NI32 tpdictoffset; 109 | Tinitproc125550 tpinit; 110 | Tallocfunc125554 tpalloc; 111 | Tnewfunc125552 tpnew; 112 | Tpydestructor125508 tpfree; 113 | Tinquiry125494 tpisgc; 114 | Tpyobject125574* tpbases; 115 | Tpyobject125574* tpmro; 116 | Tpyobject125574* tpcache; 117 | Tpyobject125574* tpsubclasses; 118 | Tpyobject125574* tpweaklist; 119 | void* tpxxx7; 120 | void* tpxxx8; 121 | }; 122 | typedef N_CDECL_PTR(Tpyobject125574*, Tbinaryfunc125490) (Tpyobject125574* ob1, Tpyobject125574* ob2); 123 | typedef N_CDECL_PTR(Tpyobject125574*, Tunaryfunc125488) (Tpyobject125574* ob1); 124 | typedef N_CDECL_PTR(NI, Tcoercion125496) (Tpyobject125574** ob1, Tpyobject125574** ob2); 125 | struct Tpynumbermethods125556 { 126 | Tbinaryfunc125490 nbadd; 127 | Tbinaryfunc125490 nbsubstract; 128 | Tbinaryfunc125490 nbmultiply; 129 | Tbinaryfunc125490 nbdivide; 130 | Tbinaryfunc125490 nbremainder; 131 | Tbinaryfunc125490 nbdivmod; 132 | Tternaryfunc125492 nbpower; 133 | Tunaryfunc125488 nbnegative; 134 | Tunaryfunc125488 nbpositive; 135 | Tunaryfunc125488 nbabsolute; 136 | Tinquiry125494 nbnonzero; 137 | Tunaryfunc125488 nbinvert; 138 | Tbinaryfunc125490 nblshift; 139 | Tbinaryfunc125490 nbrshift; 140 | Tbinaryfunc125490 nband; 141 | Tbinaryfunc125490 nbxor; 142 | Tbinaryfunc125490 nbor; 143 | Tcoercion125496 nbcoerce; 144 | Tunaryfunc125488 nbint; 145 | Tunaryfunc125488 nblong; 146 | Tunaryfunc125488 nbfloat; 147 | Tunaryfunc125488 nboct; 148 | Tunaryfunc125488 nbhex; 149 | Tbinaryfunc125490 nbinplaceadd; 150 | Tbinaryfunc125490 nbinplacesubtract; 151 | Tbinaryfunc125490 nbinplacemultiply; 152 | Tbinaryfunc125490 nbinplacedivide; 153 | Tbinaryfunc125490 nbinplaceremainder; 154 | Tternaryfunc125492 nbinplacepower; 155 | Tbinaryfunc125490 nbinplacelshift; 156 | Tbinaryfunc125490 nbinplacershift; 157 | Tbinaryfunc125490 nbinplaceand; 158 | Tbinaryfunc125490 nbinplacexor; 159 | Tbinaryfunc125490 nbinplaceor; 160 | Tbinaryfunc125490 nbfloordivide; 161 | Tbinaryfunc125490 nbtruedivide; 162 | Tbinaryfunc125490 nbinplacefloordivide; 163 | Tbinaryfunc125490 nbinplacetruedivide; 164 | }; 165 | typedef N_CDECL_PTR(Tpyobject125574*, Tintargfunc125498) (Tpyobject125574* ob1, NI i); 166 | typedef N_CDECL_PTR(Tpyobject125574*, Tintintargfunc125500) (Tpyobject125574* ob1, NI i1, NI i2); 167 | typedef N_CDECL_PTR(NI, Tintobjargproc125502) (Tpyobject125574* ob1, NI i, Tpyobject125574* ob2); 168 | typedef N_CDECL_PTR(NI, Tintintobjargproc125504) (Tpyobject125574* ob1, NI i1, NI i2, Tpyobject125574* ob2); 169 | typedef N_CDECL_PTR(NI, Tobjobjproc125534) (Tpyobject125574* ob1, Tpyobject125574* ob2); 170 | struct Tpysequencemethods125560 { 171 | Tinquiry125494 sqlength; 172 | Tbinaryfunc125490 sqconcat; 173 | Tintargfunc125498 sqrepeat; 174 | Tintargfunc125498 sqitem; 175 | Tintintargfunc125500 sqslice; 176 | Tintobjargproc125502 sqassitem; 177 | Tintintobjargproc125504 sqassslice; 178 | Tobjobjproc125534 sqcontains; 179 | Tbinaryfunc125490 sqinplaceconcat; 180 | Tintargfunc125498 sqinplacerepeat; 181 | }; 182 | typedef N_CDECL_PTR(NI, Tobjobjargproc125506) (Tpyobject125574* ob1, Tpyobject125574* ob2, Tpyobject125574* ob3); 183 | struct Tpymappingmethods125564 { 184 | Tinquiry125494 mplength; 185 | Tbinaryfunc125490 mpsubscript; 186 | Tobjobjargproc125506 mpasssubscript; 187 | }; 188 | typedef N_CDECL_PTR(NI, Tgetreadbufferproc125526) (Tpyobject125574* ob1, NI i, void* p); 189 | typedef N_CDECL_PTR(NI, Tgetwritebufferproc125528) (Tpyobject125574* ob1, NI i, void* p); 190 | typedef N_CDECL_PTR(NI, Tgetsegcountproc125530) (Tpyobject125574* ob1, NI i); 191 | typedef N_CDECL_PTR(NI, Tgetcharbufferproc125532) (Tpyobject125574* ob1, NI i, NCSTRING pstr); 192 | struct Tpybufferprocs125568 { 193 | Tgetreadbufferproc125526 bfgetreadbuffer; 194 | Tgetwritebufferproc125528 bfgetwritebuffer; 195 | Tgetsegcountproc125530 bfgetsegcount; 196 | Tgetcharbufferproc125532 bfgetcharbuffer; 197 | }; 198 | typedef N_CDECL_PTR(Tpyobject125574*, Tpycfunction125486) (Tpyobject125574* self, Tpyobject125574* args); 199 | struct Tpymethoddef125586 { 200 | NCSTRING mlname; 201 | Tpycfunction125486 mlmeth; 202 | NI mlflags; 203 | NCSTRING mldoc; 204 | }; 205 | struct Tpymemberdef125590 { 206 | NCSTRING name; 207 | NI thetype; 208 | NI offset; 209 | NI flags; 210 | NCSTRING doc; 211 | }; 212 | typedef N_CDECL_PTR(Tpyobject125574*, Tgetter125592) (Tpyobject125574* obj, void* context); 213 | typedef N_CDECL_PTR(NI, Tsetter125594) (Tpyobject125574* obj, Tpyobject125574* value, void* context); 214 | struct Tpygetsetdef125598 { 215 | NCSTRING name; 216 | Tgetter125592 get; 217 | Tsetter125594 setter; 218 | NCSTRING doc; 219 | void* closure; 220 | }; 221 | struct TY132027 { 222 | TGenericSeq Sup; 223 | NI data[SEQ_DECL_SIZE]; 224 | }; 225 | struct TY130058 { 226 | TGenericSeq Sup; 227 | Tpyobject125574* data[SEQ_DECL_SIZE]; 228 | }; 229 | static N_INLINE(void, HEX5BHEX5DHEX3D_132146)(PythondictHEX3Aobjecttype130025* p, NimStringDesc* index, PythonlistHEX3Aobjecttype130011* val); 230 | static N_INLINE(void, setitem_132156)(PythondictHEX3Aobjecttype130025* p, NimStringDesc* index, PythonlistHEX3Aobjecttype130011* val); 231 | static N_INLINE(PythonlistHEX3Aobjecttype130011*, pythonify_132166)(PythonlistHEX3Aobjecttype130011* x); 232 | static N_INLINE(void, nimFrame)(TFrame* s); 233 | N_NOINLINE(void, stackoverflow_23601)(void); 234 | static N_INLINE(void, popFrame)(void); 235 | static N_INLINE(PythonlistHEX3Aobjecttype130011*, pythonify_132033)(NI* data, NI dataLen0); 236 | static N_INLINE(PythonlistHEX3Aobjecttype130011*, newpythonlist_130742)(NI size); 237 | N_NIMCALL(Tpyobject125574*, addreference_130098)(Tpyobject125574* obj); 238 | N_NOINLINE(void, raiseIndexError)(void); 239 | static N_INLINE(void, HEX5BHEX5DHEX3D_132091)(PythonlistHEX3Aobjecttype130011** p, NI index, Tpyobject125574* val); 240 | static N_INLINE(void, setitem_132101)(PythonlistHEX3Aobjecttype130011** p, NI index, Tpyobject125574* val); 241 | static N_INLINE(Tpyobject125574*, pythonify_132111)(Tpyobject125574* x); 242 | static N_INLINE(NI, chckRange)(NI i, NI a, NI b); 243 | N_NOINLINE(void, raiseRangeError)(NI64 val); 244 | static N_INLINE(Tpyobject125574*, pythonify_130214)(NI x); 245 | static N_INLINE(NI, addInt)(NI a, NI b); 246 | N_NOINLINE(void, raiseOverflow)(void); 247 | N_NIMCALL(void, release_132412)(Tpyobject125574* op); 248 | N_NIMCALL(void, failedassertimpl_91603)(NimStringDesc* msg); 249 | static N_INLINE(void, initStackBottomWith)(void* locals); 250 | N_NOINLINE(void, setStackBottom)(void* thestackbottom); 251 | NIM_EXTERNC N_NOINLINE(void, systemInit000)(void); 252 | NIM_EXTERNC N_NOINLINE(void, systemDatInit000)(void); 253 | NIM_EXTERNC N_NOINLINE(void, HEX00_parseutilsInit000)(void); 254 | NIM_EXTERNC N_NOINLINE(void, HEX00_parseutilsDatInit000)(void); 255 | NIM_EXTERNC N_NOINLINE(void, HEX00_strutilsInit000)(void); 256 | NIM_EXTERNC N_NOINLINE(void, HEX00_strutilsDatInit000)(void); 257 | NIM_EXTERNC N_NOINLINE(void, HEX00_etcprivInit000)(void); 258 | NIM_EXTERNC N_NOINLINE(void, HEX00_etcprivDatInit000)(void); 259 | NIM_EXTERNC N_NOINLINE(void, HEX00_hashesInit000)(void); 260 | NIM_EXTERNC N_NOINLINE(void, HEX00_hashesDatInit000)(void); 261 | NIM_EXTERNC N_NOINLINE(void, HEX00_timesInit000)(void); 262 | NIM_EXTERNC N_NOINLINE(void, HEX00_timesDatInit000)(void); 263 | NIM_EXTERNC N_NOINLINE(void, HEX00_mathInit000)(void); 264 | NIM_EXTERNC N_NOINLINE(void, HEX00_mathDatInit000)(void); 265 | NIM_EXTERNC N_NOINLINE(void, HEX00_tablesInit000)(void); 266 | NIM_EXTERNC N_NOINLINE(void, HEX00_tablesDatInit000)(void); 267 | NIM_EXTERNC N_NOINLINE(void, HEX00_dynlibInit000)(void); 268 | NIM_EXTERNC N_NOINLINE(void, HEX00_dynlibDatInit000)(void); 269 | NIM_EXTERNC N_NOINLINE(void, python_pythonInit000)(void); 270 | NIM_EXTERNC N_NOINLINE(void, python_pythonDatInit000)(void); 271 | NIM_EXTERNC N_NOINLINE(void, pythonize_pythonizeInit000)(void); 272 | NIM_EXTERNC N_NOINLINE(void, pythonize_pythonizeDatInit000)(void); 273 | NIM_EXTERNC N_NOINLINE(void, plottingInit000)(void); 274 | NIM_EXTERNC N_NOINLINE(void, plottingDatInit000)(void); 275 | STRING_LITERAL(TMP511, "signal", 6); 276 | NIM_CONST struct { 277 | TGenericSeq Sup; 278 | NI data[14]; 279 | } CNSTSEQ515 = {{14, 14}, {((NI) 0), 280 | ((NI) 2290), 281 | ((NI) 4001), 282 | ((NI) 5122), 283 | ((NI) 5686), 284 | ((NI) 5756), 285 | ((NI) 5419), 286 | ((NI) 4773), 287 | ((NI) 3919), 288 | ((NI) 2955), 289 | ((NI) 1966), 290 | ((NI) 1026), 291 | ((NI) 188), 292 | ((NI) 0)}}; 293 | NIM_CONST TY132027* TMP513 = ((TY132027*)&CNSTSEQ515); 294 | STRING_LITERAL(TMP516, "len(a) == L seq modified while iterating over it", 48); 295 | extern TY126655 Dl_126654; 296 | extern TFrame* frameptr_20842; 297 | extern Tpyobject125574* pythonenvironmentobject_130069; 298 | extern TY126953 Dl_126952; 299 | extern TY126965 Dl_126964; 300 | extern TY127047 Dl_127046; 301 | extern TY126681 Dl_126680; 302 | extern TY126509 Dl_126508; 303 | Tpyobject125574* pythonref_132221; 304 | extern TY130058* pythonreferences_130059; 305 | extern TY127892 Dl_127891; 306 | 307 | static N_INLINE(void, nimFrame)(TFrame* s) { 308 | NI LOC1; 309 | LOC1 = 0; 310 | { 311 | if (!(frameptr_20842 == NIM_NIL)) goto LA4; 312 | LOC1 = ((NI) 0); 313 | } 314 | goto LA2; 315 | LA4: ; 316 | { 317 | LOC1 = ((NI) ((NI16)((*frameptr_20842).calldepth + ((NI16) 1)))); 318 | } 319 | LA2: ; 320 | (*s).calldepth = ((NI16) (LOC1)); 321 | (*s).prev = frameptr_20842; 322 | frameptr_20842 = s; 323 | { 324 | if (!((*s).calldepth == ((NI16) 2000))) goto LA9; 325 | stackoverflow_23601(); 326 | } 327 | LA9: ; 328 | } 329 | 330 | static N_INLINE(void, popFrame)(void) { 331 | frameptr_20842 = (*frameptr_20842).prev; 332 | } 333 | 334 | static N_INLINE(PythonlistHEX3Aobjecttype130011*, pythonify_132166)(PythonlistHEX3Aobjecttype130011* x) { 335 | PythonlistHEX3Aobjecttype130011* result; 336 | nimfr("pythonify", "pythonize.nim") 337 | result = 0; 338 | nimln(97, "pythonize.nim"); 339 | result = x; 340 | popFrame(); 341 | return result; 342 | } 343 | 344 | static N_INLINE(void, setitem_132156)(PythondictHEX3Aobjecttype130025* p, NimStringDesc* index, PythonlistHEX3Aobjecttype130011* val) { 345 | PythonlistHEX3Aobjecttype130011* LOC1; 346 | NI LOC2; 347 | nimfr("setItem", "pythonize.nim") 348 | nimln(545, "pythonize.nim"); 349 | LOC1 = 0; 350 | LOC1 = pythonify_132166(val); 351 | LOC2 = 0; 352 | LOC2 = Dl_126654(((Tpyobject125574*) (p)), index->data, ((Tpyobject125574*) (LOC1))); 353 | popFrame(); 354 | } 355 | 356 | static N_INLINE(void, HEX5BHEX5DHEX3D_132146)(PythondictHEX3Aobjecttype130025* p, NimStringDesc* index, PythonlistHEX3Aobjecttype130011* val) { 357 | nimfr("[]=", "pythonize.nim") 358 | nimln(548, "pythonize.nim"); 359 | setitem_132156(p, index, val); 360 | popFrame(); 361 | } 362 | 363 | static N_INLINE(PythonlistHEX3Aobjecttype130011*, newpythonlist_130742)(NI size) { 364 | PythonlistHEX3Aobjecttype130011* result; 365 | Tpyobject125574* LOC1; 366 | Tpyobject125574* LOC2; 367 | nimfr("newPythonList", "pythonize.nim") 368 | result = 0; 369 | nimln(276, "pythonize.nim"); 370 | LOC1 = 0; 371 | LOC1 = Dl_126952(size); 372 | LOC2 = 0; 373 | LOC2 = addreference_130098(((Tpyobject125574*) (LOC1))); 374 | result = ((PythonlistHEX3Aobjecttype130011*) (LOC2)); 375 | popFrame(); 376 | return result; 377 | } 378 | 379 | static N_INLINE(Tpyobject125574*, pythonify_132111)(Tpyobject125574* x) { 380 | Tpyobject125574* result; 381 | nimfr("pythonify", "pythonize.nim") 382 | result = 0; 383 | nimln(97, "pythonize.nim"); 384 | result = x; 385 | popFrame(); 386 | return result; 387 | } 388 | 389 | static N_INLINE(void, setitem_132101)(PythonlistHEX3Aobjecttype130011** p, NI index, Tpyobject125574* val) { 390 | Tpyobject125574* LOC1; 391 | NI LOC2; 392 | nimfr("setItem", "pythonize.nim") 393 | nimln(340, "pythonize.nim"); 394 | LOC1 = 0; 395 | LOC1 = pythonify_132111(val); 396 | LOC2 = 0; 397 | LOC2 = Dl_126964(((Tpyobject125574*) ((*p))), ((NI) (index)), ((Tpyobject125574*) (LOC1))); 398 | popFrame(); 399 | } 400 | 401 | static N_INLINE(void, HEX5BHEX5DHEX3D_132091)(PythonlistHEX3Aobjecttype130011** p, NI index, Tpyobject125574* val) { 402 | nimfr("[]=", "pythonize.nim") 403 | nimln(342, "pythonize.nim"); 404 | setitem_132101(p, index, val); 405 | popFrame(); 406 | } 407 | 408 | static N_INLINE(NI, chckRange)(NI i, NI a, NI b) { 409 | NI result; 410 | { result = 0; 411 | { 412 | NIM_BOOL LOC3; 413 | LOC3 = 0; 414 | LOC3 = (a <= i); 415 | if (!(LOC3)) goto LA4; 416 | LOC3 = (i <= b); 417 | LA4: ; 418 | if (!LOC3) goto LA5; 419 | result = i; 420 | goto BeforeRet; 421 | } 422 | goto LA1; 423 | LA5: ; 424 | { 425 | raiseRangeError(((NI64) (i))); 426 | } 427 | LA1: ; 428 | }BeforeRet: ; 429 | return result; 430 | } 431 | 432 | static N_INLINE(Tpyobject125574*, pythonify_130214)(NI x) { 433 | Tpyobject125574* result; 434 | Tpyobject125574* LOC1; 435 | nimfr("pythonify", "pythonize.nim") 436 | result = 0; 437 | nimln(107, "pythonize.nim"); 438 | LOC1 = 0; 439 | LOC1 = Dl_127046(((NI64) (x))); 440 | result = ((Tpyobject125574*) (LOC1)); 441 | popFrame(); 442 | return result; 443 | } 444 | 445 | static N_INLINE(NI, addInt)(NI a, NI b) { 446 | NI result; 447 | { result = 0; 448 | result = (NI)((NU64)(a) + (NU64)(b)); 449 | { 450 | NIM_BOOL LOC3; 451 | LOC3 = 0; 452 | LOC3 = (((NI) 0) <= (NI)(result ^ a)); 453 | if (LOC3) goto LA4; 454 | LOC3 = (((NI) 0) <= (NI)(result ^ b)); 455 | LA4: ; 456 | if (!LOC3) goto LA5; 457 | goto BeforeRet; 458 | } 459 | LA5: ; 460 | raiseOverflow(); 461 | }BeforeRet: ; 462 | return result; 463 | } 464 | 465 | static N_INLINE(PythonlistHEX3Aobjecttype130011*, pythonify_132033)(NI* data, NI dataLen0) { 466 | PythonlistHEX3Aobjecttype130011* result; 467 | nimfr("pythonify", "pythonize.nim") 468 | result = 0; 469 | nimln(287, "pythonize.nim"); 470 | result = newpythonlist_130742(dataLen0); 471 | { 472 | NI index_132088; 473 | NI value_132089; 474 | NI i_132132; 475 | index_132088 = 0; 476 | value_132089 = 0; 477 | nimln(2031, "system.nim"); 478 | i_132132 = ((NI) 0); 479 | { 480 | nimln(2032, "system.nim"); 481 | while (1) { 482 | Tpyobject125574* LOC4; 483 | NI TMP512; 484 | if (!(i_132132 < dataLen0)) goto LA3; 485 | nimln(2031, "system.nim"); 486 | index_132088 = i_132132; 487 | nimln(2033, "system.nim"); 488 | if ((NU)(i_132132) >= (NU)(dataLen0)) raiseIndexError(); 489 | value_132089 = data[i_132132]; 490 | nimln(289, "pythonize.nim"); 491 | LOC4 = 0; 492 | LOC4 = pythonify_130214(value_132089); 493 | HEX5BHEX5DHEX3D_132091(&result, ((NI)chckRange(index_132088, ((NI) 0), ((NI) IL64(9223372036854775807)))), LOC4); 494 | nimln(2034, "system.nim"); 495 | TMP512 = addInt(i_132132, ((NI) 1)); 496 | i_132132 = (NI)(TMP512); 497 | } LA3: ; 498 | } 499 | } 500 | popFrame(); 501 | return result; 502 | } 503 | 504 | static N_INLINE(void, initStackBottomWith)(void* locals) { 505 | setStackBottom(locals); 506 | } 507 | void PreMainInner() { 508 | systemInit000(); 509 | HEX00_parseutilsDatInit000(); 510 | HEX00_strutilsDatInit000(); 511 | HEX00_etcprivDatInit000(); 512 | HEX00_hashesDatInit000(); 513 | HEX00_timesDatInit000(); 514 | HEX00_mathDatInit000(); 515 | HEX00_tablesDatInit000(); 516 | HEX00_dynlibDatInit000(); 517 | python_pythonDatInit000(); 518 | pythonize_pythonizeDatInit000(); 519 | plottingDatInit000(); 520 | HEX00_parseutilsInit000(); 521 | HEX00_strutilsInit000(); 522 | HEX00_etcprivInit000(); 523 | HEX00_hashesInit000(); 524 | HEX00_timesInit000(); 525 | HEX00_mathInit000(); 526 | HEX00_tablesInit000(); 527 | HEX00_dynlibInit000(); 528 | python_pythonInit000(); 529 | pythonize_pythonizeInit000(); 530 | } 531 | 532 | void PreMain() { 533 | void (*volatile inner)(); 534 | systemDatInit000(); 535 | inner = PreMainInner; 536 | initStackBottomWith((void *)&inner); 537 | (*inner)(); 538 | } 539 | 540 | int cmdCount; 541 | char** cmdLine; 542 | char** gEnv; 543 | N_CDECL(void, NimMainInner)(void) { 544 | plottingInit000(); 545 | } 546 | 547 | N_CDECL(void, NimMain)(void) { 548 | void (*volatile inner)(); 549 | PreMain(); 550 | inner = NimMainInner; 551 | initStackBottomWith((void *)&inner); 552 | (*inner)(); 553 | } 554 | 555 | int main(int argc, char** args, char** env) { 556 | cmdLine = args; 557 | cmdCount = argc; 558 | gEnv = env; 559 | NimMain(); 560 | return nim_program_result; 561 | } 562 | 563 | NIM_EXTERNC N_NOINLINE(void, plottingInit000)(void) { 564 | PythonlistHEX3Aobjecttype130011* LOC1; 565 | nimfr("plotting", "plotting.nim") 566 | nimln(3, "plotting.nim"); 567 | LOC1 = 0; 568 | LOC1 = pythonify_132033(TMP513->data, TMP513->Sup.len); 569 | HEX5BHEX5DHEX3D_132146(((PythondictHEX3Aobjecttype130025*) (pythonenvironmentobject_130069)), ((NimStringDesc*) &TMP511), LOC1); 570 | nimln(70, "pythonize.nim"); 571 | { 572 | Tpyobject125574* LOC4; 573 | LOC4 = 0; 574 | LOC4 = Dl_126680("import pylab", ((NI) 257), pythonenvironmentobject_130069, pythonenvironmentobject_130069); 575 | if (!LOC4 == 0) goto LA5; 576 | nimln(71, "pythonize.nim"); 577 | Dl_126508(); 578 | } 579 | LA5: ; 580 | nimln(70, "pythonize.nim"); 581 | { 582 | Tpyobject125574* LOC9; 583 | LOC9 = 0; 584 | LOC9 = Dl_126680("pylab.fill(signal)", ((NI) 257), pythonenvironmentobject_130069, pythonenvironmentobject_130069); 585 | if (!LOC9 == 0) goto LA10; 586 | nimln(71, "pythonize.nim"); 587 | Dl_126508(); 588 | } 589 | LA10: ; 590 | nimln(70, "pythonize.nim"); 591 | { 592 | Tpyobject125574* LOC14; 593 | LOC14 = 0; 594 | LOC14 = Dl_126680("pylab.show()", ((NI) 257), pythonenvironmentobject_130069, pythonenvironmentobject_130069); 595 | if (!LOC14 == 0) goto LA15; 596 | nimln(71, "pythonize.nim"); 597 | Dl_126508(); 598 | } 599 | LA15: ; 600 | { 601 | NI i_132458; 602 | NI L_132460; 603 | nimln(3365, "system.nim"); 604 | i_132458 = ((NI) 0); 605 | nimln(3366, "system.nim"); 606 | L_132460 = (pythonreferences_130059 ? pythonreferences_130059->Sup.len : 0); 607 | { 608 | nimln(3367, "system.nim"); 609 | while (1) { 610 | NI TMP515; 611 | if (!(i_132458 < L_132460)) goto LA19; 612 | nimln(3368, "system.nim"); 613 | if ((NU)(i_132458) >= (NU)(pythonreferences_130059->Sup.len)) raiseIndexError(); 614 | pythonref_132221 = pythonreferences_130059->data[i_132458]; 615 | nimln(603, "pythonize.nim"); 616 | release_132412(pythonref_132221); 617 | nimln(3369, "system.nim"); 618 | TMP515 = addInt(i_132458, ((NI) 1)); 619 | i_132458 = (NI)(TMP515); 620 | nimln(3370, "system.nim"); 621 | { 622 | if (!!(((pythonreferences_130059 ? pythonreferences_130059->Sup.len : 0) == L_132460))) goto LA22; 623 | failedassertimpl_91603(((NimStringDesc*) &TMP516)); 624 | } 625 | LA22: ; 626 | } LA19: ; 627 | } 628 | } 629 | nimln(604, "pythonize.nim"); 630 | { 631 | if (!NIM_TRUE) goto LA26; 632 | nimln(596, "pythonize.nim"); 633 | Dl_127891(); 634 | } 635 | LA26: ; 636 | popFrame(); 637 | } 638 | 639 | NIM_EXTERNC N_NOINLINE(void, plottingDatInit000)(void) { 640 | } 641 | 642 | -------------------------------------------------------------------------------- /pythonize.nim: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2015 Marco Antonio Pinto 2 | # MIT License - Look at license.txt for details. 3 | {.deadCodeElim: on.} 4 | import tables 5 | import python 6 | 7 | # 8 | # 9 | # 10 | type PythonObject* = PPyObject 11 | 12 | # 13 | # 14 | # 15 | #type PythonList* = ref object of PythonObject 16 | type PythonList* = ref object of PythonObject 17 | type PythonTuple* = ref object of PythonObject 18 | type PythonDict* = ref object of PythonObject 19 | 20 | type CommonPythonObject = PythonObject or PythonList or PythonTuple or PythonList 21 | # 22 | # 23 | # 24 | #type PythonObjectable* = PythonObject or PPyObject or float or float64 or int32 or int64 or int or string or cstring or bool 25 | #type PythonObjectable* = PythonObject or float or float64 or int32 or int64 or int or string or cstring or bool 26 | type PythonObjectable* = PythonObject or PythonDict or PythonTuple or PythonList or float or float64 or int32 or int64 or int or string or cstring or bool 27 | type PythonNativeObjectable* = float or float64 or int32 or int64 or int or string or cstring or bool 28 | 29 | # 30 | # 31 | # 32 | var pythonReferences*: seq[PythonObject] 33 | var pythonEnvironmentModule*: PythonObject 34 | #var pythonEnvironmentObject*: PythonObject 35 | #var pythonEnvironment*: PythonDict = cast[PythonDict](PyDict_New()) 36 | var pythonEnvironmentObject*: PythonObject 37 | 38 | 39 | # 40 | # 41 | # 42 | proc addReference*[T](obj: var T): var T = 43 | pythonReferences.add(cast[PythonObject](obj)) 44 | return obj 45 | 46 | proc addReference*[T](obj: T): T = 47 | pythonReferences.add(cast[PythonObject](obj)) 48 | return obj 49 | 50 | proc addReference*(obj: PythonObject): PythonObject = 51 | pythonReferences.add(obj) 52 | return obj 53 | 54 | # 55 | # 56 | # 57 | proc initPythonObject*(): PythonObject = 58 | addReference(result) 59 | 60 | # 61 | # 62 | # 63 | template loadPythonModule*(name: string): system.stmt = 64 | discard PyRun_SimpleString("import " & name) 65 | 66 | # 67 | # 68 | # 69 | template execPython*(code: string): system.stmt = 70 | #if PyRun_String(code, file_input, cast[PythonObject](pythonEnvironment), cast[PythonObject](pythonEnvironment)).isNil: 71 | if PyRun_String(code, file_input, pythonEnvironmentObject, pythonEnvironmentObject).isNil: 72 | PyErr_Print() 73 | 74 | # 75 | # Clear the python object and the memory allocated 76 | # 77 | #proc release*[PythonObject](op: PythonObject) = 78 | proc releaseComplete*[T: CommonPythonObject](op: T) = 79 | if op == nil: return 80 | if op.ob_refcnt <= 0 or op.ob_type == nil or op.ob_type.tp_dealloc == nil: return 81 | op.ob_refcnt = 0 82 | op.ob_type.tp_dealloc(cast[PPyObject](op)) 83 | #execPython("gc.collect()") 84 | 85 | # 86 | # Clear the python object and the memory allocated 87 | # 88 | #template tryRelease*(op: var PythonObject): system.stmt = 89 | #proc release*(op: var PythonObject) = 90 | proc release*[T: CommonPythonObject](op: var T) = 91 | #proc release*(op: var CommonPythonObject) = 92 | Py_XDECREF(cast[PPyObject](op)) 93 | 94 | #proc release*(op: PythonObject) = 95 | proc release*[T: CommonPythonObject](op: T) = 96 | #proc release*(op: CommonPythonObject) = 97 | Py_XDECREF(cast[PPyObject](op)) 98 | 99 | # 100 | # 101 | # 102 | #proc pythonify*(x: var PythonObject): PythonObject {.inline.} = x 103 | proc pythonify*[T: CommonPythonObject](x: var T): T {.inline.} = x 104 | 105 | #proc pythonify*(x: PythonObject): PythonObject {.inline.} = x 106 | proc pythonify*[T: CommonPythonObject](x: T): T {.inline.} = x 107 | 108 | proc pythonify*(x: float): PythonObject {.inline.} = cast[PythonObject]( PyFloat_FromDouble(x) ) 109 | 110 | proc pythonify*(x: var float): PythonObject {.inline.} = cast[PythonObject]( PyFloat_FromDouble(x) ) 111 | 112 | #proc pythonify*(x: float64): PythonObject {.inline.} = PyFloat_FromDouble(x) 113 | 114 | #proc pythonify*(x: var float64): PythonObject {.inline.} = PyFloat_FromDouble(x) 115 | 116 | proc pythonify*(x: int): PythonObject {.inline.} = cast[PythonObject]( PyLong_FromLongLong(x) ) 117 | 118 | proc pythonify*(x: var int): PythonObject {.inline.} = cast[PythonObject]( PyLong_FromLongLong(x) ) 119 | 120 | proc pythonify*(x: int64): PythonObject {.inline.} = cast[PythonObject]( PyLong_FromLongLong(x) ) 121 | 122 | proc pythonify*(x: var int64): PythonObject {.inline.} = cast[PythonObject]( PyLong_FromLongLong(x) ) 123 | 124 | proc pythonify*(x: int32): PythonObject {.inline.} = cast[PythonObject]( PyLong_FromLong(x) ) 125 | 126 | proc pythonify*(x: var int32): PythonObject {.inline.} = cast[PythonObject]( PyLong_FromLong(x) ) 127 | 128 | proc pythonify*(x: string): PythonObject {.inline.} = cast[PythonObject]( PyString_FromString(cstring(x)) ) 129 | 130 | proc pythonify*(x: var string): PythonObject {.inline.} = cast[PythonObject]( PyString_FromString(cstring(x)) ) 131 | 132 | proc pythonify*(x: cstring): PythonObject {.inline.} = cast[PythonObject]( PyString_FromString(x) ) 133 | 134 | proc pythonify*(x: var cstring): PythonObject {.inline.} = cast[PythonObject]( PyString_FromString(x) ) 135 | 136 | proc pythonify*(x: bool): PythonObject {.inline.} = cast[PythonObject]( PyBool_FromLong(if cast[bool](x): 1 else: 0) ) 137 | 138 | proc pythonify*(x: var bool): PythonObject {.inline.} = cast[PythonObject]( PyBool_FromLong(if cast[bool](x): 1 else: 0) ) 139 | 140 | 141 | proc asFloat*(x: CommonPythonObject): float64 {.inline.} = 142 | if PyFloat_Check(cast[PPyObject](x)): return cast[PPyObject](x).PyFloat_AsDouble 143 | return NaN 144 | 145 | proc asCString*(x: CommonPythonObject): cstring {.inline.} = 146 | if PyString_Check(cast[PPyObject](x)): return cast[PPyObject](x).PyString_AsString 147 | return cast[PPyObject](x).PyObject_Repr.PyString_AsString 148 | 149 | proc asString*(x: CommonPythonObject): string {.inline.} = 150 | if PyString_Check(cast[PPyObject](x)): return $(cast[PPyObject](x).PyString_AsString) 151 | return $(cast[PPyObject](x).PyObject_Repr.PyString_AsString) 152 | 153 | proc asLong*(x: CommonPythonObject): int64 {.inline.} = 154 | if PyLong_Check(cast[PPyObject](x)): return cast[PPyObject](x).PyLong_AsLongLong 155 | return PyLong_FromString(cast[PPyObject](x).PyObject_Repr.PyString_AsString, cast[var cstring](nil), 10).PyLong_AsLongLong 156 | 157 | proc asInt*(x: CommonPythonObject): int32 {.inline.} = 158 | if PyLong_Check(cast[PPyObject](x)): return cast[PPyObject](x).PyLong_AsLong 159 | return PyLong_FromString(cast[PPyObject](x).PyObject_Repr.PyString_AsString, cast[var cstring](nil), 10).PyLong_AsLong 160 | 161 | proc `$`*(x: CommonPythonObject): string {.inline.} = $x.asString 162 | 163 | # 164 | #2 165 | # 166 | proc depythonify22*[U: PythonNativeObjectable](x: PythonObject, T: typedesc[U]): U = 167 | #template depythonify*[U: PythonNativeObjectable](x: PythonObject, T: typedesc[U]): U = 168 | #template depythonify*[U: PythonNativeObjectable](x: PythonObject, T: typedesc[U]): U = 169 | when T is float: 170 | return cast[U](x.PyFloat_AsDouble) 171 | elif T is float64: 172 | return cast[U](x.PyFloat_AsDouble) 173 | elif T is int: 174 | return cast[U](x.PyLong_AsLongLong) 175 | elif T is int64: 176 | return cast[U](x.PyLong_AsLong) 177 | elif T is int32: 178 | return cast[U](x.PyLong_AsLongLong) 179 | elif T is string: 180 | return cast[U]($(PyString_AsString(x))) 181 | elif T is cstring: 182 | return cast[U](PyString_AsString(x)) 183 | elif T is bool: return cast[U](x.PyObject_IsTrue) 184 | else: nil 185 | 186 | 187 | proc depythonif2y*[U: PythonNativeObjectable](x: PythonObject, T: typedesc[U]): U = 188 | if U is float: return cast[U](x.PyFloat_AsDouble) 189 | if U is float64: return cast[U](x.PyFloat_AsDouble) 190 | if U is int: return cast[U](x.PyLong_AsLongLong) 191 | if U is int64: return cast[U](x.PyLong_AsLong) 192 | if U is int32: return cast[U](x.PyLong_AsLongLong) 193 | if U is string: return cast[U]($(PyString_AsString(x))) 194 | if U is cstring: return cast[U](PyString_AsString(x)) 195 | if U is bool: return cast[U](x.PyObject_IsTrue) 196 | 197 | proc depythonify*[U: typedesc[float]](x: PythonObject, T: U): float = x.PyFloat_AsDouble 198 | 199 | proc depythonify*[U: float64](x: PythonObject, T: typedesc[U]): float64 = x.PyFloat_AsDouble 200 | 201 | proc depythonify*[U: int](x: PythonObject, T: typedesc[U]): int = cast[int](x.PyLong_AsLongLong) 202 | 203 | proc depythonify*[U: int64](x: PythonObject, T: typedesc[U]): int64 = x.PyLong_AsLongLong 204 | 205 | proc depythonify*[U: int32](x: PythonObject, T: typedesc[U]): int32 = x.PyLong_AsLong 206 | 207 | proc depythonify*[U: string](x: PythonObject, T: typedesc[U]): string = $x.PyString_AsString 208 | 209 | proc depythonify*[U: cstring](x: PythonObject, T: typedesc[U]): cstring = x.PyString_AsString 210 | 211 | proc depythonify*[U: bool](x: PythonObject, T: typedesc[U]): bool = x.PyObject_IsTrue 212 | 213 | template depythonify1*[U: PythonNativeObjectable](x: PythonObject, T: typedesc[U]): system.expr {.immediate.} = 214 | when T is float: x.PyFloat_AsDouble 215 | when T is float64: x.PyFloat_AsDouble 216 | when T is int: x.PyLong_AsLongLong 217 | when T is int64: x.PyLong_AsLong 218 | when T is int32: x.PyLong_AsLongLong 219 | when T is string: $(PyString_AsString(x)) 220 | when T is cstring: x.PyString_AsString 221 | when T is bool: x.PyObject_IsTrue 222 | 223 | # 224 | # 225 | # 226 | type PythonObjectAttr = ref object of PythonObject 227 | 228 | # 229 | # 230 | # 231 | proc `attrs`*(obj: var PythonObject): PythonObjectAttr {.inline.} = 232 | new(result) 233 | result = cast[PythonObjectAttr](obj) 234 | 235 | proc `attrs`*(obj: PythonObject): PythonObjectAttr {.inline.} = 236 | new(result) 237 | result = cast[PythonObjectAttr](obj) 238 | 239 | # 240 | # 241 | # 242 | proc getItem*(obj: PythonObjectAttr, attr: string): PythonObject {.inline.} = cast[PythonObject](PyObject_GetAttrString(cast[PythonObject](obj), cstring(attr))) 243 | 244 | proc `[]`*(obj: PythonObjectAttr, attr: string): PythonObject {.inline.} = getItem(obj, attr) 245 | 246 | proc setItem*[T](obj: PythonObjectAttr, attr: string, value: T) {.inline.} = discard PyObject_SetAttrString(cast[PythonObject](obj), cstring(attr), cast[PythonObject](value.pythonify)) 247 | 248 | proc `[]=`*[T](obj: PythonObjectAttr, attr: string, value: T) {.inline.} = setItem(obj, attr, value) 249 | 250 | 251 | 252 | # 253 | # Primitive functions 254 | # 255 | #proc PyList_Append*(ob1, ob2: PPyObject): int{.cdecl, importc, dynlib: dllname.} #- 256 | #proc PyList_AsTuple*(ob: PPyObject): PPyObject{.cdecl, importc, dynlib: dllname.} #+ 257 | #proc PyList_GetItem*(ob: PPyObject, i: int): PPyObject{.cdecl, importc, dynlib: dllname.} #- 258 | #proc PyList_GetSlice*(ob: PPyObject, i1, i2: int): PPyObject{.cdecl, importc, dynlib: dllname.} #- 259 | #proc PyList_Insert*(dp: PPyObject, idx: int, item: PPyObject): int{.cdecl, importc, dynlib: dllname.} #- 260 | #proc PyList_New*(size: int): PPyObject{.cdecl, importc, dynlib: dllname.} #- 261 | #proc PyList_Reverse*(ob: PPyObject): int{.cdecl, importc, dynlib: dllname.} #- 262 | #proc PyList_SetItem*(dp: PPyObject, idx: int, item: PPyObject): int{.cdecl, importc, dynlib: dllname.} #- 263 | #proc PyList_SetSlice*(ob: PPyObject, i1, i2: int, ob2: PPyObject): int{. 264 | # cdecl, importc, dynlib: dllname.} #+ 265 | #proc PyList_Size*(ob: PPyObject): int{.cdecl, importc, dynlib: dllname.} #- 266 | #proc PyList_Sort*(ob: PPyObject): int{.cdecl, importc, dynlib: dllname.} #- 267 | 268 | 269 | # 270 | # 271 | # 272 | proc newPythonList*(obj: PythonObject): PythonList {.inline.} = 273 | result = cast[PythonList](obj.addReference()) 274 | 275 | # 276 | # 277 | # 278 | proc newPythonList*(obj: var PythonObject): PythonList {.inline.} = 279 | result = cast[PythonList](obj.addReference()) 280 | 281 | # 282 | # 283 | # 284 | proc newPythonList*(size: int): PythonList {.inline.} = 285 | result = cast[PythonList](cast[PythonObject](PyList_New(size)).addReference()) 286 | 287 | # 288 | # 289 | # 290 | proc pythonify*[T](data: var openarray[T]): PythonList {.inline.} = 291 | result = newPythonList(data.len) 292 | for index, value in mpairs(data): 293 | result[index] = value.pythonify 294 | 295 | proc pythonify*[T](data: openarray[T]): PythonList {.inline.} = 296 | result = newPythonList(data.len) 297 | for index, value in pairs(data): 298 | result[index] = value.pythonify 299 | 300 | # 301 | # 302 | # 303 | proc asPyList*(obj: PythonObject): PythonList {.inline.} = newPythonList(obj) 304 | 305 | # 306 | # 307 | # 308 | proc asList*(obj: PythonList, T: typedesc): seq[T] {.inline.} = 309 | result = newSeq[T]() 310 | for i in countup(0, obj.len-1): 311 | result.add(cast[T](obj[i].depythonify(T))) 312 | 313 | proc asList*[U](obj: PythonObject, T: typedesc[U]): seq[U] {.inline.} = 314 | result = asList(obj.asPyList, T) 315 | 316 | # 317 | # 318 | # 319 | proc len*(p: PythonList): Natural {.inline.} = PyList_Size(cast[PPyObject](p)) 320 | 321 | # 322 | # 323 | # 324 | proc sort*(p: PythonList) {.inline.} = discard PyList_Sort(cast[PPyObject](p)) 325 | 326 | # 327 | # 328 | # 329 | proc reverse*(p: PythonList) {.inline.} = discard PyList_Reverse(cast[PPyObject](p)) 330 | 331 | # 332 | # 333 | # 334 | proc getItem*(p: PythonList, index: Natural): PythonObject {.inline.} = PyList_GetItem(cast[PPyObject](p), index) 335 | 336 | proc `[]`*(p: PythonList, index: Natural): PythonObject {.inline.} = getItem(p, index) 337 | 338 | proc getItem*(p: var PythonList, index: Natural): PythonObject {.inline.} = PyList_GetItem(cast[PPyObject](p), index) 339 | 340 | proc `[]`*(p: var PythonList, index: Natural): PythonObject {.inline.} = getItem(p, index) 341 | 342 | # 343 | # 344 | # 345 | proc insertItem*(p: var PythonList, index: Natural, val: PythonObjectable) {.inline.} = discard PyList_Insert(cast[PPyObject](p), index, val.pythonify) 346 | # 347 | # 348 | # 349 | proc setItem*(p: var PythonList, index: Natural, val: PythonObjectable) {.inline.} = discard PyList_SetItem(cast[PPyObject](p), index, cast[PPyObject](val.pythonify)) 350 | 351 | proc `[]=`*(p: var PythonList, index: Natural, val: PythonObjectable) {.inline.} = setItem(p, index, val) 352 | 353 | # 354 | # 355 | # 356 | proc getSlice*(p: PythonList, indexA: Natural, indexB: Natural): PythonObject {.inline.} = PyList_GetSlice(cast[PPyObject](p), indexA, indexB) 357 | 358 | proc `[]`*(p: PythonList, indexA: Natural, indexB: Natural): PythonObject {.inline.} = getSlice(p, indexA, indexB) 359 | 360 | proc getSlice*(p: var PythonList, indexA: Natural, indexB: Natural): PythonObject {.inline.} = PyList_GetSlice(cast[PPyObject](p), indexA, indexB) 361 | 362 | proc `[]`*(p: var PythonList, indexA: Natural, indexB: Natural): PythonObject {.inline.} = getSlice(p, indexA, indexB) 363 | 364 | # 365 | # 366 | # 367 | proc setSlice*(p: var PythonList, indexA: Natural, indexB: Natural, val: PythonObjectable) {.inline.} = discard PyList_SetSlice(p, indexA, indexB, val.pythonify) 368 | 369 | proc `[]=`*(p: var PythonList, indexA: Natural, indexB: Natural, val: PythonObjectable) {.inline.} = setSlice(p, indexA, indexB, val) 370 | 371 | # 372 | # 373 | # 374 | proc appendItem*(p: var PythonList, obj: PythonObjectable) {.inline.} = discard PyList_Append(p, obj.pythonify) 375 | 376 | # 377 | # 378 | # 379 | #proc asPyTuple*(p: PythonList): PythonTuple {.inline.} = newPythonTuple(PyList_AsTuple(p)) 380 | #proc asPyTuple*(p: var PythonList): PythonTuple {.inline.} = newPythonTuple(PyList_AsTuple(p)) 381 | 382 | 383 | # 384 | # Primitive functions 385 | # 386 | #proc PyTuple_GetItem*(ob: PPyObject, i: int): PPyObject{.cdecl, importc, dynlib: dllname.} #- 387 | #proc PyTuple_GetSlice*(ob: PPyObject, i1, i2: int): PPyObject{.cdecl, importc, dynlib: dllname.} #+ 388 | #proc PyTuple_New*(size: int): PPyObject{.cdecl, importc, dynlib: dllname.} #+ 389 | #proc PyTuple_SetItem*(ob: PPyObject, key: int, value: PPyObject): int{.cdecl, importc, dynlib: dllname.} #+ 390 | #proc PyTuple_Size*(ob: PPyObject): int{.cdecl, importc, dynlib: dllname.} #+ 391 | 392 | # 393 | # 394 | # 395 | proc newPythonTuple*(obj: PythonObject): PythonTuple {.inline.} = 396 | result = cast[PythonTuple](obj.addReference()) 397 | 398 | proc newPythonTuple*(obj: var PythonObject): PythonTuple {.inline.} = 399 | result = cast[PythonTuple](obj.addReference()) 400 | 401 | # 402 | # 403 | # 404 | proc newPythonTuple*(size: int): PythonTuple {.inline.} = 405 | result = cast[PythonTuple](PyTuple_New(size).addReference()) 406 | 407 | # 408 | # 409 | # 410 | proc asPythonTuple*[T](data: openarray[T]): PythonTuple {.inline.} = 411 | result = newPythonTuple(data.len) 412 | for index, value in pairs(data): 413 | result[index] = value.pythonify 414 | 415 | # 416 | # 417 | # 418 | proc asPyTuple*(obj: PPyObject): PythonTuple {.inline.} = newPythonTuple(obj) 419 | 420 | # 421 | # 422 | # 423 | proc len*(p: PythonTuple): Natural {.inline.} = PyTuple_Size(cast[PythonObject](p)) 424 | 425 | 426 | # 427 | # 428 | # 429 | proc getItem*(p: PythonTuple, index: Natural): PythonObject {.inline.} = PyTuple_GetItem(cast[PythonObject](p), index) 430 | 431 | proc getItem*(p: var PythonTuple, index: Natural): PythonObject {.inline.} = PyTuple_GetItem(cast[PythonObject](p), index) 432 | 433 | proc `[]`*(p: PythonTuple, index: Natural): PythonObject {.inline.} = getItem(p, index) 434 | 435 | proc `[]`*(p: var PythonTuple, index: Natural): PythonObject {.inline.} = getItem(p, index) 436 | 437 | # 438 | # 439 | # 440 | proc setItem*(p: var PythonTuple, index: Natural, val: PythonObjectable) {.inline.} = discard PyTuple_SetItem(cast[PythonObject](p), index, val.pythonify) 441 | 442 | proc `[]=`*(p: var PythonTuple, index: Natural, val: PythonObjectable) {.inline.} = setItem(p, index, val) 443 | 444 | # 445 | # 446 | # 447 | proc getSlice*(p: var PythonTuple, indexA: Natural, indexB: Natural): PythonObject {.inline.} = PyTuple_GetSlice(cast[PythonObject](p), indexA, indexB) 448 | 449 | proc `[]`*(p: var PythonTuple, indexA: Natural, indexB: Natural): PythonObject {.inline.} = getSlice(p, indexA, indexB) 450 | 451 | # 452 | # Primitive functions 453 | # 454 | #proc PyDict_GetItem*(mp, key: PPyObject): PPyObject{.cdecl, importc, dynlib: dllname.} 455 | #proc PyDict_SetItem*(mp, key, item: PPyObject): int{.cdecl, importc, dynlib: dllname.} 456 | #proc PyDict_DelItem*(mp, key: PPyObject): int{.cdecl, importc, dynlib: dllname.} 457 | #proc PyDict_Clear*(mp: PPyObject){.cdecl, importc, dynlib: dllname.} 458 | #proc PyDict_Next*(mp: PPyObject, pos: PInt, key, value: PPPyObject): int{. 459 | # cdecl, importc, dynlib: dllname.} 460 | #proc PyDict_Keys*(mp: PPyObject): PPyObject{.cdecl, importc, dynlib: dllname.} 461 | #proc PyDict_Values*(mp: PPyObject): PPyObject{.cdecl, importc, dynlib: dllname.} 462 | #proc PyDict_Items*(mp: PPyObject): PPyObject{.cdecl, importc, dynlib: dllname.} 463 | #proc PyDict_Size*(mp: PPyObject): int{.cdecl, importc, dynlib: dllname.} 464 | #proc PyDict_DelItemString*(dp: PPyObject, key: cstring): int{.cdecl, importc, dynlib: dllname.} 465 | #proc PyDict_New*(): PPyObject{.cdecl, importc, dynlib: dllname.} 466 | #proc PyDict_GetItemString*(dp: PPyObject, key: cstring): PPyObject{.cdecl, importc, dynlib: dllname.} 467 | #proc PyDict_SetItemString*(dp: PPyObject, key: cstring, item: PPyObject): int{. 468 | # cdecl, importc, dynlib: dllname.} 469 | 470 | import tables 471 | 472 | # 473 | # 474 | # 475 | proc newPythonDict*(obj: PythonObject): PythonDict {.inline.} = cast[PythonDict](obj).addReference() 476 | 477 | proc newPythonDict*(obj: var PythonObject): PythonDict {.inline.} = cast[PythonDict](obj).addReference() 478 | 479 | # 480 | # 481 | # 482 | proc newPythonDict*(): PythonDict {.inline.} = 483 | result = cast[PythonDict](PyDict_New()).addReference() 484 | 485 | # 486 | # 487 | # 488 | proc pythonify*[K, V](data: Table[K, V]): PythonDict {.inline.} = 489 | result = newPythonDict(data.len) 490 | for index, value in pairs(data): 491 | result[index.pythonify] = value.pythonify 492 | 493 | proc pythonify*[K, V](data: var Table[K, V]): PythonDict {.inline.} = 494 | result = newPythonDict(data.len) 495 | for index, value in pairs(data): 496 | result[index.pythonify] = value.pythonify 497 | 498 | # 499 | # 500 | # 501 | proc asPyDict*(obj: PythonObject): PythonDict {.inline.} = newPythonDict(obj) 502 | 503 | proc asPyDict*(obj: var PythonObject): PythonDict {.inline.} = newPythonDict(obj) 504 | 505 | # 506 | # 507 | # 508 | proc len*(p: PythonDict): Natural {.inline.} = PyDict_Size(cast[PythonObject](p)) 509 | 510 | # 511 | # 512 | # 513 | proc clear*(p: PythonDict) {.inline.} = PyDict_Clear(cast[PythonObject](p)) 514 | 515 | # 516 | # 517 | # 518 | proc items*(p: PythonDict): PythonTuple {.inline.} = newPythonTuple(PyDict_Items(cast[PythonObject](p))) 519 | 520 | # 521 | # 522 | # 523 | proc keys*(p: PythonDict): PythonTuple {.inline.} = newPythonTuple(PyDict_Keys(cast[PythonObject](p))) 524 | 525 | # 526 | # 527 | # 528 | proc values*(p: PythonDict): PythonTuple {.inline.} = newPythonTuple(PyDict_Values(cast[PythonObject](p))) 529 | 530 | # 531 | # 532 | # 533 | proc getItem*(p: PythonDict, index: PythonObjectable): PythonObject {.inline.} = PyDict_GetItem(cast[PythonObject](p), cast[PythonObject](index.pythonify)) 534 | proc getItem*(p: var PythonDict, index: PythonObjectable): PythonObject {.inline.} = PyDict_GetItem(cast[PythonObject](p), cast[PythonObject](index.pythonify)) 535 | 536 | proc `[]`*(p: PythonDict, index: PythonObjectable): PythonObject {.inline.} = getItem(p, index) 537 | proc `[]`*(p: var PythonDict, index: PythonObjectable): PythonObject {.inline.} = getItem(p, index) 538 | 539 | proc getItem*(p: PythonDict, index: string): PythonObject {.inline.} = PyDict_GetItemString(cast[PythonObject](p), cstring(index)) 540 | proc getItem*(p: var PythonDict, index: string): PythonObject {.inline.} = PyDict_GetItemString(cast[PythonObject](p), cstring(index)) 541 | 542 | proc `[]`*(p: PythonDict, index: string): PythonObject {.inline.} = getItem(p, index) 543 | proc `[]`*(p: var PythonDict, index: string): PythonObject {.inline.} = getItem(p, index) 544 | 545 | # 546 | # 547 | # 548 | proc setItem*(p: PythonDict, index: PythonObjectable, val: PythonObjectable) {.inline.} = discard PyDict_SetItem(cast[PythonObject](p), cast[PythonObject](index.pythonify), cast[PythonObject](val.pythonify)) 549 | proc setItem*(p: var PythonDict, index: PythonObjectable, val: PythonObjectable) {.inline.} = discard PyDict_SetItem(cast[PythonObject](p), cast[PythonObject](index.pythonify), cast[PythonObject](val.pythonify)) 550 | 551 | proc `[]=`*(p: PythonDict, index: PythonObjectable, val: PythonObjectable) {.inline.} = setItem(p, index, val) 552 | proc `[]=`*(p: var PythonDict, index: PythonObjectable, val: PythonObjectable) {.inline.} = setItem(p, index, val) 553 | 554 | proc setItem*(p: PythonDict, index: string, val: PythonObjectable) {.inline.} = discard PyDict_SetItemString(cast[PythonObject](p), cstring(index), cast[PythonObject](val.pythonify)) 555 | proc setItem*(p: var PythonDict, index: string, val: PythonObjectable) {.inline.} = discard PyDict_SetItemString(cast[PythonObject](p), cstring(index), cast[PythonObject](val.pythonify)) 556 | 557 | proc `[]=`*(p: PythonDict, index: string, val: PythonObjectable) {.inline.} = setItem(p, index, val) 558 | proc `[]=`*(p: var PythonDict, index: string, val: PythonObjectable) {.inline.} = setItem(p, index, val) 559 | 560 | # 561 | # 562 | # 563 | proc delItem*(p: PythonDict, index: PythonObjectable) {.inline.} = discard PyDict_DelItem(cast[PythonObject](p), cast[PythonObject](index.pythonify)) 564 | proc delItem*(p: var PythonDict, index: PythonObjectable) {.inline.} = discard PyDict_DelItem(cast[PythonObject](p), cast[PythonObject](index.pythonify)) 565 | 566 | proc delItem*(p: PythonDict, index: string) {.inline.} = discard PyDict_DelItemString(cast[PythonObject](p), cstring(index)) 567 | proc delItem*(p: var PythonDict, index: string) {.inline.} = discard PyDict_DelItemString(cast[PythonObject](p), cstring(index)) 568 | 569 | 570 | 571 | proc proc1() = 572 | var list1 = newPythonList(10_000_000) 573 | for i in countup(0, 10_000_000-1): 574 | list1[i] = i 575 | release(list1) 576 | list1.release() 577 | 578 | 579 | ##var pythonEnvironment*: PythonDict 580 | 581 | 582 | #var pythonEnvironment*: PythonDict 583 | 584 | # 585 | # 586 | # 587 | template pythonEnvironment*(): PythonDict = cast[PythonDict](pythonEnvironmentObject) 588 | 589 | # 590 | # 591 | # 592 | #template initializePython*(): system.stmt = 593 | template initializePython*(initializeScripts=true) = #: system.stmt = 594 | #proc initializePython*() = 595 | Py_Initialize() 596 | pythonReferences = newSeq[PythonObject]() 597 | pythonEnvironmentModule = PyImport_AddModule("__main__") 598 | pythonEnvironmentObject = PyModule_GetDict(pythonEnvironmentModule) 599 | if initializeScripts: 600 | allowLocalPythonScripts() 601 | 602 | # 603 | # 604 | # 605 | template finishingPython*(): system.stmt = 606 | Py_Finalize() 607 | 608 | # 609 | # 610 | # 611 | template releasePythonObjects*(finishing = true): system.stmt = 612 | for pythonRef in pythonReferences: 613 | pythonRef.release() 614 | if finishing: 615 | finishingPython() 616 | 617 | # 618 | # Allow to load local scripts 619 | # 620 | template allowLocalPythonScripts*(): system.stmt = 621 | execPython("import os, sys, gc") 622 | execPython("sys.path.insert(0, os.getcwd())") 623 | 624 | 625 | initializePython() 626 | if isMainModule: 627 | initializePython() 628 | allowLocalPythonScripts() 629 | execPython("a=1") 630 | #var pythonEnvironment = cast[PythonDict](pythonEnvironmentObject) 631 | echo "FROM PYTHON: ", pythonEnvironment["a"] 632 | execPython("print 'Hello world'") 633 | execPython(""" 634 | def examp(o): 635 | print 'Hello world ' + str(o) 636 | """) 637 | execPython("examp(2)") 638 | execPython("examp('again')") 639 | proc1() 640 | echo "---" 641 | proc1() 642 | echo "---" 643 | proc1() 644 | echo "---" 645 | proc1() 646 | echo "---" 647 | proc1() 648 | echo "---" 649 | proc1() 650 | echo "---" 651 | proc1() 652 | echo "---" 653 | proc1() 654 | echo "---" 655 | proc1() 656 | echo "---" 657 | proc1() 658 | echo "---" 659 | proc1() 660 | finishingPython() 661 | 662 | 663 | -------------------------------------------------------------------------------- /tests/nimcache/pythonize_md5_pythonize.c: -------------------------------------------------------------------------------- 1 | /* Generated by Nim Compiler v0.12.0 */ 2 | /* (c) 2015 Andreas Rumpf */ 3 | /* The generated code is subject to the original license. */ 4 | /* Compiled for: Linux, amd64, gcc */ 5 | /* Command for C compiler: 6 | gcc -c -w -g3 -O0 -I/media/marco/Research/Applications/aporia/Nim/lib -o /home/marco/.nimble/pkgs/Pythonize27-1.0.0/tests/nimcache/pythonize_md5_pythonize.o /home/marco/.nimble/pkgs/Pythonize27-1.0.0/tests/nimcache/pythonize_md5_pythonize.c */ 7 | #define NIM_INTBITS 64 8 | 9 | #include "nimbase.h" 10 | #include 11 | #include 12 | typedef struct NimStringDesc NimStringDesc; 13 | typedef struct TGenericSeq TGenericSeq; 14 | typedef struct Memregion31291 Memregion31291; 15 | typedef struct Gcheap51418 Gcheap51418; 16 | typedef struct Gcstack51416 Gcstack51416; 17 | typedef struct Cellseq49363 Cellseq49363; 18 | typedef struct Cell49347 Cell49347; 19 | typedef struct Cellset49359 Cellset49359; 20 | typedef struct Pagedesc49355 Pagedesc49355; 21 | typedef struct Smallchunk31243 Smallchunk31243; 22 | typedef struct Llchunk31285 Llchunk31285; 23 | typedef struct Bigchunk31245 Bigchunk31245; 24 | typedef struct Intset31217 Intset31217; 25 | typedef struct Trunk31213 Trunk31213; 26 | typedef struct Avlnode31289 Avlnode31289; 27 | typedef struct Gcstat51414 Gcstat51414; 28 | typedef struct TNimType TNimType; 29 | typedef struct PythondictHEX3Aobjecttype130025 PythondictHEX3Aobjecttype130025; 30 | typedef struct Tpyobject125574 Tpyobject125574; 31 | typedef struct TY130058 TY130058; 32 | typedef struct Basechunk31241 Basechunk31241; 33 | typedef struct Freecell31233 Freecell31233; 34 | typedef struct TNimNode TNimNode; 35 | typedef struct Tpytypeobject125626 Tpytypeobject125626; 36 | typedef struct Tpynumbermethods125556 Tpynumbermethods125556; 37 | typedef struct Tpysequencemethods125560 Tpysequencemethods125560; 38 | typedef struct Tpymappingmethods125564 Tpymappingmethods125564; 39 | typedef struct Tpybufferprocs125568 Tpybufferprocs125568; 40 | typedef struct Tpymethoddef125586 Tpymethoddef125586; 41 | typedef struct Tpymemberdef125590 Tpymemberdef125590; 42 | typedef struct Tpygetsetdef125598 Tpygetsetdef125598; 43 | struct TGenericSeq { 44 | NI len; 45 | NI reserved; 46 | }; 47 | struct NimStringDesc { 48 | TGenericSeq Sup; 49 | NIM_CHAR data[SEQ_DECL_SIZE]; 50 | }; 51 | struct Cellseq49363 { 52 | NI len; 53 | NI cap; 54 | Cell49347** d; 55 | }; 56 | struct Cellset49359 { 57 | NI counter; 58 | NI max; 59 | Pagedesc49355* head; 60 | Pagedesc49355** data; 61 | }; 62 | typedef Smallchunk31243* TY31306[512]; 63 | typedef Trunk31213* Trunkbuckets31215[256]; 64 | struct Intset31217 { 65 | Trunkbuckets31215 data; 66 | }; 67 | struct Memregion31291 { 68 | NI minlargeobj; 69 | NI maxlargeobj; 70 | TY31306 freesmallchunks; 71 | Llchunk31285* llmem; 72 | NI currmem; 73 | NI maxmem; 74 | NI freemem; 75 | NI lastsize; 76 | Bigchunk31245* freechunkslist; 77 | Intset31217 chunkstarts; 78 | Avlnode31289* root; 79 | Avlnode31289* deleted; 80 | Avlnode31289* last; 81 | Avlnode31289* freeavlnodes; 82 | }; 83 | struct Gcstat51414 { 84 | NI stackscans; 85 | NI cyclecollections; 86 | NI maxthreshold; 87 | NI maxstacksize; 88 | NI maxstackcells; 89 | NI cycletablesize; 90 | NI64 maxpause; 91 | }; 92 | struct Gcheap51418 { 93 | Gcstack51416* stack; 94 | void* stackbottom; 95 | NI cyclethreshold; 96 | Cellseq49363 zct; 97 | Cellseq49363 decstack; 98 | Cellset49359 cycleroots; 99 | Cellseq49363 tempstack; 100 | NI recgclock; 101 | Memregion31291 region; 102 | Gcstat51414 stat; 103 | }; 104 | struct Cell49347 { 105 | NI refcount; 106 | TNimType* typ; 107 | }; 108 | typedef N_CDECL_PTR(NI, TY126655) (Tpyobject125574* dp, NCSTRING key, Tpyobject125574* item); 109 | typedef N_CDECL_PTR(Tpyobject125574*, TY126702) (NCSTRING str); 110 | typedef N_CDECL_PTR(Tpyobject125574*, TY126681) (NCSTRING str, NI start, Tpyobject125574* globals, Tpyobject125574* locals); 111 | typedef N_CDECL_PTR(void, TY126509) (void); 112 | typedef N_CDECL_PTR(Tpyobject125574*, TY126648) (Tpyobject125574* dp, NCSTRING key); 113 | typedef N_CDECL_PTR(void, TY127892) (void); 114 | struct Gcstack51416 { 115 | Gcstack51416* prev; 116 | Gcstack51416* next; 117 | void* starts; 118 | void* pos; 119 | NI maxstacksize; 120 | }; 121 | typedef NI TY31222[8]; 122 | struct Pagedesc49355 { 123 | Pagedesc49355* next; 124 | NI key; 125 | TY31222 bits; 126 | }; 127 | struct Basechunk31241 { 128 | NI prevsize; 129 | NI size; 130 | NIM_BOOL used; 131 | }; 132 | struct Smallchunk31243 { 133 | Basechunk31241 Sup; 134 | Smallchunk31243* next; 135 | Smallchunk31243* prev; 136 | Freecell31233* freelist; 137 | NI free; 138 | NI acc; 139 | NF data; 140 | }; 141 | struct Llchunk31285 { 142 | NI size; 143 | NI acc; 144 | Llchunk31285* next; 145 | }; 146 | struct Bigchunk31245 { 147 | Basechunk31241 Sup; 148 | Bigchunk31245* next; 149 | Bigchunk31245* prev; 150 | NI align; 151 | NF data; 152 | }; 153 | struct Trunk31213 { 154 | Trunk31213* next; 155 | NI key; 156 | TY31222 bits; 157 | }; 158 | typedef Avlnode31289* TY31296[2]; 159 | struct Avlnode31289 { 160 | TY31296 link; 161 | NI key; 162 | NI upperbound; 163 | NI level; 164 | }; 165 | typedef N_NIMCALL_PTR(void, TY3889) (void* p, NI op); 166 | typedef N_NIMCALL_PTR(void*, TY3894) (void* p); 167 | struct TNimType { 168 | NI size; 169 | NU8 kind; 170 | NU8 flags; 171 | TNimType* base; 172 | TNimNode* node; 173 | void* finalizer; 174 | TY3889 marker; 175 | TY3894 deepcopy; 176 | }; 177 | struct Tpyobject125574 { 178 | NI obrefcnt; 179 | Tpytypeobject125626* obtype; 180 | }; 181 | struct PythondictHEX3Aobjecttype130025 { 182 | Tpyobject125574 Sup; 183 | }; 184 | struct Freecell31233 { 185 | Freecell31233* next; 186 | NI zerofield; 187 | }; 188 | struct TNimNode { 189 | NU8 kind; 190 | NI offset; 191 | TNimType* typ; 192 | NCSTRING name; 193 | NI len; 194 | TNimNode** sons; 195 | }; 196 | typedef N_CDECL_PTR(void, Tpydestructor125508) (Tpyobject125574* ob); 197 | typedef N_CDECL_PTR(NI, Tprintfunc125510) (Tpyobject125574* ob, FILE* f, NI i); 198 | typedef N_CDECL_PTR(Tpyobject125574*, Tgetattrfunc125512) (Tpyobject125574* ob1, NCSTRING name); 199 | typedef N_CDECL_PTR(NI, Tsetattrfunc125514) (Tpyobject125574* ob1, NCSTRING name, Tpyobject125574* ob2); 200 | typedef N_CDECL_PTR(NI, Tcmpfunc125516) (Tpyobject125574* ob1, Tpyobject125574* ob2); 201 | typedef N_CDECL_PTR(Tpyobject125574*, Treprfunc125518) (Tpyobject125574* ob); 202 | typedef N_CDECL_PTR(NI32, Thashfunc125520) (Tpyobject125574* ob); 203 | typedef N_CDECL_PTR(Tpyobject125574*, Tternaryfunc125492) (Tpyobject125574* ob1, Tpyobject125574* ob2, Tpyobject125574* ob3); 204 | typedef N_CDECL_PTR(Tpyobject125574*, Tgetattrofunc125522) (Tpyobject125574* ob1, Tpyobject125574* ob2); 205 | typedef N_CDECL_PTR(NI, Tsetattrofunc125524) (Tpyobject125574* ob1, Tpyobject125574* ob2, Tpyobject125574* ob3); 206 | typedef N_CDECL_PTR(NI, Tvisitproc125536) (Tpyobject125574* ob1, void* p); 207 | typedef N_CDECL_PTR(NI, Ttraverseproc125538) (Tpyobject125574* ob1, Tvisitproc125536 prc, void* p); 208 | typedef N_CDECL_PTR(NI, Tinquiry125494) (Tpyobject125574* ob1); 209 | typedef N_CDECL_PTR(Tpyobject125574*, Trichcmpfunc125540) (Tpyobject125574* ob1, Tpyobject125574* ob2, NI i); 210 | typedef N_CDECL_PTR(Tpyobject125574*, Tgetiterfunc125542) (Tpyobject125574* ob1); 211 | typedef N_CDECL_PTR(Tpyobject125574*, Titernextfunc125544) (Tpyobject125574* ob1); 212 | typedef N_CDECL_PTR(Tpyobject125574*, Tdescrgetfunc125546) (Tpyobject125574* ob1, Tpyobject125574* ob2, Tpyobject125574* ob3); 213 | typedef N_CDECL_PTR(NI, Tdescrsetfunc125548) (Tpyobject125574* ob1, Tpyobject125574* ob2, Tpyobject125574* ob3); 214 | typedef N_CDECL_PTR(NI, Tinitproc125550) (Tpyobject125574* self, Tpyobject125574* args, Tpyobject125574* kwds); 215 | typedef N_CDECL_PTR(Tpyobject125574*, Tallocfunc125554) (Tpytypeobject125626* self, NI nitems); 216 | typedef N_CDECL_PTR(Tpyobject125574*, Tnewfunc125552) (Tpytypeobject125626* subtype, Tpyobject125574* args, Tpyobject125574* kwds); 217 | struct Tpytypeobject125626 { 218 | Tpyobject125574 Sup; 219 | NI obsize; 220 | NCSTRING tpname; 221 | NI tpbasicsize; 222 | NI tpitemsize; 223 | Tpydestructor125508 tpdealloc; 224 | Tprintfunc125510 tpprint; 225 | Tgetattrfunc125512 tpgetattr; 226 | Tsetattrfunc125514 tpsetattr; 227 | Tcmpfunc125516 tpcompare; 228 | Treprfunc125518 tprepr; 229 | Tpynumbermethods125556* tpasnumber; 230 | Tpysequencemethods125560* tpassequence; 231 | Tpymappingmethods125564* tpasmapping; 232 | Thashfunc125520 tphash; 233 | Tternaryfunc125492 tpcall; 234 | Treprfunc125518 tpstr; 235 | Tgetattrofunc125522 tpgetattro; 236 | Tsetattrofunc125524 tpsetattro; 237 | Tpybufferprocs125568* tpasbuffer; 238 | NI32 tpflags; 239 | NCSTRING tpdoc; 240 | Ttraverseproc125538 tptraverse; 241 | Tinquiry125494 tpclear; 242 | Trichcmpfunc125540 tprichcompare; 243 | NI32 tpweaklistoffset; 244 | Tgetiterfunc125542 tpiter; 245 | Titernextfunc125544 tpiternext; 246 | Tpymethoddef125586* tpmethods; 247 | Tpymemberdef125590* tpmembers; 248 | Tpygetsetdef125598* tpgetset; 249 | Tpytypeobject125626* tpbase; 250 | Tpyobject125574* tpdict; 251 | Tdescrgetfunc125546 tpdescrget; 252 | Tdescrsetfunc125548 tpdescrset; 253 | NI32 tpdictoffset; 254 | Tinitproc125550 tpinit; 255 | Tallocfunc125554 tpalloc; 256 | Tnewfunc125552 tpnew; 257 | Tpydestructor125508 tpfree; 258 | Tinquiry125494 tpisgc; 259 | Tpyobject125574* tpbases; 260 | Tpyobject125574* tpmro; 261 | Tpyobject125574* tpcache; 262 | Tpyobject125574* tpsubclasses; 263 | Tpyobject125574* tpweaklist; 264 | void* tpxxx7; 265 | void* tpxxx8; 266 | }; 267 | typedef N_CDECL_PTR(Tpyobject125574*, Tbinaryfunc125490) (Tpyobject125574* ob1, Tpyobject125574* ob2); 268 | typedef N_CDECL_PTR(Tpyobject125574*, Tunaryfunc125488) (Tpyobject125574* ob1); 269 | typedef N_CDECL_PTR(NI, Tcoercion125496) (Tpyobject125574** ob1, Tpyobject125574** ob2); 270 | struct Tpynumbermethods125556 { 271 | Tbinaryfunc125490 nbadd; 272 | Tbinaryfunc125490 nbsubstract; 273 | Tbinaryfunc125490 nbmultiply; 274 | Tbinaryfunc125490 nbdivide; 275 | Tbinaryfunc125490 nbremainder; 276 | Tbinaryfunc125490 nbdivmod; 277 | Tternaryfunc125492 nbpower; 278 | Tunaryfunc125488 nbnegative; 279 | Tunaryfunc125488 nbpositive; 280 | Tunaryfunc125488 nbabsolute; 281 | Tinquiry125494 nbnonzero; 282 | Tunaryfunc125488 nbinvert; 283 | Tbinaryfunc125490 nblshift; 284 | Tbinaryfunc125490 nbrshift; 285 | Tbinaryfunc125490 nband; 286 | Tbinaryfunc125490 nbxor; 287 | Tbinaryfunc125490 nbor; 288 | Tcoercion125496 nbcoerce; 289 | Tunaryfunc125488 nbint; 290 | Tunaryfunc125488 nblong; 291 | Tunaryfunc125488 nbfloat; 292 | Tunaryfunc125488 nboct; 293 | Tunaryfunc125488 nbhex; 294 | Tbinaryfunc125490 nbinplaceadd; 295 | Tbinaryfunc125490 nbinplacesubtract; 296 | Tbinaryfunc125490 nbinplacemultiply; 297 | Tbinaryfunc125490 nbinplacedivide; 298 | Tbinaryfunc125490 nbinplaceremainder; 299 | Tternaryfunc125492 nbinplacepower; 300 | Tbinaryfunc125490 nbinplacelshift; 301 | Tbinaryfunc125490 nbinplacershift; 302 | Tbinaryfunc125490 nbinplaceand; 303 | Tbinaryfunc125490 nbinplacexor; 304 | Tbinaryfunc125490 nbinplaceor; 305 | Tbinaryfunc125490 nbfloordivide; 306 | Tbinaryfunc125490 nbtruedivide; 307 | Tbinaryfunc125490 nbinplacefloordivide; 308 | Tbinaryfunc125490 nbinplacetruedivide; 309 | }; 310 | typedef N_CDECL_PTR(Tpyobject125574*, Tintargfunc125498) (Tpyobject125574* ob1, NI i); 311 | typedef N_CDECL_PTR(Tpyobject125574*, Tintintargfunc125500) (Tpyobject125574* ob1, NI i1, NI i2); 312 | typedef N_CDECL_PTR(NI, Tintobjargproc125502) (Tpyobject125574* ob1, NI i, Tpyobject125574* ob2); 313 | typedef N_CDECL_PTR(NI, Tintintobjargproc125504) (Tpyobject125574* ob1, NI i1, NI i2, Tpyobject125574* ob2); 314 | typedef N_CDECL_PTR(NI, Tobjobjproc125534) (Tpyobject125574* ob1, Tpyobject125574* ob2); 315 | struct Tpysequencemethods125560 { 316 | Tinquiry125494 sqlength; 317 | Tbinaryfunc125490 sqconcat; 318 | Tintargfunc125498 sqrepeat; 319 | Tintargfunc125498 sqitem; 320 | Tintintargfunc125500 sqslice; 321 | Tintobjargproc125502 sqassitem; 322 | Tintintobjargproc125504 sqassslice; 323 | Tobjobjproc125534 sqcontains; 324 | Tbinaryfunc125490 sqinplaceconcat; 325 | Tintargfunc125498 sqinplacerepeat; 326 | }; 327 | typedef N_CDECL_PTR(NI, Tobjobjargproc125506) (Tpyobject125574* ob1, Tpyobject125574* ob2, Tpyobject125574* ob3); 328 | struct Tpymappingmethods125564 { 329 | Tinquiry125494 mplength; 330 | Tbinaryfunc125490 mpsubscript; 331 | Tobjobjargproc125506 mpasssubscript; 332 | }; 333 | typedef N_CDECL_PTR(NI, Tgetreadbufferproc125526) (Tpyobject125574* ob1, NI i, void* p); 334 | typedef N_CDECL_PTR(NI, Tgetwritebufferproc125528) (Tpyobject125574* ob1, NI i, void* p); 335 | typedef N_CDECL_PTR(NI, Tgetsegcountproc125530) (Tpyobject125574* ob1, NI i); 336 | typedef N_CDECL_PTR(NI, Tgetcharbufferproc125532) (Tpyobject125574* ob1, NI i, NCSTRING pstr); 337 | struct Tpybufferprocs125568 { 338 | Tgetreadbufferproc125526 bfgetreadbuffer; 339 | Tgetwritebufferproc125528 bfgetwritebuffer; 340 | Tgetsegcountproc125530 bfgetsegcount; 341 | Tgetcharbufferproc125532 bfgetcharbuffer; 342 | }; 343 | typedef N_CDECL_PTR(Tpyobject125574*, Tpycfunction125486) (Tpyobject125574* self, Tpyobject125574* args); 344 | struct Tpymethoddef125586 { 345 | NCSTRING mlname; 346 | Tpycfunction125486 mlmeth; 347 | NI mlflags; 348 | NCSTRING mldoc; 349 | }; 350 | struct Tpymemberdef125590 { 351 | NCSTRING name; 352 | NI thetype; 353 | NI offset; 354 | NI flags; 355 | NCSTRING doc; 356 | }; 357 | typedef N_CDECL_PTR(Tpyobject125574*, Tgetter125592) (Tpyobject125574* obj, void* context); 358 | typedef N_CDECL_PTR(NI, Tsetter125594) (Tpyobject125574* obj, Tpyobject125574* value, void* context); 359 | struct Tpygetsetdef125598 { 360 | NCSTRING name; 361 | Tgetter125592 get; 362 | Tsetter125594 setter; 363 | NCSTRING doc; 364 | void* closure; 365 | }; 366 | struct TY130058 { 367 | TGenericSeq Sup; 368 | Tpyobject125574* data[SEQ_DECL_SIZE]; 369 | }; 370 | N_NIMCALL(NimStringDesc*, copyStringRC1)(NimStringDesc* src); 371 | static N_INLINE(void, nimGCunrefNoCycle)(void* p); 372 | N_NIMCALL(NIM_BOOL, allocinv_38411)(Memregion31291* a); 373 | static N_INLINE(Cell49347*, usrtocell_53046)(void* usr); 374 | static N_INLINE(void, nimFrame)(TFrame* s); 375 | N_NOINLINE(void, stackoverflow_23601)(void); 376 | static N_INLINE(void, popFrame)(void); 377 | N_NIMCALL(NIM_BOOL, isallocatedptr_38407)(Memregion31291* a, void* p); 378 | static N_INLINE(void, Gcdisable_11201)(void); 379 | N_NIMCALL(void, writestacktrace_20207)(void); 380 | static N_INLINE(void, rtladdzct_54604)(Cell49347* c); 381 | N_NOINLINE(void, addzct_53017)(Cellseq49363* s, Cell49347* c); 382 | static N_INLINE(void, HEX5BHEX5DHEX3D_132009)(PythondictHEX3Aobjecttype130025* p, NimStringDesc* index, NimStringDesc* val); 383 | static N_INLINE(void, setitem_132019)(PythondictHEX3Aobjecttype130025* p, NimStringDesc* index, NimStringDesc* val); 384 | static N_INLINE(Tpyobject125574*, pythonify_130283)(NimStringDesc* x); 385 | N_NIMCALL(NimStringDesc*, depythonify_132067)(Tpyobject125574* x); 386 | static N_INLINE(Tpyobject125574*, HEX5BHEX5D_131477)(PythondictHEX3Aobjecttype130025* p, NimStringDesc* index); 387 | static N_INLINE(Tpyobject125574*, getitem_131452)(PythondictHEX3Aobjecttype130025* p, NimStringDesc* index); 388 | static N_INLINE(void, asgnRefNoCycle)(void** dest, void* src); 389 | N_NOINLINE(void, raiseIndexError)(void); 390 | N_NIMCALL(void, release_132212)(Tpyobject125574* op); 391 | static N_INLINE(NI, addInt)(NI a, NI b); 392 | N_NOINLINE(void, raiseOverflow)(void); 393 | N_NIMCALL(void, failedassertimpl_91603)(NimStringDesc* msg); 394 | static N_INLINE(void, initStackBottomWith)(void* locals); 395 | N_NOINLINE(void, setStackBottom)(void* thestackbottom); 396 | NIM_EXTERNC N_NOINLINE(void, systemInit000)(void); 397 | NIM_EXTERNC N_NOINLINE(void, systemDatInit000)(void); 398 | NIM_EXTERNC N_NOINLINE(void, HEX00_parseutilsInit000)(void); 399 | NIM_EXTERNC N_NOINLINE(void, HEX00_parseutilsDatInit000)(void); 400 | NIM_EXTERNC N_NOINLINE(void, HEX00_strutilsInit000)(void); 401 | NIM_EXTERNC N_NOINLINE(void, HEX00_strutilsDatInit000)(void); 402 | NIM_EXTERNC N_NOINLINE(void, HEX00_etcprivInit000)(void); 403 | NIM_EXTERNC N_NOINLINE(void, HEX00_etcprivDatInit000)(void); 404 | NIM_EXTERNC N_NOINLINE(void, HEX00_hashesInit000)(void); 405 | NIM_EXTERNC N_NOINLINE(void, HEX00_hashesDatInit000)(void); 406 | NIM_EXTERNC N_NOINLINE(void, HEX00_timesInit000)(void); 407 | NIM_EXTERNC N_NOINLINE(void, HEX00_timesDatInit000)(void); 408 | NIM_EXTERNC N_NOINLINE(void, HEX00_mathInit000)(void); 409 | NIM_EXTERNC N_NOINLINE(void, HEX00_mathDatInit000)(void); 410 | NIM_EXTERNC N_NOINLINE(void, HEX00_tablesInit000)(void); 411 | NIM_EXTERNC N_NOINLINE(void, HEX00_tablesDatInit000)(void); 412 | NIM_EXTERNC N_NOINLINE(void, HEX00_dynlibInit000)(void); 413 | NIM_EXTERNC N_NOINLINE(void, HEX00_dynlibDatInit000)(void); 414 | NIM_EXTERNC N_NOINLINE(void, python_pythonInit000)(void); 415 | NIM_EXTERNC N_NOINLINE(void, python_pythonDatInit000)(void); 416 | NIM_EXTERNC N_NOINLINE(void, pythonize_pythonizeInit000)(void); 417 | NIM_EXTERNC N_NOINLINE(void, pythonize_pythonizeDatInit000)(void); 418 | NIM_EXTERNC N_NOINLINE(void, md5_pythonizeInit000)(void); 419 | NIM_EXTERNC N_NOINLINE(void, md5_pythonizeDatInit000)(void); 420 | STRING_LITERAL(TMP511, "Hello world!", 12); 421 | STRING_LITERAL(TMP512, "[SYSASSERT] ", 12); 422 | STRING_LITERAL(TMP513, "begin nimGCunrefNoCycle", 23); 423 | STRING_LITERAL(TMP514, "[GCASSERT] ", 11); 424 | STRING_LITERAL(TMP515, "nimGCunrefNoCycle: isAllocatedPtr", 33); 425 | STRING_LITERAL(TMP516, "end nimGCunrefNoCycle 2", 23); 426 | STRING_LITERAL(TMP517, "end nimGCunrefNoCycle 5", 23); 427 | STRING_LITERAL(TMP518, "text", 4); 428 | STRING_LITERAL(TMP519, "encoded_text", 12); 429 | STRING_LITERAL(TMP520, "Text: ", 6); 430 | STRING_LITERAL(TMP521, "Encoded Text: ", 14); 431 | STRING_LITERAL(TMP523, "len(a) == L seq modified while iterating over it", 48); 432 | NimStringDesc* texttoencode_132004; 433 | extern Gcheap51418 gch_51459; 434 | extern TFrame* frameptr_20842; 435 | extern TY126655 Dl_126654; 436 | extern TY126702 Dl_126701; 437 | extern Tpyobject125574* pythonenvironmentobject_130069; 438 | extern TY126681 Dl_126680; 439 | extern TY126509 Dl_126508; 440 | NimStringDesc* encodedtext_132079; 441 | extern TY126648 Dl_126647; 442 | Tpyobject125574* pythonref_132096; 443 | extern TY130058* pythonreferences_130059; 444 | extern TY127892 Dl_127891; 445 | 446 | static N_INLINE(void, nimFrame)(TFrame* s) { 447 | NI LOC1; 448 | LOC1 = 0; 449 | { 450 | if (!(frameptr_20842 == NIM_NIL)) goto LA4; 451 | LOC1 = ((NI) 0); 452 | } 453 | goto LA2; 454 | LA4: ; 455 | { 456 | LOC1 = ((NI) ((NI16)((*frameptr_20842).calldepth + ((NI16) 1)))); 457 | } 458 | LA2: ; 459 | (*s).calldepth = ((NI16) (LOC1)); 460 | (*s).prev = frameptr_20842; 461 | frameptr_20842 = s; 462 | { 463 | if (!((*s).calldepth == ((NI16) 2000))) goto LA9; 464 | stackoverflow_23601(); 465 | } 466 | LA9: ; 467 | } 468 | 469 | static N_INLINE(void, popFrame)(void) { 470 | frameptr_20842 = (*frameptr_20842).prev; 471 | } 472 | 473 | static N_INLINE(Cell49347*, usrtocell_53046)(void* usr) { 474 | Cell49347* result; 475 | nimfr("usrToCell", "gc.nim") 476 | result = 0; 477 | nimln(131, "gc.nim"); 478 | result = ((Cell49347*) ((NI)((NU64)(((NI) (usr))) - (NU64)(((NI)sizeof(Cell49347)))))); 479 | popFrame(); 480 | return result; 481 | } 482 | 483 | static N_INLINE(void, Gcdisable_11201)(void) { 484 | nimfr("GC_disable", "gc.nim") 485 | nimln(976, "gc.nim"); 486 | gch_51459.recgclock += ((NI) 1); 487 | popFrame(); 488 | } 489 | 490 | static N_INLINE(void, rtladdzct_54604)(Cell49347* c) { 491 | nimfr("rtlAddZCT", "gc.nim") 492 | nimln(212, "gc.nim"); 493 | addzct_53017((&gch_51459.zct), c); 494 | popFrame(); 495 | } 496 | 497 | static N_INLINE(void, nimGCunrefNoCycle)(void* p) { 498 | Cell49347* c; 499 | nimfr("nimGCunrefNoCycle", "gc.nim") 500 | nimln(1365, "system.nim"); 501 | { 502 | NIM_BOOL LOC3; 503 | nimln(245, "gc.nim"); 504 | LOC3 = 0; 505 | LOC3 = allocinv_38411((&gch_51459.region)); 506 | if (!!(LOC3)) goto LA4; 507 | nimln(1366, "system.nim"); 508 | printf("%s%s\012", ((NimStringDesc*) &TMP512)? (((NimStringDesc*) &TMP512))->data:"nil", ((NimStringDesc*) &TMP513)? (((NimStringDesc*) &TMP513))->data:"nil"); 509 | nimln(1367, "system.nim"); 510 | exit(((NI) 1)); 511 | } 512 | LA4: ; 513 | nimln(246, "gc.nim"); 514 | c = usrtocell_53046(p); 515 | nimln(114, "gc.nim"); 516 | { 517 | NIM_BOOL LOC8; 518 | nimln(247, "gc.nim"); 519 | LOC8 = 0; 520 | LOC8 = isallocatedptr_38407((&gch_51459.region), ((void*) (c))); 521 | if (!!(LOC8)) goto LA9; 522 | nimln(115, "gc.nim"); 523 | printf("%s%s\012", ((NimStringDesc*) &TMP514)? (((NimStringDesc*) &TMP514))->data:"nil", ((NimStringDesc*) &TMP515)? (((NimStringDesc*) &TMP515))->data:"nil"); 524 | nimln(116, "gc.nim"); 525 | Gcdisable_11201(); 526 | nimln(117, "gc.nim"); 527 | writestacktrace_20207(); 528 | nimln(118, "gc.nim"); 529 | exit(((NI) 1)); 530 | } 531 | LA9: ; 532 | nimln(248, "gc.nim"); 533 | { 534 | nimln(180, "gc.nim"); 535 | (*c).refcount -= ((NI) 8); 536 | nimln(181, "gc.nim"); 537 | if (!((NU64)((*c).refcount) < (NU64)(((NI) 8)))) goto LA13; 538 | nimln(249, "gc.nim"); 539 | rtladdzct_54604(c); 540 | nimln(1365, "system.nim"); 541 | { 542 | NIM_BOOL LOC17; 543 | nimln(250, "gc.nim"); 544 | LOC17 = 0; 545 | LOC17 = allocinv_38411((&gch_51459.region)); 546 | if (!!(LOC17)) goto LA18; 547 | nimln(1366, "system.nim"); 548 | printf("%s%s\012", ((NimStringDesc*) &TMP512)? (((NimStringDesc*) &TMP512))->data:"nil", ((NimStringDesc*) &TMP516)? (((NimStringDesc*) &TMP516))->data:"nil"); 549 | nimln(1367, "system.nim"); 550 | exit(((NI) 1)); 551 | } 552 | LA18: ; 553 | } 554 | LA13: ; 555 | nimln(1365, "system.nim"); 556 | { 557 | NIM_BOOL LOC22; 558 | nimln(251, "gc.nim"); 559 | LOC22 = 0; 560 | LOC22 = allocinv_38411((&gch_51459.region)); 561 | if (!!(LOC22)) goto LA23; 562 | nimln(1366, "system.nim"); 563 | printf("%s%s\012", ((NimStringDesc*) &TMP512)? (((NimStringDesc*) &TMP512))->data:"nil", ((NimStringDesc*) &TMP517)? (((NimStringDesc*) &TMP517))->data:"nil"); 564 | nimln(1367, "system.nim"); 565 | exit(((NI) 1)); 566 | } 567 | LA23: ; 568 | popFrame(); 569 | } 570 | 571 | static N_INLINE(Tpyobject125574*, pythonify_130283)(NimStringDesc* x) { 572 | Tpyobject125574* result; 573 | Tpyobject125574* LOC1; 574 | nimfr("pythonify", "pythonize.nim") 575 | result = 0; 576 | nimln(119, "pythonize.nim"); 577 | LOC1 = 0; 578 | LOC1 = Dl_126701(x->data); 579 | result = ((Tpyobject125574*) (LOC1)); 580 | popFrame(); 581 | return result; 582 | } 583 | 584 | static N_INLINE(void, setitem_132019)(PythondictHEX3Aobjecttype130025* p, NimStringDesc* index, NimStringDesc* val) { 585 | Tpyobject125574* LOC1; 586 | NI LOC2; 587 | nimfr("setItem", "pythonize.nim") 588 | nimln(545, "pythonize.nim"); 589 | LOC1 = 0; 590 | LOC1 = pythonify_130283(val); 591 | LOC2 = 0; 592 | LOC2 = Dl_126654(((Tpyobject125574*) (p)), index->data, ((Tpyobject125574*) (LOC1))); 593 | popFrame(); 594 | } 595 | 596 | static N_INLINE(void, HEX5BHEX5DHEX3D_132009)(PythondictHEX3Aobjecttype130025* p, NimStringDesc* index, NimStringDesc* val) { 597 | nimfr("[]=", "pythonize.nim") 598 | nimln(548, "pythonize.nim"); 599 | setitem_132019(p, index, val); 600 | popFrame(); 601 | } 602 | 603 | static N_INLINE(Tpyobject125574*, getitem_131452)(PythondictHEX3Aobjecttype130025* p, NimStringDesc* index) { 604 | Tpyobject125574* result; 605 | nimfr("getItem", "pythonize.nim") 606 | result = 0; 607 | nimln(530, "pythonize.nim"); 608 | result = Dl_126647(((Tpyobject125574*) (p)), index->data); 609 | popFrame(); 610 | return result; 611 | } 612 | 613 | static N_INLINE(Tpyobject125574*, HEX5BHEX5D_131477)(PythondictHEX3Aobjecttype130025* p, NimStringDesc* index) { 614 | Tpyobject125574* result; 615 | nimfr("[]", "pythonize.nim") 616 | result = 0; 617 | nimln(533, "pythonize.nim"); 618 | result = getitem_131452(p, index); 619 | popFrame(); 620 | return result; 621 | } 622 | 623 | static N_INLINE(void, asgnRefNoCycle)(void** dest, void* src) { 624 | nimfr("asgnRefNoCycle", "gc.nim") 625 | nimln(264, "gc.nim"); 626 | { 627 | Cell49347* c; 628 | nimln(349, "system.nim"); 629 | if (!!((src == NIM_NIL))) goto LA3; 630 | nimln(265, "gc.nim"); 631 | c = usrtocell_53046(src); 632 | nimln(182, "gc.nim"); 633 | (*c).refcount += ((NI) 8); 634 | } 635 | LA3: ; 636 | nimln(267, "gc.nim"); 637 | { 638 | Cell49347* c; 639 | nimln(349, "system.nim"); 640 | if (!!(((*dest) == NIM_NIL))) goto LA7; 641 | nimln(268, "gc.nim"); 642 | c = usrtocell_53046((*dest)); 643 | nimln(269, "gc.nim"); 644 | { 645 | nimln(180, "gc.nim"); 646 | (*c).refcount -= ((NI) 8); 647 | nimln(181, "gc.nim"); 648 | if (!((NU64)((*c).refcount) < (NU64)(((NI) 8)))) goto LA11; 649 | nimln(270, "gc.nim"); 650 | rtladdzct_54604(c); 651 | } 652 | LA11: ; 653 | } 654 | LA7: ; 655 | nimln(271, "gc.nim"); 656 | (*dest) = src; 657 | popFrame(); 658 | } 659 | 660 | static N_INLINE(NI, addInt)(NI a, NI b) { 661 | NI result; 662 | { result = 0; 663 | result = (NI)((NU64)(a) + (NU64)(b)); 664 | { 665 | NIM_BOOL LOC3; 666 | LOC3 = 0; 667 | LOC3 = (((NI) 0) <= (NI)(result ^ a)); 668 | if (LOC3) goto LA4; 669 | LOC3 = (((NI) 0) <= (NI)(result ^ b)); 670 | LA4: ; 671 | if (!LOC3) goto LA5; 672 | goto BeforeRet; 673 | } 674 | LA5: ; 675 | raiseOverflow(); 676 | }BeforeRet: ; 677 | return result; 678 | } 679 | 680 | static N_INLINE(void, initStackBottomWith)(void* locals) { 681 | setStackBottom(locals); 682 | } 683 | void PreMainInner() { 684 | systemInit000(); 685 | HEX00_parseutilsDatInit000(); 686 | HEX00_strutilsDatInit000(); 687 | HEX00_etcprivDatInit000(); 688 | HEX00_hashesDatInit000(); 689 | HEX00_timesDatInit000(); 690 | HEX00_mathDatInit000(); 691 | HEX00_tablesDatInit000(); 692 | HEX00_dynlibDatInit000(); 693 | python_pythonDatInit000(); 694 | pythonize_pythonizeDatInit000(); 695 | md5_pythonizeDatInit000(); 696 | HEX00_parseutilsInit000(); 697 | HEX00_strutilsInit000(); 698 | HEX00_etcprivInit000(); 699 | HEX00_hashesInit000(); 700 | HEX00_timesInit000(); 701 | HEX00_mathInit000(); 702 | HEX00_tablesInit000(); 703 | HEX00_dynlibInit000(); 704 | python_pythonInit000(); 705 | pythonize_pythonizeInit000(); 706 | } 707 | 708 | void PreMain() { 709 | void (*volatile inner)(); 710 | systemDatInit000(); 711 | inner = PreMainInner; 712 | initStackBottomWith((void *)&inner); 713 | (*inner)(); 714 | } 715 | 716 | int cmdCount; 717 | char** cmdLine; 718 | char** gEnv; 719 | N_CDECL(void, NimMainInner)(void) { 720 | md5_pythonizeInit000(); 721 | } 722 | 723 | N_CDECL(void, NimMain)(void) { 724 | void (*volatile inner)(); 725 | PreMain(); 726 | inner = NimMainInner; 727 | initStackBottomWith((void *)&inner); 728 | (*inner)(); 729 | } 730 | 731 | int main(int argc, char** args, char** env) { 732 | cmdLine = args; 733 | cmdCount = argc; 734 | gEnv = env; 735 | NimMain(); 736 | return nim_program_result; 737 | } 738 | 739 | NIM_EXTERNC N_NOINLINE(void, md5_pythonizeInit000)(void) { 740 | NimStringDesc* LOC1; 741 | Tpyobject125574* LOC12; 742 | nimfr("md5_pythonize", "md5_pythonize.nim") 743 | nimln(6, "md5_pythonize.nim"); 744 | LOC1 = 0; 745 | LOC1 = texttoencode_132004; texttoencode_132004 = copyStringRC1(((NimStringDesc*) &TMP511)); 746 | if (LOC1) nimGCunrefNoCycle(LOC1); 747 | nimln(7, "md5_pythonize.nim"); 748 | HEX5BHEX5DHEX3D_132009(((PythondictHEX3Aobjecttype130025*) (pythonenvironmentobject_130069)), ((NimStringDesc*) &TMP518), texttoencode_132004); 749 | nimln(70, "pythonize.nim"); 750 | { 751 | Tpyobject125574* LOC4; 752 | LOC4 = 0; 753 | LOC4 = Dl_126680("import md5", ((NI) 257), pythonenvironmentobject_130069, pythonenvironmentobject_130069); 754 | if (!LOC4 == 0) goto LA5; 755 | nimln(71, "pythonize.nim"); 756 | Dl_126508(); 757 | } 758 | LA5: ; 759 | nimln(70, "pythonize.nim"); 760 | { 761 | Tpyobject125574* LOC9; 762 | LOC9 = 0; 763 | LOC9 = Dl_126680("encoded_text = md5.md5(text).hexdigest()", ((NI) 257), pythonenvironmentobject_130069, pythonenvironmentobject_130069); 764 | if (!LOC9 == 0) goto LA10; 765 | nimln(71, "pythonize.nim"); 766 | Dl_126508(); 767 | } 768 | LA10: ; 769 | nimln(10, "md5_pythonize.nim"); 770 | LOC12 = 0; 771 | LOC12 = HEX5BHEX5D_131477(((PythondictHEX3Aobjecttype130025*) (pythonenvironmentobject_130069)), ((NimStringDesc*) &TMP519)); 772 | asgnRefNoCycle((void**) (&encodedtext_132079), depythonify_132067(LOC12)); 773 | nimln(11, "md5_pythonize.nim"); 774 | printf("%s%s\012", ((NimStringDesc*) &TMP520)? (((NimStringDesc*) &TMP520))->data:"nil", texttoencode_132004? (texttoencode_132004)->data:"nil"); 775 | nimln(12, "md5_pythonize.nim"); 776 | printf("%s%s\012", ((NimStringDesc*) &TMP521)? (((NimStringDesc*) &TMP521))->data:"nil", encodedtext_132079? (encodedtext_132079)->data:"nil"); 777 | { 778 | NI i_132258; 779 | NI L_132260; 780 | nimln(3365, "system.nim"); 781 | i_132258 = ((NI) 0); 782 | nimln(3366, "system.nim"); 783 | L_132260 = (pythonreferences_130059 ? pythonreferences_130059->Sup.len : 0); 784 | { 785 | nimln(3367, "system.nim"); 786 | while (1) { 787 | NI TMP522; 788 | if (!(i_132258 < L_132260)) goto LA15; 789 | nimln(3368, "system.nim"); 790 | if ((NU)(i_132258) >= (NU)(pythonreferences_130059->Sup.len)) raiseIndexError(); 791 | pythonref_132096 = pythonreferences_130059->data[i_132258]; 792 | nimln(603, "pythonize.nim"); 793 | release_132212(pythonref_132096); 794 | nimln(3369, "system.nim"); 795 | TMP522 = addInt(i_132258, ((NI) 1)); 796 | i_132258 = (NI)(TMP522); 797 | nimln(3370, "system.nim"); 798 | { 799 | if (!!(((pythonreferences_130059 ? pythonreferences_130059->Sup.len : 0) == L_132260))) goto LA18; 800 | failedassertimpl_91603(((NimStringDesc*) &TMP523)); 801 | } 802 | LA18: ; 803 | } LA15: ; 804 | } 805 | } 806 | nimln(604, "pythonize.nim"); 807 | { 808 | if (!NIM_TRUE) goto LA22; 809 | nimln(596, "pythonize.nim"); 810 | Dl_127891(); 811 | } 812 | LA22: ; 813 | popFrame(); 814 | } 815 | 816 | NIM_EXTERNC N_NOINLINE(void, md5_pythonizeDatInit000)(void) { 817 | } 818 | 819 | --------------------------------------------------------------------------------