Class: Rubycc::Type::VoidType

Inherits:
Object
  • Object
show all
Defined in:
lib/rubycc/type.rb

Overview

The incomplete void type. A single shared instance (Type::Void) stands in for every void. It is valid only as a function's return type or as the target of a pointer (void *); every other use (a variable, an array element, a non-pointer parameter, sizeof(void), dereferencing a void *) is rejected by the parser or the generator rather than modelled here. It has no storage width: #size raises, since a well-formed program never asks a bare void for one.

Instance Method Summary collapse

Instance Method Details

#alignmentObject

void has no alignment for the same reason it has no size; a well-formed program never lays a bare void out in storage.



209
210
211
# File 'lib/rubycc/type.rb', line 209

def alignment
  raise "void has no alignment"
end

#arithmetic?Boolean

Returns:

  • (Boolean)


176
177
178
# File 'lib/rubycc/type.rb', line 176

def arithmetic?
  false
end

#array?Boolean

Returns:

  • (Boolean)


188
189
190
# File 'lib/rubycc/type.rb', line 188

def array?
  false
end

#bool?Boolean

Returns:

  • (Boolean)


184
185
186
# File 'lib/rubycc/type.rb', line 184

def bool?
  false
end

#char?Boolean

Returns:

  • (Boolean)


164
165
166
# File 'lib/rubycc/type.rb', line 164

def char?
  false
end

#float?Boolean

Returns:

  • (Boolean)


180
181
182
# File 'lib/rubycc/type.rb', line 180

def float?
  false
end

#function?Boolean

Returns:

  • (Boolean)


196
197
198
# File 'lib/rubycc/type.rb', line 196

def function?
  false
end

#int?Boolean

Returns:

  • (Boolean)


160
161
162
# File 'lib/rubycc/type.rb', line 160

def int?
  false
end

#integer?Boolean

Returns:

  • (Boolean)


172
173
174
# File 'lib/rubycc/type.rb', line 172

def integer?
  false
end

#pointer?Boolean

Returns:

  • (Boolean)


156
157
158
# File 'lib/rubycc/type.rb', line 156

def pointer?
  false
end

#sizeObject

void is incomplete and has no storage width; every call site that might reach a bare void here (sizeof, a global's layout, ...) rejects it first with a proper CompileError, so reaching this is a bug.



203
204
205
# File 'lib/rubycc/type.rb', line 203

def size
  raise "void has no size"
end

#struct?Boolean

Returns:

  • (Boolean)


192
193
194
# File 'lib/rubycc/type.rb', line 192

def struct?
  false
end

#to_sObject



213
214
215
# File 'lib/rubycc/type.rb', line 213

def to_s
  "void"
end

#void?Boolean

Returns:

  • (Boolean)


168
169
170
# File 'lib/rubycc/type.rb', line 168

def void?
  true
end