Module: Carbon::Core Private

Defined in:
lib/carbon/core.rb,
lib/carbon/core/int.rb,
lib/carbon/core/main.rb,
lib/carbon/core/void.rb,
lib/carbon/core/integer.rb,
lib/carbon/core/pointer.rb,
lib/carbon/core/integer/cast.rb,
lib/carbon/core/integer/math.rb,
lib/carbon/core/integer/misc.rb,
lib/carbon/core/integer/pole.rb,
lib/carbon/core/integer/ship.rb,
lib/carbon/core/integer/sign.rb,
lib/carbon/core/integer/type.rb,
lib/carbon/core/integer/zero.rb,
lib/carbon/core/pointer/cast.rb,
lib/carbon/core/pointer/math.rb,
lib/carbon/core/pointer/type.rb,
lib/carbon/core/pointer/access.rb,
lib/carbon/core/pointer/memory.rb

Overview

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

The Carbon Core library. This is the library that is loaded for every program, and contains definitions that cannot be defined from within Carbon. The Carbon Core library is required for any Carbon program to function.

Defined Under Namespace

Modules: Integer, Main, Pointer, Void Classes: Int

Constant Summary collapse

PATH =

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

Pathname.new(File.expand_path("../core/core.clib", __FILE__))
Ints =

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

The integeral types that are defined in Carbon, and all information pertaining to them.

Returns:

[
  ["Carbon::Int64", "to-int64", :signed, 64],
  ["Carbon::UInt64", "to-uint64", :unsigned, 64],
  ["Carbon::Int32", "to-int32", :signed, 32],
  ["Carbon::UInt32", "to-uint32", :unsigned, 32],
  ["Carbon::Int16", "to-int16", :signed, 16],
  ["Carbon::UInt16", "to-uint16", :unsigned, 16],
  ["Carbon::Int8", "to-int8", :signed, 8],
  ["Carbon::UInt8", "to-uint8", :unsigned, 8],
  ["Carbon::Boolean", "to-bool", :unsigned, 1]
].map { |a| Int.new(Carbon::Type(a[0]), *a[1..-1]) }.deep_freeze!

Class Method Summary collapse

Class Method Details

.define(*options) {|data| ... } ⇒ void

This method returns an undefined value.

Defines an item on the core index.

Examples:

index.class # => Carbon::Concrete::Index
index.define(internal: Carbon::Boolean) do |bool|
  bool[:size] = 1
  bool[:kind] = :integer
  bool[:implements] << Carbon::Type("Carbon::Numeric")
  bool[:implements] << Carbon::Type("Carbon::Boolean")
end
internal = index[Carbon::Boolean]
internal.name # => "Carbon::Boolean"

Parameters:

  • data ({::Symbol => Concrete::Type})

    The name and item type information. There should only be one key pair; any more will cause an error.

Yields:

  • (data)

    To construct the data. At the end of the block, the data should contain all the information needed to create the item.

Yield Parameters:

  • data ({::Symbol => ::Object})

    The data to be passed to the item's intializer.

Raises:

  • (ArgumentError)

    if more than one key-value pair is provided for the data argument.

See Also:



34
35
36
# File 'lib/carbon/core.rb', line 34

def self.define(*options, &block)
  index.define(*options, &block)
end

.define_main(build, pass) ⇒ 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.



49
50
51
# File 'lib/carbon/core.rb', line 49

def self.define_main(build, pass)
  Core::Main.define_main_function(build.module, build.index, pass)
end

.finalizevoid

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.

This method returns an undefined value.

Finalizes the index by defining all of the types on it.



42
43
44
45
46
47
# File 'lib/carbon/core.rb', line 42

def self.finalize
  @index = Concrete::Index.new
  Core::Integer.define_integer
  Core::Pointer.define_pointer
  index.finalize
end

.findObject

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.



53
54
55
56
57
58
59
# File 'lib/carbon/core.rb', line 53

def self.find
  if PATH.exist?
    Concrete.load(PATH.read)
  else
    finalize.tap { |i| PATH.write(Concrete.dump(i)) }
  end
end

.indexConcrete::Index

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.

The core index. This can either be loaded from a core library file or from the definitions in this library.

Returns:



19
20
21
# File 'lib/carbon/core.rb', line 19

def self.index
  @index ||= find
end