// TODO check subtypes func errIfNonFirstClassType(t types.Type, i ssa.Instruction) error { if !types.IsFirstClass(t) { return &InstrError{ Message: "Illegal non-first class type", Instr: i, } } return nil }
func checkLoad(instr *ssa.Load) error { op := ssa.GetOperands(instr)[0] ptr, ok := op.Type().(*types.Pointer) if !ok { return &InstrError{ Instr: instr, Message: "Expected pointer type, found `" + instr.Type().String() + "`", } } if !types.IsFirstClass(ptr.Element()) { return &InstrError{ Instr: instr, Message: "Pointer element type is not first class", } } return nil }