Example #1
0
 def name_expr(self, name):
     nexpr = NameExpr(name)
     nexpr.kind = nodes.LDEF
     node = self.names[name]
     nexpr.node = node
     self.type_map[nexpr] = node.type
     return nexpr
Example #2
0
 def name_expr(self, name: str) -> NameExpr:
     nexpr = NameExpr(name)
     nexpr.kind = nodes.LDEF
     node = self.names[name]
     nexpr.node = node
     self.type_map[nexpr] = node.type
     return nexpr
Example #3
0
    if is_alt != BOUND_VAR:
        if n > 0:
            # Equivalent to slot name.
            return tvar_slot_name(n - 1)
        elif n == -1:
            return '__ftv'
        else:
            return '__ftv{}'.format(-n)
    else:
        if n > 0:
            # Equivalent to slot name.
            return tvar_slot_name(n - 1, BOUND_VAR)
        elif n == -1:
            return '__bftv' # FIX do we need this?
        else:
            return '__bftv{}'.format(-n) # FIX do we need this?


str dynamic_suffix(bool is_pretty):
    """Return the suffix of the dynamic wrapper of a method or class."""
    if is_pretty:
        return '*'
    else:
        return '___dyn'


NameExpr self_expr():
    n = NameExpr('self')
    n.kind = LDEF
    return n
Example #4
0
def self_expr():
    n = NameExpr('self')
    n.kind = LDEF
    return n
Example #5
0
        
        fdef.type = wrapper_sig
        return fdef

    Instance self_type(self):
        return self_type(self.tf.type_context())

    Scope make_scope(self):
        return Scope(self.tf.type_map)
        

class Scope:
    """Maintain a temporary local scope during transformation."""
    void __init__(self, dict<Node, Type> type_map):
        self.names = <str, Var> {}
        self.type_map = type_map

    Var add(self, str name, Type type):
        v = Var(name)
        v.type = type
        self.names[name] = v
        return v

    NameExpr name_expr(self, str name):
        nexpr = NameExpr(name)
        nexpr.kind = nodes.LDEF
        node = self.names[name]
        nexpr.node = node
        self.type_map[nexpr] = node.type
        return nexpr
Example #6
0
def self_expr() -> NameExpr:
    n = NameExpr('self')
    n.kind = LDEF
    return n
Example #7
0
def self_expr() -> NameExpr:
    n = NameExpr("self")
    n.kind = LDEF
    return n