當前位置: 首頁>>代碼示例>>Python>>正文


Python PredefinedTypes.get_integer_type方法代碼示例

本文整理匯總了Python中pynestml.symbols.predefined_types.PredefinedTypes.get_integer_type方法的典型用法代碼示例。如果您正苦於以下問題:Python PredefinedTypes.get_integer_type方法的具體用法?Python PredefinedTypes.get_integer_type怎麽用?Python PredefinedTypes.get_integer_type使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在pynestml.symbols.predefined_types.PredefinedTypes的用法示例。


在下文中一共展示了PredefinedTypes.get_integer_type方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: visit_simple_expression

# 需要導入模塊: from pynestml.symbols.predefined_types import PredefinedTypes [as 別名]
# 或者: from pynestml.symbols.predefined_types.PredefinedTypes import get_integer_type [as 別名]
    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,代碼行數:32,代碼來源:ast_numeric_literal_visitor.py

示例2: __register_random_int_function

# 需要導入模塊: from pynestml.symbols.predefined_types import PredefinedTypes [as 別名]
# 或者: from pynestml.symbols.predefined_types.PredefinedTypes import get_integer_type [as 別名]
 def __register_random_int_function(cls):
     """
     Registers the random method as used to generate a random integer-typed value.
     """
     symbol = FunctionSymbol(name=cls.RANDOM_INT, param_types=list(),
                             return_type=PredefinedTypes.get_integer_type(),
                             element_reference=None, is_predefined=True)
     cls.name2function[cls.RANDOM_INT] = symbol
開發者ID:Silmathoron,項目名稱:nestml,代碼行數:10,代碼來源:predefined_functions.py

示例3: __register_time_steps_function

# 需要導入模塊: from pynestml.symbols.predefined_types import PredefinedTypes [as 別名]
# 或者: from pynestml.symbols.predefined_types.PredefinedTypes import get_integer_type [as 別名]
 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,代碼行數:13,代碼來源:predefined_functions.py

示例4: visit_data_type

# 需要導入模塊: from pynestml.symbols.predefined_types import PredefinedTypes [as 別名]
# 或者: from pynestml.symbols.predefined_types.PredefinedTypes import get_integer_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


注:本文中的pynestml.symbols.predefined_types.PredefinedTypes.get_integer_type方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。