Class: RLTK::CG::ConstantString

Inherits:
ConstantArray show all
Defined in:
lib/rltk/cg/value.rb

Overview

A sub-class of ConstantArray specifically for holding strings.

Instance Attribute Summary

Attributes included from BindingClass

#ptr

Instance Method Summary collapse

Methods inherited from ConstantArray

#size

Methods inherited from ConstantAggregate

#extract, #insert

Methods inherited from Constant

#addr_space_cast, #bitcast_to, #get_element_ptr, #get_element_ptr_in_bounds

Methods inherited from User

#operands

Methods inherited from Value

#==, #attributes, #bitcast, #constant?, #dump, #hash, #name, #name=, #null?, #print, #trunc, #trunc_or_bitcast, #type, #undefined?, #zextend, #zextend_or_bitcast

Methods included from BindingClass

#==

Constructor Details

#initialize(string, null_terminate = true, context = nil) ⇒ ConstantString

Create a new constant string value.

Parameters:

  • string (String)

    Sting to turn into a value.

  • null_terminate (Boolean) (defaults to: true)

    To null terminate the string or not.

  • context (Context, nil) (defaults to: nil)

    Context in which to create the value.



435
436
437
438
439
440
441
442
443
444
# File 'lib/rltk/cg/value.rb', line 435

def initialize(string, null_terminate = true, context = nil)
	@type = ArrayType.new(Int8Type)

	@ptr =
	if context
		Bindings.const_string_in_context(check_type(context, Context, 'context'), string, string.length, null_terminate.to_i)
	else
		Bindings.const_string(string, string.length, null_terminate.to_i)
	end
end