MCPcopy Create free account
hub / github.com/covscript/covscript / check_define_var

Method check_define_var

sources/instance/instance.cpp:211–249  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

209 }
210
211 void instance_type::check_define_var(tree_type<token_base *>::iterator it, bool regist, bool constant)
212 {
213 if (it.data() == nullptr)
214 throw internal_error("Null pointer accessed.");
215 if (it.data()->get_type() == token_types::parallel) {
216 auto &parallel_list = static_cast<token_parallel *>(it.data())->get_parallel();
217 for (auto &t : parallel_list)
218 check_define_var(t.root(), regist, constant);
219 }
220 else {
221 token_base *root = it.data();
222 if (root == nullptr)
223 throw internal_error("Null pointer accessed.");
224 if (root->get_type() != token_types::signal)
225 throw runtime_error("Wrong grammar for variable definition(1).");
226 switch (static_cast<token_signal *>(root)->get_signal()) {
227 case signal_types::asi_: {
228 token_base *left = it.left().data();
229 token_base *right = it.right().data();
230 if (left == nullptr || right == nullptr || left->get_type() != token_types::id)
231 throw runtime_error("Wrong grammar for variable definition(2).");
232 if (constant && right->get_type() != token_types::value)
233 throw runtime_error("Wrong grammar for constant variable definition(3).");
234 if (regist)
235 storage.add_record(static_cast<token_id *>(left)->get_id().get_id());
236 break;
237 }
238 case signal_types::bind_: {
239 token_base *right = it.right().data();
240 if (constant && (right == nullptr || right->get_type() != token_types::value))
241 throw runtime_error("Wrong grammar for constant variable definition(4).");
242 check_define_structured_binding(it.left(), regist);
243 break;
244 }
245 default:
246 throw runtime_error("Wrong grammar for variable definition(5).");
247 }
248 }
249 }
250
251 void instance_type::parse_define_var(tree_type<token_base *>::iterator it, bool constant, bool link)
252 {

Callers 2

preprocessMethod · 0.80
translateMethod · 0.80

Calls 8

internal_errorClass · 0.85
runtime_errorClass · 0.85
dataMethod · 0.80
get_signalMethod · 0.80
leftMethod · 0.80
rightMethod · 0.80
get_typeMethod · 0.45
rootMethod · 0.45

Tested by

no test coverage detected