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


Python predefined_types.PredefinedTypes类代码示例

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


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

示例1: endvisit_function

 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,代码行数:29,代码来源:ast_symbol_table_visitor.py

示例2: visit_simple_expression

    def visit_simple_expression(self, node):
        """
        Visit a simple rhs and update the type of a numeric literal.
        :param node: a single meta_model node
        :type node: ast_node
        :return: no value returned, the type is updated in-place
        :rtype: void
        """
        assert node.get_scope() is not None, "Run symboltable creator."
        # if variable is also set in this rhs, the var type overrides the literal
        if node.get_variable() is not None:
            scope = node.get_scope()
            var_name = node.get_variable().get_name()
            variable_symbol_resolve = scope.resolve_to_symbol(var_name, SymbolKind.VARIABLE)
            if not variable_symbol_resolve is None:
                node.type = variable_symbol_resolve.get_type_symbol()
            else:
                node.type = scope.resolve_to_symbol(var_name, SymbolKind.TYPE)
            node.type.referenced_object = node
            return

        if node.get_numeric_literal() is not None and isinstance(node.get_numeric_literal(), float):
            node.type = PredefinedTypes.get_real_type()
            node.type.referenced_object = node
            return

        elif node.get_numeric_literal() is not None and isinstance(node.get_numeric_literal(), int):
            node.type = PredefinedTypes.get_integer_type()
            node.type.referenced_object = node
            return
开发者ID:Silmathoron,项目名称:nestml,代码行数:30,代码来源:ast_numeric_literal_visitor.py

示例3: __register_print_function

 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,代码行数:10,代码来源:predefined_functions.py

示例4: __register_logger_info_function

 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,代码行数:10,代码来源:predefined_functions.py

示例5: setUp

    def setUp(self):
        PredefinedUnits.register_units()
        PredefinedTypes.register_types()
        PredefinedFunctions.register_functions()
        PredefinedVariables.register_variables()
        SymbolTable.initialize_symbol_table(ASTSourceLocation(start_line=0, start_column=0, end_line=0, end_column=0))
        Logger.init_logger(LoggingLevel.INFO)

        self.target_path = str(os.path.realpath(os.path.join(os.path.dirname(__file__), os.path.join(
            os.pardir, 'target'))))
开发者ID:Silmathoron,项目名称:nestml,代码行数:10,代码来源:nest_codegenerator_preparation_test.py

示例6: __register_logger_warning_function

 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,代码行数:10,代码来源:predefined_functions.py

示例7: __register_exp1_function

 def __register_exp1_function(cls):
     """
     Registers the alternative version of the exponent function, exp1.
     """
     params = list()
     params.append(PredefinedTypes.get_real_type())  # the argument
     symbol = FunctionSymbol(name=cls.EXPM1, param_types=params,
                             return_type=PredefinedTypes.get_real_type(),
                             element_reference=None, is_predefined=True)
     cls.name2function[cls.EXPM1] = symbol
开发者ID:Silmathoron,项目名称:nestml,代码行数:10,代码来源:predefined_functions.py

示例8: __register_log_function

 def __register_log_function(cls):
     """
     Registers the logarithm function (to base 10).
     """
     params = list()
     params.append(PredefinedTypes.get_real_type())  # the argument
     symbol = FunctionSymbol(name=cls.LOG, param_types=params,
                             return_type=PredefinedTypes.get_real_type(),
                             element_reference=None, is_predefined=True)
     cls.name2function[cls.LOG] = symbol
开发者ID:Silmathoron,项目名称:nestml,代码行数:10,代码来源:predefined_functions.py

示例9: __register_time_steps_function

 def __register_time_steps_function(cls):
     """
     Registers the time-resolution.
     """
     params = list()
     params.append(PredefinedTypes.get_type('ms'))
     symbol = FunctionSymbol(name=cls.TIME_STEPS, param_types=params,
                             return_type=PredefinedTypes.get_integer_type(),
                             element_reference=None, is_predefined=True)
     cls.name2function[cls.TIME_STEPS] = symbol
     return
开发者ID:Silmathoron,项目名称:nestml,代码行数:11,代码来源:predefined_functions.py

示例10: __register_power_function

 def __register_power_function(cls):
     """
     Registers the power function.
     """
     params = list()
     params.append(PredefinedTypes.get_real_type())  # the base type
     params.append(PredefinedTypes.get_real_type())  # the exponent type
     symbol = FunctionSymbol(name=cls.POW, param_types=params,
                             return_type=PredefinedTypes.get_real_type(),
                             element_reference=None, is_predefined=True)
     cls.name2function[cls.POW] = symbol
开发者ID:Silmathoron,项目名称:nestml,代码行数:11,代码来源:predefined_functions.py

示例11: __register_convolve

 def __register_convolve(cls):
     """
     Registers the convolve function into the system.
     """
     params = list()
     params.append(PredefinedTypes.get_real_type())
     params.append(PredefinedTypes.get_real_type())
     symbol = FunctionSymbol(name=cls.CONVOLVE, param_types=params,
                             return_type=PredefinedTypes.get_real_type(),
                             element_reference=None, is_predefined=True)
     cls.name2function[cls.CONVOLVE] = symbol
开发者ID:Silmathoron,项目名称:nestml,代码行数:11,代码来源:predefined_functions.py

示例12: __register_predefined_type_variables

 def __register_predefined_type_variables(cls):
     """
     Registers all predefined type variables, e.g., mV and integer.
     """
     for name in PredefinedTypes.get_types().keys():
         symbol = VariableSymbol(name=name, block_type=BlockType.PREDEFINED,
                                 is_predefined=True,
                                 type_symbol=PredefinedTypes.get_type(name),
                                 variable_type=VariableType.TYPE)
         cls.name2variable[name] = symbol
     return
开发者ID:Silmathoron,项目名称:nestml,代码行数:11,代码来源:predefined_variables.py

示例13: __register_max_function

 def __register_max_function(cls):
     """
     Registers the maximum function.
     """
     params = list()
     params.append(PredefinedTypes.get_real_type())
     params.append(PredefinedTypes.get_real_type())
     symbol = FunctionSymbol(name=cls.MAX, param_types=params,
                             return_type=PredefinedTypes.get_real_type(),
                             element_reference=None, is_predefined=True)
     cls.name2function[cls.MAX] = symbol
开发者ID:Silmathoron,项目名称:nestml,代码行数:11,代码来源:predefined_functions.py

示例14: __register_cond_sum_function

 def __register_cond_sum_function(cls):
     """
     Registers the cond_sum function into scope.
     """
     params = list()
     params.append(PredefinedTypes.get_type('nS'))
     params.append(PredefinedTypes.get_real_type())
     symbol = FunctionSymbol(name=cls.COND_SUM, param_types=params,
                             return_type=PredefinedTypes.get_type('nS'),
                             element_reference=None, is_predefined=True)
     cls.name2function[cls.COND_SUM] = symbol
开发者ID:Silmathoron,项目名称:nestml,代码行数:11,代码来源:predefined_functions.py

示例15: __register_min_bounded_function

 def __register_min_bounded_function(cls):
     """
     Registers the minimum (bounded) function.
     """
     params = list()
     params.append(PredefinedTypes.get_real_type())
     params.append(PredefinedTypes.get_real_type())
     symbol = FunctionSymbol(name=cls.BOUNDED_MIN, param_types=params,
                             return_type=PredefinedTypes.get_real_type(),
                             element_reference=None, is_predefined=True)
     cls.name2function[cls.BOUNDED_MIN] = symbol
开发者ID:Silmathoron,项目名称:nestml,代码行数:11,代码来源:predefined_functions.py


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