make functions static where possible

This commit is contained in:
Eitan Adler
2016-09-17 23:08:31 -07:00
parent 3545785041
commit 733fe1d25c
2 changed files with 22 additions and 11 deletions

View File

@@ -209,7 +209,8 @@ class RustSlicePrinter:
def __init__(self, val): def __init__(self, val):
self.__val = val self.__val = val
def display_hint(self): @staticmethod
def display_hint():
return "array" return "array"
def to_string(self): def to_string(self):
@@ -240,7 +241,8 @@ class RustStdVecPrinter:
def __init__(self, val): def __init__(self, val):
self.__val = val self.__val = val
def display_hint(self): @staticmethod
def display_hint():
return "array" return "array"
def to_string(self): def to_string(self):

View File

@@ -119,16 +119,19 @@ class Void(Type):
def __init__(self): def __init__(self):
Type.__init__(self, 0) Type.__init__(self, 0)
def compiler_ctor(self): @staticmethod
def compiler_ctor():
return '::VOID' return '::VOID'
def compiler_ctor_ref(self): def compiler_ctor_ref(self):
return '&' + self.compiler_ctor() return '&' + self.compiler_ctor()
def rust_name(self): @staticmethod
def rust_name():
return '()' return '()'
def type_info(self, platform_info): @staticmethod
def type_info(platform_info):
return None return None
def __eq__(self, other): def __eq__(self, other):
@@ -756,22 +759,26 @@ class ExternBlock(object):
def __init__(self): def __init__(self):
pass pass
def open(self, platform): @staticmethod
def open(platform):
return 'extern "platform-intrinsic" {' return 'extern "platform-intrinsic" {'
def render(self, mono): @staticmethod
def render(mono):
return ' fn {}{}{};'.format(mono.platform_prefix(), return ' fn {}{}{};'.format(mono.platform_prefix(),
mono.intrinsic_name(), mono.intrinsic_name(),
mono.intrinsic_signature()) mono.intrinsic_signature())
def close(self): @staticmethod
def close():
return '}' return '}'
class CompilerDefs(object): class CompilerDefs(object):
def __init__(self): def __init__(self):
pass pass
def open(self, platform): @staticmethod
def open(platform):
return '''\ return '''\
// Copyright 2015 The Rust Project Developers. See the COPYRIGHT // Copyright 2015 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at // file at the top-level directory of this distribution and at
@@ -798,7 +805,8 @@ pub fn find(name: &str) -> Option<Intrinsic> {{
if !name.starts_with("{0}") {{ return None }} if !name.starts_with("{0}") {{ return None }}
Some(match &name["{0}".len()..] {{'''.format(platform.platform_prefix()) Some(match &name["{0}".len()..] {{'''.format(platform.platform_prefix())
def render(self, mono): @staticmethod
def render(mono):
return '''\ return '''\
"{}" => Intrinsic {{ "{}" => Intrinsic {{
inputs: {{ static INPUTS: [&'static Type; {}] = [{}]; &INPUTS }}, inputs: {{ static INPUTS: [&'static Type; {}] = [{}]; &INPUTS }},
@@ -810,7 +818,8 @@ pub fn find(name: &str) -> Option<Intrinsic> {{
mono.compiler_ret(), mono.compiler_ret(),
mono.llvm_name()) mono.llvm_name())
def close(self): @staticmethod
def close():
return '''\ return '''\
_ => return None, _ => return None,
}) })