当前位置: 首页>>代码示例>>Python>>正文


Python PredefinedTypes.get_void_type方法代码示例

本文整理汇总了Python中pynestml.symbols.predefined_types.PredefinedTypes.get_void_type方法的典型用法代码示例。如果您正苦于以下问题:Python PredefinedTypes.get_void_type方法的具体用法?Python PredefinedTypes.get_void_type怎么用?Python PredefinedTypes.get_void_type使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在pynestml.symbols.predefined_types.PredefinedTypes的用法示例。


在下文中一共展示了PredefinedTypes.get_void_type方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: check_co_co

# 需要导入模块: from pynestml.symbols.predefined_types import PredefinedTypes [as 别名]
# 或者: from pynestml.symbols.predefined_types.PredefinedTypes import get_void_type [as 别名]
 def check_co_co(cls, _neuron=None):
     """
     Checks the coco for the handed over neuron.
     :param _neuron: a single neuron instance.
     :type _neuron: ASTNeuron
     """
     assert (_neuron is not None and isinstance(_neuron, ASTNeuron)), \
         '(PyNestML.CoCo.FunctionCallsConsistent) No or wrong type of neuron provided (%s)!' % type(_neuron)
     cls.__neuronName = _neuron.get_name()
     for userDefinedFunction in _neuron.get_functions():
         cls.processed_function = userDefinedFunction
         symbol = userDefinedFunction.get_scope().resolve_to_symbol(userDefinedFunction.get_name(),
                                                                    SymbolKind.FUNCTION)
         # first ensure that the block contains at least one statement
         if symbol is not None and len(userDefinedFunction.get_block().get_stmts()) > 0:
             # now check that the last statement is a return
             cls.__check_return_recursively(symbol.get_return_type(),
                                            userDefinedFunction.get_block().get_stmts(), False)
         # now if it does not have a statement, but uses a return type, it is an error
         elif symbol is not None and userDefinedFunction.has_return_type() and \
                 not symbol.get_return_type().equals(PredefinedTypes.get_void_type()):
             code, message = Messages.get_no_return()
             Logger.log_message(neuron=_neuron, code=code, message=message,
                                error_position=userDefinedFunction.get_source_position(),
                                log_level=LoggingLevel.ERROR)
     return
开发者ID:Silmathoron,项目名称:nestml,代码行数:28,代码来源:co_co_user_defined_function_correctly_defined.py

示例2: endvisit_function

# 需要导入模块: from pynestml.symbols.predefined_types import PredefinedTypes [as 别名]
# 或者: from pynestml.symbols.predefined_types.PredefinedTypes import get_void_type [as 别名]
 def endvisit_function(self, node):
     symbol = self.symbol_stack.pop()
     scope = self.scope_stack.pop()
     assert isinstance(symbol, FunctionSymbol), 'Not a function symbol'
     for arg in node.get_parameters():
         # given the fact that the name is not directly equivalent to the one as stated in the model,
         # we have to get it by the sub-visitor
         data_type_visitor = ASTDataTypeVisitor()
         arg.get_data_type().accept(data_type_visitor)
         type_name = data_type_visitor.result
         # first collect the types for the parameters of the function symbol
         symbol.add_parameter_type(PredefinedTypes.get_type(type_name))
         # update the scope of the arg
         arg.update_scope(scope)
         # create the corresponding variable symbol representing the parameter
         var_symbol = VariableSymbol(element_reference=arg, scope=scope, name=arg.get_name(),
                                     block_type=BlockType.LOCAL, is_predefined=False, is_function=False,
                                     is_recordable=False,
                                     type_symbol=PredefinedTypes.get_type(type_name),
                                     variable_type=VariableType.VARIABLE)
         assert isinstance(scope, Scope)
         scope.add_symbol(var_symbol)
     if node.has_return_type():
         data_type_visitor = ASTDataTypeVisitor()
         node.get_return_type().accept(data_type_visitor)
         symbol.set_return_type(PredefinedTypes.get_type(data_type_visitor.result))
     else:
         symbol.set_return_type(PredefinedTypes.get_void_type())
     self.block_type_stack.pop()  # before leaving update the type
开发者ID:Silmathoron,项目名称:nestml,代码行数:31,代码来源:ast_symbol_table_visitor.py

示例3: __register_print_ln_function

# 需要导入模块: from pynestml.symbols.predefined_types import PredefinedTypes [as 别名]
# 或者: from pynestml.symbols.predefined_types.PredefinedTypes import get_void_type [as 别名]
 def __register_print_ln_function(cls):
     """
     Registers the print-line function.
     """
     symbol = FunctionSymbol(name=cls.PRINTLN, param_types=list(),
                             return_type=PredefinedTypes.get_void_type(),
                             element_reference=None, is_predefined=True)
     cls.name2function[cls.PRINTLN] = symbol
