<commit_before>from thinglang.lexer.values.identifier import Identifier


class Symbol(object):

    METHOD, MEMBER = object(), object()
    INTERNAL, BYTECODE = object(), object()
    PUBLIC = object()

    def __init__(self, name, kind, type, static, arguments=None, index=None, convention=BYTECODE):
        super(Symbol, self).__init__()

        self.name, self.kind, self.type, self.static, self.arguments, self.index, self._convention = \
            name, kind, type, static, arguments, index, convention
        self.visibility = Symbol.PUBLIC

    def update_index(self, new_index):
        self.index = new_index
        return self

    def parameterize(self, parameters):
        return Symbol(self.name,
                      self.kind,
                      parameters[self.type] if self.type in parameters else self.type,
                      self.static,
                      [parameters[x] if x in parameters else x for x in self.arguments] if self.arguments else self.arguments,
                      self.index,
                      self.convention)

    @property
    def convention(self):
        return self._convention

    @convention.setter
    def convention(self, value):
        self._convention = value

    def serialize(self):
        return {
            "name": self.name,
            "index": self.index,
            "kind": "method" if self.kind is Symbol.METHOD else "member",
            "type": self.type,
            "static": self.static,
            "arguments": self.arguments,
            "convention": "bytecode" if self.convention is Symbol.BYTECODE else "internal"
        }

    @classmethod
    def load(cls, data: dict) -> 'Symbol':
        assert data['kind'] in ('member', 'method')
        assert data['convention'] in ('user', 'internal')

        return cls(<commit_msg>Recursively update parameter values for symbol types and arguments<commit_after>from thinglang.lexer.values.identifier import Identifier, GenericIdentifier


class Symbol(object):

    METHOD, MEMBER = object(), object()
    INTERNAL, BYTECODE = object(), object()
    PUBLIC = object()

    def __init__(self, name, kind, type, static, arguments=None, index=None, convention=BYTECODE):
        super(Symbol, self).__init__()

        self.name, self.kind, self.type, self.static, self.arguments, self.index, self._convention = \
            name, kind, type, static, arguments, index, convention
        self.visibility = Symbol.PUBLIC

    def update_index(self, new_index):
        self.index = new_index
        return self

    def parameterize(self, parameters):
        return Symbol(self.name,
                      self.kind,
                      self.type.parameterize(parameters) if self.type else None,
                      self.static,
                      [x.parameterize(parameters) for x in self.arguments] if self.arguments else self.arguments,
                      self.index,
                      self.convention)

    @property
    def convention(self):
        return self._convention

    @convention.setter
    def convention(self, value):
        self._convention = value

    def serialize(self):
        return {
            "name": self.name,
            "index": self.index,
            "kind": "method" if self.kind is Symbol.METHOD else "member",
            "type": self.type,
            "static": self.static,
            "arguments": self.arguments,
            "convention": "bytecode" if self.convention is Symbol.BYTECODE else "internal"
        }

    @classmethod
    def load(cls, data: dict) -> 'Symbol':
        assert data['kind'] in ('member', 'method')
        assert data['convention'] in ('user', 'internal')

        return cls(
{'fraction_non_alphanumeric': 0.10784578053383662, 'fraction_numerical': 0.0, 'mean_word_length': 2.1682322801024765, 'pattern_counts': {'":': 14, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3488112', 'n_tokens_mistral': 1008, 'n_tokens_neox': 978, 'n_words': 278}