Exemple #1
0
    def assign(self, args, meta):
        assert_isa(args, List[str])
        # TODO let
        if args[0] == '__slots__' or args[0].startswith('__serialize_'):
            return ''

        if getattr(meta, 'in_class', False):
            var, value = args
            return f"get {var}() {{ return {value}; }}"

        let = 'let ' if getattr(meta, 'new_var', False) else ''
        return let + ' = '.join(args)
Exemple #2
0
 def arguments(self, args):
     assert_isa(args, List[Optional[str]])
     return ', '.join(p for p in args if p)
Exemple #3
0
 def parameters(self, params):
     assert_isa(params, List[Optional[str]])
     if params and params[0] == 'self':
         params = params[1:]
     return '(%s)' % ', '.join(p for p in params if p)
Exemple #4
0
    def file_input(self, nodes):
        assert_isa(nodes, List[str])

        return '\n'.join(nodes)
Exemple #5
0
 def suite(self, stmts):
     assert_isa(stmts, List[str])
     return '\n'.join(stmts)
Exemple #6
0
 def and_expr(self, args):
     assert_isa(args, List[str])
     return '(%s)' % ' & '.join(args)
Exemple #7
0
 def or_test(self, args):
     assert_isa(args, List[str])
     return '(%s)' % ' || '.join(args)