Changeset View
Changeset View
Standalone View
Standalone View
src/backends/julia/juliaserver/juliaserver.cpp
Show First 20 Lines • Show All 142 Lines • ▼ Show 20 Line(s) | 142 | { | |||
---|---|---|---|---|---|
143 | return m_output; | 143 | return m_output; | ||
144 | } | 144 | } | ||
145 | 145 | | |||
146 | bool JuliaServer::getWasException() const | 146 | bool JuliaServer::getWasException() const | ||
147 | { | 147 | { | ||
148 | return m_was_exception; | 148 | return m_was_exception; | ||
149 | } | 149 | } | ||
150 | 150 | | |||
151 | void JuliaServer::parseModules() | 151 | void JuliaServer::parseModules(bool variableManagement) | ||
152 | { | 152 | { | ||
153 | parseJlModule(jl_internal_main_module); | 153 | parseJlModule(jl_internal_main_module, variableManagement); | ||
154 | } | 154 | } | ||
155 | 155 | | |||
156 | void JuliaServer::parseJlModule(jl_module_t* module) | 156 | void JuliaServer::parseJlModule(jl_module_t* module, bool parseValue) | ||
157 | { | 157 | { | ||
158 | jl_function_t* jl_string_function = jl_get_function(jl_base_module, "string"); | 158 | jl_function_t* jl_string_function = jl_get_function(jl_base_module, "string"); | ||
159 | 159 | | |||
160 | if (module != jl_internal_main_module) | 160 | if (module != jl_internal_main_module) | ||
161 | { | 161 | { | ||
162 | const QString& moduleName = fromJuliaString(jl_call1(jl_string_function, (jl_value_t*)(module->name))); | 162 | const QString& moduleName = fromJuliaString(jl_call1(jl_string_function, (jl_value_t*)(module->name))); | ||
163 | if (parsedModules.contains(moduleName)) | 163 | if (parsedModules.contains(moduleName)) | ||
164 | return; | 164 | return; | ||
Show All 13 Lines | 176 | { | |||
178 | const QString& name = fromJuliaString(jl_call1(jl_string_function, data[i])); | 178 | const QString& name = fromJuliaString(jl_call1(jl_string_function, data[i])); | ||
179 | jl_value_t* value = jl_get_binding_or_error(module, (jl_sym_t*)(data[i]))->value; | 179 | jl_value_t* value = jl_get_binding_or_error(module, (jl_sym_t*)(data[i]))->value; | ||
180 | jl_datatype_t* datetype = (jl_datatype_t*)jl_typeof(value); | 180 | jl_datatype_t* datetype = (jl_datatype_t*)jl_typeof(value); | ||
181 | QString type = QString::fromUtf8(jl_typeof_str(value)); | 181 | QString type = QString::fromUtf8(jl_typeof_str(value)); | ||
182 | // Module | 182 | // Module | ||
183 | if (jl_is_module(value)) | 183 | if (jl_is_module(value)) | ||
184 | { | 184 | { | ||
185 | if (module == jl_internal_main_module && (jl_module_t*)value != jl_internal_main_module) | 185 | if (module == jl_internal_main_module && (jl_module_t*)value != jl_internal_main_module) | ||
186 | parseJlModule((jl_module_t*)value); | 186 | parseJlModule((jl_module_t*)value, parseValue); | ||
187 | } | 187 | } | ||
188 | // Function | 188 | // Function | ||
189 | else if (type.startsWith(QLatin1String("#")) || type == QLatin1String("Function")) | 189 | else if (type.startsWith(QLatin1String("#")) || type == QLatin1String("Function")) | ||
190 | { | 190 | { | ||
191 | if (!m_functions.contains(name)) | 191 | if (!m_functions.contains(name)) | ||
192 | m_functions.append(name); | 192 | m_functions.append(name); | ||
193 | } | 193 | } | ||
194 | // Variable | 194 | // Variable | ||
195 | else if (datetype != jl_datatype_type) // Not type | 195 | else if (datetype != jl_datatype_type) // Not type | ||
196 | { | 196 | { | ||
197 | if (module == jl_internal_main_module && !INTERNAL_VARIABLES.contains(name)) | 197 | if (module == jl_internal_main_module && !INTERNAL_VARIABLES.contains(name)) | ||
198 | { | 198 | { | ||
199 | if (parseValue) | ||||
200 | { | ||||
199 | const QString& valueString = fromJuliaString(jl_call1(jl_string_function, value)); | 201 | const QString& valueString = fromJuliaString(jl_call1(jl_string_function, value)); | ||
200 | if (m_variables.contains(name)) | 202 | if (m_variables.contains(name)) | ||
201 | { | 203 | { | ||
202 | int i = m_variables.indexOf(name); | 204 | int i = m_variables.indexOf(name); | ||
203 | m_variableValues[i] = valueString; | 205 | m_variableValues[i] = valueString; | ||
204 | } | 206 | } | ||
205 | else | 207 | else | ||
206 | { | 208 | { | ||
207 | m_variables.append(name); | 209 | m_variables.append(name); | ||
208 | m_variableValues.append(valueString); | 210 | m_variableValues.append(valueString); | ||
209 | } | 211 | } | ||
210 | } | 212 | } | ||
213 | else | ||||
214 | { | ||||
215 | if (!m_variables.contains(name)) | ||||
216 | m_variables.append(name); | ||||
217 | } | ||||
218 | } | ||||
211 | } | 219 | } | ||
212 | } | 220 | } | ||
213 | } | 221 | } | ||
214 | } | 222 | } | ||
215 | 223 | | |||
216 | QString JuliaServer::fromJuliaString(const jl_value_t* value) | 224 | QString JuliaServer::fromJuliaString(const jl_value_t* value) | ||
217 | { | 225 | { | ||
218 | return QString::fromUtf8(jl_string_data(value)); | 226 | return QString::fromUtf8(jl_string_data(value)); | ||
Show All 16 Lines |