Class: CastOff::Compiler::SimpleIR::LoopKey

Inherits:
Object
  • Object
show all
Includes:
Util
Defined in:
lib/cast_off/compile/ir/call_ir.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Util

#bug, #dlog, #todo, #vlog

Constructor Details

#initialize(id, key, args, insn, translator) ⇒ LoopKey

Returns a new instance of LoopKey.



1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
# File 'lib/cast_off/compile/ir/call_ir.rb', line 1277

def initialize(id, key, args, insn, translator)
  @id = id          # method name
  @key = key          # loop number
  @args = args
  @argc = args.size

  @translator = translator
  @insn = insn

  @signiture = nil
  @klass = nil
end

Instance Attribute Details

#argcObject (readonly)

Returns the value of attribute argc.



1274
1275
1276
# File 'lib/cast_off/compile/ir/call_ir.rb', line 1274

def argc
  @argc
end

#block_iseqObject

Returns the value of attribute block_iseq.



1275
1276
1277
# File 'lib/cast_off/compile/ir/call_ir.rb', line 1275

def block_iseq
  @block_iseq
end

#idObject (readonly)

Returns the value of attribute id.



1274
1275
1276
# File 'lib/cast_off/compile/ir/call_ir.rb', line 1274

def id
  @id
end

#keyObject (readonly)

Returns the value of attribute key.



1274
1275
1276
# File 'lib/cast_off/compile/ir/call_ir.rb', line 1274

def key
  @key
end

#klassObject (readonly)

Returns the value of attribute klass.



1274
1275
1276
# File 'lib/cast_off/compile/ir/call_ir.rb', line 1274

def klass
  @klass
end

Instance Method Details

#arg_argcObject



1329
1330
1331
1332
# File 'lib/cast_off/compile/ir/call_ir.rb', line 1329

def arg_argc
  bug() unless @block_iseq
  @block_iseq.args.argc
end

#arg_post_lenObject



1334
1335
1336
1337
# File 'lib/cast_off/compile/ir/call_ir.rb', line 1334

def arg_post_len
  bug() unless @block_iseq
  @block_iseq.args.post_len
end

#arg_post_startObject



1339
1340
1341
1342
# File 'lib/cast_off/compile/ir/call_ir.rb', line 1339

def arg_post_start
  bug() unless @block_iseq
  @block_iseq.args.post_start
end

#arg_rest_indexObject



1344
1345
1346
1347
# File 'lib/cast_off/compile/ir/call_ir.rb', line 1344

def arg_rest_index
  bug() unless @block_iseq
  @block_iseq.args.rest_index
end

#declObject



1353
1354
1355
1356
1357
# File 'lib/cast_off/compile/ir/call_ir.rb', line 1353

def decl
  bug() unless resolved?
  bug() unless @signiture
  "cast_off_#{@signiture}_t #{self.to_s}"
end

#decl?Boolean

Returns:

  • (Boolean)


1349
1350
1351
# File 'lib/cast_off/compile/ir/call_ir.rb', line 1349

def decl?
  resolved?
end

#dopt_funcObject



1377
1378
1379
1380
1381
# File 'lib/cast_off/compile/ir/call_ir.rb', line 1377

def dopt_func
  bug() unless resolved?
  bug() unless @signiture
  "cast_off_#{@signiture}_construct_frame"
end

#finl_funcObject



1371
1372
1373
1374
1375
# File 'lib/cast_off/compile/ir/call_ir.rb', line 1371

def finl_func
  bug() unless resolved?
  bug() unless @signiture
  "cast_off_#{@signiture}_finl"
end

#loop_funcObject



1365
1366
1367
1368
1369
# File 'lib/cast_off/compile/ir/call_ir.rb', line 1365

def loop_func
  bug() unless resolved?
  bug() unless @signiture
  "cast_off_#{@signiture}_loop"
end

#prep_funcObject



1359
1360
1361
1362
1363
# File 'lib/cast_off/compile/ir/call_ir.rb', line 1359

def prep_func
  bug() unless resolved?
  bug() unless @signiture
  "cast_off_#{@signiture}_prep"
end

#resolve(classes) ⇒ Object



1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
# File 'lib/cast_off/compile/ir/call_ir.rb', line 1294

def resolve(classes)
  classes.each do |c|
    bug() unless c.is_a?(ClassWrapper)
    # method exist
    begin
      sign = SupportLoopInstruction[MethodWrapper.new(c, @id)]
    rescue CompileError
      sign = nil
    end
    if @translator.inline_block? && !sign
      @translator.unsupported_or_re_compilation("Unsupported loop method: #{c}##{@id}")
    end
    @translator.unsupported_or_re_compilation(<<-EOS) if @signiture && @signiture != sign && @translator.inline_block?

Currently, CastOff doesn't support a method invocation which target is not single and which takes a block.
#{@klass}##{@id} and #{c}##{@id} are different methods.
----------------------------------------------------------------------------------------------------------
Target file is (#{@translator.target_name()}).
Call site is (#{@insn}).
    EOS
    @signiture = sign
    @klass = c
  end
  bug() if @translator.inline_block? && !resolved?
end

#resolved?Boolean

Returns:

  • (Boolean)


1290
1291
1292
# File 'lib/cast_off/compile/ir/call_ir.rb', line 1290

def resolved?
  !!@signiture
end

#splat?Boolean

Returns:

  • (Boolean)


1324
1325
1326
1327
# File 'lib/cast_off/compile/ir/call_ir.rb', line 1324

def splat?
  bug() unless @block_iseq
  @block_iseq.args.splat?
end

#to_sObject



1320
1321
1322
# File 'lib/cast_off/compile/ir/call_ir.rb', line 1320

def to_s
  (resolved? && @signiture) ? "cast_off_#{@signiture}_#{@key}" : "unresolved"
end