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 ConstantAggregate

#extract, #insert

Methods included from AbstractClass

included

Methods inherited from Constant

#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.



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

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