开发者ID:Silmathoron,项目名称:nestml,代码行数:10,代码来源:predefined_functions.py

示例4: __register_integrated_odes_function

# 需要导入模块: from pynestml.symbols.predefined_types import PredefinedTypes [as 别名]
# 或者: from pynestml.symbols.predefined_types.PredefinedTypes import get_void_type [as 别名]
 def __register_integrated_odes_function(cls):
     """
     Registers the integrate-odes function.
     """
     params = list()
     symbol = FunctionSymbol(name=cls.INTEGRATE_ODES, param_types=params,
                             return_type=PredefinedTypes.get_void_type(),
                             element_reference=None, is_predefined=True)
     cls.name2function[cls.INTEGRATE_ODES] = symbol
开发者ID:Silmathoron,项目名称:nestml,代码行数:11,代码来源:predefined_functions.py

示例5: __register_logger_warning_function

# 需要导入模块: from pynestml.symbols.predefined_types import PredefinedTypes [as 别名]
# 或者: from pynestml.symbols.predefined_types.PredefinedTypes import get_void_type [as 别名]
 def __register_logger_warning_function(cls):
     """
     Registers the logger warning method.
     """
     params = list()
     params.append(PredefinedTypes.get_string_type())  # the argument
     symbol = FunctionSymbol(name=cls.LOGGER_WARNING, param_types=params,
                             return_type=PredefinedTypes.get_void_type(),
                             element_reference=None, is_predefined=True)
     cls.name2function[cls.LOGGER_WARNING] = symbol
开发者ID:Silmathoron,项目名称:nestml,代码行数:12,代码来源:predefined_functions.py

示例6: __register_logger_info_function

# 需要导入模块: from pynestml.symbols.predefined_types import PredefinedTypes [as 别名]
# 或者: from pynestml.symbols.predefined_types.PredefinedTypes import get_void_type [as 别名]
 def __register_logger_info_function(cls):
     """
     Registers the logger info method into the scope.
     """
     params = list()
     params.append(PredefinedTypes.get_string_type())  # the argument
     symbol = FunctionSymbol(name=cls.LOGGER_INFO, param_types=params,
                             return_type=PredefinedTypes.get_void_type(),
                             element_reference=None, is_predefined=True)
     cls.name2function[cls.LOGGER_INFO] = symbol
开发者ID:Silmathoron,项目名称:nestml,代码行数:12,代码来源:predefined_functions.py

示例7: __register_print_function

# 需要导入模块: from pynestml.symbols.predefined_types import PredefinedTypes [as 别名]
# 或者: from pynestml.symbols.predefined_types.PredefinedTypes import get_void_type [as 别名]
 def __register_print_function(cls):
     """
     Registers the print function.
     """
     params = list()
     params.append(PredefinedTypes.get_string_type())
     symbol = FunctionSymbol(name=cls.PRINT, param_types=params,
                             return_type=PredefinedTypes.get_void_type(),
                             element_reference=None, is_predefined=True)
     cls.name2function[cls.PRINT] = symbol
开发者ID:Silmathoron,项目名称:nestml,代码行数:12,代码来源:predefined_functions.py

示例8: visit_data_type

# 需要导入模块: from pynestml.symbols.predefined_types import PredefinedTypes [as 别名]
# 或者: from pynestml.symbols.predefined_types.PredefinedTypes import get_void_type [as 别名]
 def visit_data_type(self, node):
     """
     Visits a single data type meta_model node and updates, checks correctness and updates its type symbol.
     This visitor can also be used to derive the original name of the unit.
     :param node: a single datatype node.
     :type node: ast_data_type
     """
     if node.is_integer:
         self.symbol = PredefinedTypes.get_integer_type()
         node.set_type_symbol(self.symbol)
     elif node.is_real:
         self.symbol = PredefinedTypes.get_real_type()
         node.set_type_symbol(self.symbol)
     elif node.is_string:
         self.symbol = PredefinedTypes.get_string_type()
         node.set_type_symbol(self.symbol)
     elif node.is_boolean:
         self.symbol = PredefinedTypes.get_boolean_type()
         node.set_type_symbol(self.symbol)
     elif node.is_void:
         self.symbol = PredefinedTypes.get_void_type()
         node.set_type_symbol(self.symbol)
开发者ID:Silmathoron,项目名称:nestml,代码行数:24,代码来源:ast_data_type_visitor.py

示例9: __check_return_recursively

