Example #1
0
 def GetScopeSymbol(self, scope_proto, parent_scope_symbol=None):
     symbol_id = self._NewSymbolId4Scope(scope_proto)
     serialized_scope_proto = scope_proto.SerializeToString()
     if symbol_storage.HasSymbol4SerializedScopeProto(serialized_scope_proto):
         return symbol_storage.GetSymbol4SerializedScopeProto(serialized_scope_proto)
     symbol = scope_util.ScopeSymbol(symbol_id, scope_proto, parent_scope_symbol)
     symbol_storage.SetSymbol4Id(symbol_id, symbol)
     symbol_storage.SetSymbol4SerializedScopeProto(serialized_scope_proto, symbol)
     return symbol
Example #2
0
def AddScopeToStorage(scope_symbol_id, scope_proto_str):
    if symbol_storage.HasSymbol4SerializedScopeProto(scope_proto_str):
        return
    scope_proto = text_format.Parse(scope_proto_str, scope_pb.ScopeProto())
    parent_scope_symbol = symbol_storage.GetSymbol4Id(
        scope_proto.parent_scope_symbol_id
    )
    symbol = scope_symbol.ScopeSymbol(scope_symbol_id, scope_proto, parent_scope_symbol)
    symbol_storage.SetSymbol4Id(scope_symbol_id, symbol)
    symbol_storage.SetSymbol4SerializedScopeProto(scope_proto_str, symbol)
Example #3
0
def AddScopeToStorage(scope_symbol_id, scope_proto):
    scope_proto_str = str(scope_proto)
    if symbol_storage.HasSymbol4SerializedScopeProto(scope_proto_str):
        return
    parent_scope_symbol = symbol_storage.GetSymbol4Id(
        scope_proto.parent_scope_symbol_id())
    symbol = scope_symbol.ScopeSymbol(scope_symbol_id, scope_proto,
                                      parent_scope_symbol)
    symbol_storage.SetSymbol4Id(scope_symbol_id, symbol)
    symbol_storage.SetSymbol4SerializedScopeProto(scope_proto_str, symbol)