Exemplo n.º 1
0
    def create_internal_property(
            self, name: str, expr: Optional[AbstractExpression],
            type: Optional[CompiledType]) -> Optional[PropertyDef]:
        """
        Create an internal property for this env spec.

        If ``expr`` is None, do not create a property and return None.
        Otherwise, unsugar it.

        :param name: Lower-case name to use to create this property name.
            Since the property is internal, the name is decorated.
        """
        assert self.ast_node is not None

        if expr is None:
            return None

        expr = unsugar(expr)
        p = PropertyDef(expr,
                        AbstractNodeData.PREFIX_INTERNAL,
                        name=names.Name('{}_{}'.format(
                            name, next(self.PROPERTY_COUNT))),
                        public=False,
                        type=type,
                        ignore_warn_on_node=True)
        p._indexing_name = '_{}'.format(p.original_name.lower)
        p._original_name = names.Name.from_lower(p._indexing_name)
        p.location = getattr(expr, 'location') or self.location
        self.ast_node.add_field(p)
        return p
Exemplo n.º 2
0
    def create_internal_property(self, name, expr, type):
        """
        Create an internal property for this env spec.
        """
        if expr is None:
            return None

        p = PropertyDef(
            expr, AbstractNodeData.PREFIX_INTERNAL,
            name=names.Name('_{}_{}'.format(name,
                                            next(self.PROPERTY_COUNT))),
            public=False, type=type, ignore_warn_on_node=True
        )
        p.location = getattr(expr, 'location') or self.location
        self.ast_node.add_field(p)
        return p
Exemplo n.º 3
0
    def create_internal_property(self, name, expr, type):
        """
        Create an internal property for this env spec.

        If ``expr`` is None, do not create a property and return None.
        Otherwise, unsugar it.

        :param str name: Lower-case name to use to create this property name.
            Since the property is internal, the name is decorated.
        """
        if expr is None:
            return None

        expr = unsugar(expr)
        p = PropertyDef(expr,
                        AbstractNodeData.PREFIX_INTERNAL,
                        name=names.Name('_{}_{}'.format(
                            name, next(self.PROPERTY_COUNT))),
                        public=False,
                        type=type,
                        ignore_warn_on_node=True)
        p.location = getattr(expr, 'location') or self.location
        self.ast_node.add_field(p)
        return p