Module: Carbon::Concrete

Defined in:
lib/carbon/concrete.rb,
lib/carbon/concrete/item.rb,
lib/carbon/concrete/type.rb,
lib/carbon/concrete/build.rb,
lib/carbon/concrete/index.rb,
lib/carbon/concrete/item/base.rb,
lib/carbon/concrete/item/data.rb,
lib/carbon/concrete/type/name.rb,
lib/carbon/concrete/type/part.rb,
lib/carbon/concrete/item/class.rb,
lib/carbon/concrete/item/trait.rb,
lib/carbon/concrete/type/parse.rb,
lib/carbon/concrete/item/struct.rb,
lib/carbon/concrete/type/generic.rb,
lib/carbon/concrete/item/function.rb,
lib/carbon/concrete/item/internal.rb,
lib/carbon/concrete/type/function.rb,
lib/carbon/concrete/item/class/element.rb,
lib/carbon/concrete/item/struct/element.rb,
lib/carbon/concrete/item/trait/expectation.rb

Overview

A concrete representation of the global state of a compilation. All of the things within this module should be serializable, so that libraries may be linked easily back into the process.

Defined Under Namespace

Modules: Item Classes: Build, Index, Type

Constant Summary collapse

OPTIONS =
{ circular: true, class_cache: true }.freeze

Class Method Summary collapse

Class Method Details

.dump(index) ⇒ ::String

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Dumps an object to a string. If the object responds to #to_basic, the result of that method call is used instead. The object is then serialized, and then compressed using Zlib (Deflate).

Parameters:

  • index (::Object)

    The object to dump.

Returns:

  • (::String)

    The dumped object.

See Also:



40
41
42
43
# File 'lib/carbon/concrete.rb', line 40

def self.dump(index)
  raw = Oj.dump(index, OPTIONS)
  Zlib::Deflate.deflate(raw, 9)
end

.load(source) ⇒ ::Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Loads a dumped object into an instance. The dumped object should be a Zlib compressed (with Deflate) string. The dumped object is decompressed and loaded, then passed to from.

Parameters:

  • source (::String)

    The dumped object.

Returns:

  • (::Object)

    The represented object.

See Also:



27
28
29
30
# File 'lib/carbon/concrete.rb', line 27

def self.load(source)
  raw = Zlib::Inflate.inflate(source)
  Oj.load(raw, OPTIONS)
end