compiler: implement *ssa.ChangeType

Этот коммит содержится в:
Ayke van Laethem 2018-09-21 14:47:29 +02:00
родитель 505b1f750d
коммит 2122780309
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: E97FF5335DFDFDED

Просмотреть файл

@ -183,6 +183,18 @@ func (p *Program) interpret(instrs []ssa.Instruction, paramKeys []*ssa.Parameter
return i, nil // arrived at the init#num functions return i, nil // arrived at the init#num functions
} }
return i, errors.New("todo: init call: " + callee.String()) return i, errors.New("todo: init call: " + callee.String())
case *ssa.ChangeType:
x, err := p.getValue(instr.X, locals)
if err != nil {
return i, err
}
// The only case when we need to bitcast is when casting between named
// struct types, as those are actually different in LLVM. Let's just
// bitcast all struct types for ease of use.
if _, ok := instr.Type().Underlying().(*types.Struct); ok {
return i, errors.New("todo: init: " + instr.String())
}
locals[instr] = x
case *ssa.Convert: case *ssa.Convert:
x, err := p.getValue(instr.X, locals) x, err := p.getValue(instr.X, locals)
if err != nil { if err != nil {
@ -369,6 +381,7 @@ func canInterpret(callee *ssa.Function) bool {
// Ignore all functions fully supported by Program.interpret() // Ignore all functions fully supported by Program.interpret()
// above. // above.
case *ssa.Alloc: case *ssa.Alloc:
case *ssa.ChangeType:
case *ssa.Convert: case *ssa.Convert:
case *ssa.DebugRef: case *ssa.DebugRef:
case *ssa.Extract: case *ssa.Extract: