prosyslab-classroom / is893-2020-fall

6 stars 7 forks source link

[HW7] why is `Typesystem.type_of_llvalue` necessary? #51

Closed tomtomjhj closed 3 years ago

tomtomjhj commented 3 years ago

I guess Typesystem.type_of_llvalue is for getting the type variable of a variable. But what's the point of type variable when we have access to Llvm.type_of? I believe the homework assumes that the output of Llvm.type_of is trusted because it's necessary for passing the given test which requires declaring the correct type of alloca instruction using Llvm.type_of (ID 11 and ID 12 of the expected output). If Llvm.type_of can be trusted as the source of type info of variables, I think all the stuff related to type_env is unnecessary.

KihongHeo commented 3 years ago

Good question. Let me elaborate:

You have to use Llvm.type_of only for alloca. For all the other cases, you should not trust the output of LLVM.type_of because the dummy front end does not perform type check.

tomtomjhj commented 3 years ago

what about function parameters?

2020년 11월 25일 (수) 오후 6:02, Kihong Heo notifications@github.com님이 작성:

Good question. Let me elaborate:

You have to use Llvm.type_of only for alloca. For all the other cases, you should not trust the output of LLVM.type_of because the dummy front end does not perform type check.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/prosyslab-classroom/is893-2020-fall/issues/51#issuecomment-733566758, or unsubscribe https://github.com/notifications/unsubscribe-auth/AEUWHSUKVP4DRPNLQKKSGADSRTBYZANCNFSM4UCC2YUA .

KihongHeo commented 3 years ago

You should infer the parameter types. Only alloca is trusted.