# 需要导入模块: from pynestml.symbols.predefined_types import PredefinedTypes [as 别名]
# 或者: from pynestml.symbols.predefined_types.PredefinedTypes import get_void_type [as 别名]
 def __check_return_recursively(cls, type_symbol=None, stmts=None, ret_defined=False):
     """
     For a handed over statement, it checks if the statement is a return statement and if it is typed according
     to the handed over type symbol.
     :param type_symbol: a single type symbol
     :type type_symbol: type_symbol
     :param stmts: a list of statements, either simple or compound
     :type stmts: list(ASTSmallStmt,ASTCompoundStmt)
     :param ret_defined: indicates whether a ret has already beef defined after this block of stmt, thus is not
                 necessary. Implies that the return has been defined in the higher level block
     :type ret_defined: bool
     """
     # in order to ensure that in the sub-blocks, a return is not necessary, we check if the last one in this
     # block is a return statement, thus it is not required to have a return in the sub-blocks, but optional
     last_statement = stmts[len(stmts) - 1]
     ret_defined = False or ret_defined
     if (len(stmts) > 0 and isinstance(last_statement, ASTStmt)
             and last_statement.is_small_stmt()
             and last_statement.small_stmt.is_return_stmt()):
         ret_defined = True
     # now check that returns are there if necessary and correctly typed
     for c_stmt in stmts:
         if c_stmt.is_small_stmt():
             stmt = c_stmt.small_stmt
         else:
             stmt = c_stmt.compound_stmt
         # if it is a small statement, check if it is a return statement
         if isinstance(stmt, ASTSmallStmt) and stmt.is_return_stmt():
             # first check if the return is the last one in this block of statements
             if stmts.index(c_stmt) != (len(stmts) - 1):
                 code, message = Messages.get_not_last_statement('Return')
                 Logger.log_message(error_position=stmt.get_source_position(),
                                    code=code, message=message,
                                    log_level=LoggingLevel.WARNING)
             # now check that it corresponds to the declared type
             if stmt.get_return_stmt().has_expression() and type_symbol is PredefinedTypes.get_void_type():
                 code, message = Messages.get_type_different_from_expected(PredefinedTypes.get_void_type(),
                                                                           stmt.get_return_stmt().get_expression().type)
                 Logger.log_message(error_position=stmt.get_source_position(),
                                    message=message, code=code, log_level=LoggingLevel.ERROR)
             # if it is not void check if the type corresponds to the one stated
             if not stmt.get_return_stmt().has_expression() and \
                     not type_symbol.equals(PredefinedTypes.get_void_type()):
                 code, message = Messages.get_type_different_from_expected(PredefinedTypes.get_void_type(),
                                                                           type_symbol)
                 Logger.log_message(error_position=stmt.get_source_position(),
                                    message=message, code=code, log_level=LoggingLevel.ERROR)
             if stmt.get_return_stmt().has_expression():
                 type_of_return = stmt.get_return_stmt().get_expression().type
                 if isinstance(type_of_return, ErrorTypeSymbol):
                     code, message = Messages.get_type_could_not_be_derived(cls.processed_function.get_name())
                     Logger.log_message(error_position=stmt.get_source_position(),
                                        code=code, message=message, log_level=LoggingLevel.ERROR)
                 elif not type_of_return.equals(type_symbol):
                     TypeCaster.try_to_recover_or_error(type_symbol, type_of_return,
                                                        stmt.get_return_stmt().get_expression())
         elif isinstance(stmt, ASTCompoundStmt):
             # otherwise it is a compound stmt, thus check recursively
             if stmt.is_if_stmt():
                 cls.__check_return_recursively(type_symbol,
                                                stmt.get_if_stmt().get_if_clause().get_block().get_stmts(),
                                                ret_defined)
                 for else_ifs in stmt.get_if_stmt().get_elif_clauses():
                     cls.__check_return_recursively(type_symbol, else_ifs.get_block().get_stmt(), ret_defined)
                 if stmt.get_if_stmt().has_else_clause():
                     cls.__check_return_recursively(type_symbol,
                                                    stmt.get_if_stmt().get_else_clause().get_block().get_stmts(),
                                                    ret_defined)
             elif stmt.is_while_stmt():
                 cls.__check_return_recursively(type_symbol, stmt.get_while_stmt().get_block().get_stmts(),
                                                ret_defined)
             elif stmt.is_for_stmt():
                 cls.__check_return_recursively(type_symbol, stmt.get_for_stmt().get_block().get_stmts(),
                                                ret_defined)
         # now, if a return statement has not been defined in the corresponding higher level block, we have
         # to ensure that it is defined here
         elif not ret_defined and stmts.index(c_stmt) == (len(stmts) - 1):
             if not (isinstance(stmt, ASTSmallStmt) and stmt.is_return_stmt()):
                 code, message = Messages.get_no_return()
                 Logger.log_message(error_position=stmt.get_source_position(), log_level=LoggingLevel.ERROR,
                                    code=code, message=message)
     return
开发者ID:Silmathoron,项目名称:nestml,代码行数:84,代码来源:co_co_user_defined_function_correctly_defined.py


注:本文中的pynestml.symbols.predefined_types.PredefinedTypes.get_void_type方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。