Beispiel #1
0
    def visit_Attribute(self, node):
        attr = node.attr
        value_id = get_id(node.value)
        if is_builtin_import(value_id):
            return "py14::" + value_id + "::" + attr
        elif value_id == "math":
            if node.attr == "asin":
                return "std::asin"
            elif node.attr == "atan":
                return "std::atan"
            elif node.attr == "acos":
                return "std::acos"

        if is_list(node.value):
            if node.attr == "append":
                attr = "push_back"

        if is_enum(value_id, node.scopes):
            return f"{value_id}::{attr}"

        if is_class_or_module(value_id, node.scopes):
            return f"{value_id}.{attr}"

        if is_self_arg(value_id, node.scopes):
            return f"this->{attr}"

        return f"{value_id}.{attr}"
Beispiel #2
0
    def visit_Attribute(self, node):
        attr = node.attr
        value_id = self.visit(node.value)

        if is_list(node.value):
            if node.attr == "append":
                attr = "push_back"

        if value_id in {"string"}:
            return f"std::{value_id}::{attr}"

        if is_enum(value_id, node.scopes):
            return f"{value_id}::{attr}"

        if is_class_or_module(value_id, node.scopes):
            return f"{value_id}.{attr}"

        if is_self_arg(value_id, node.scopes):
            return f"this->{attr}"

        ret = f"{value_id}.{attr}"
        if ret in self._attr_dispatch_table:
            ret = self._attr_dispatch_table[ret]
            return ret(self, node, value_id, attr)

        return ret
Beispiel #3
0
    def visit_Attribute(self, node):
        attr = node.attr

        value_id = self.visit(node.value)

        if not value_id:
            value_id = ""

        if is_enum(value_id, node.scopes):
            return f"{attr}"

        if is_class_or_module(value_id, node.scopes):
            return f"{value_id}.{attr}"

        return f"{value_id}.{attr}"
Beispiel #4
0
    def visit_Attribute(self, node):
        attr = node.attr

        value_id = self.visit(node.value)

        if not value_id:
            value_id = ""

        if value_id == "sys":
            if attr == "argv":
                return "append!([PROGRAM_FILE], ARGS)"

        if is_enum(value_id, node.scopes):
            return f"{value_id}.{attr}"

        if is_class_or_module(value_id, node.scopes):
            return f"{value_id}::{attr}"

        return f"{value_id}.{attr}"
Beispiel #5
0
    def visit_Attribute(self, node):
        attr = node.attr

        value_id = self.visit(node.value)

        if value_id == "sys":
            if attr == "argv":
                self._usings.add('"os"')
                return "os.Args"

        if not value_id:
            value_id = ""

        if is_enum(value_id, node.scopes):
            return f"{attr}"

        if is_class_or_module(value_id, node.scopes):
            return f"{value_id}.{attr}"

        return f"{value_id}.{attr}"
Beispiel #6
0
 def visit_Attribute(self, node):
     value_id = get_id(node.value)
     if value_id is not None and hasattr(node, "scopes"):
         if is_enum(value_id, node.scopes):
             node.annotation = node.scopes.find(value_id)
     return node