CFG representation needs type information
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
Mars |
Fix Released
|
High
|
Matt Giuca |
Bug Description
The AST representation carries type information in two ways. Firstly, the type of each variable is known in the localtable. Secondly, each expr has a type.
The CFG representation doesn't carry any type information. The localtable is useless because the variables aren't qualified and there are no temporaries (basically it carries type info for the AST variables, which is a completely different set of variables). And instructions don't carry a type.
This hasn't been a problem so far, but type information will be needed in the CFG for some analysis, as well as code generation.
Either update the localtable in the CFG representation to include the type of every CFG variable, or annotate each instr with the type of the variable it assigns.
Related branches
- Matt Giuca: Approve
-
Diff: 2876 lines (+1121/-410)53 files modifieddoc/intro.rst (+3/-3)
doc/ref/procedures.rst (+23/-6)
doc/ref/types.rst (+152/-5)
lib/prelude.mar (+2/-2)
src/ast_cfg.m (+269/-157)
src/builtins.m (+24/-24)
src/interactive.m (+3/-3)
src/ir.m (+6/-2)
src/mars.m (+2/-2)
src/marsc.m (+2/-2)
src/parsem.m (+7/-2)
src/pretty.m (+2/-1)
src/tables.m (+13/-1)
src/typecheck.m (+243/-177)
src/types.m (+7/-1)
src/util.m (+16/-0)
test/cases/compiler/implicitvar.mar (+47/-0)
test/cases/compiler/patterntypeerror.mar (+27/-0)
test/cases/compiler/patterntypeerror.mtc (+8/-0)
test/cases/compiler/phipred.mtc (+0/-1)
test/cases/compiler/switch.mar (+33/-0)
test/cases/compiler/switch.mtc (+0/-5)
test/cases/semantic/assignglobal.mar (+3/-1)
test/cases/semantic/assignglobal.mtc (+1/-3)
test/cases/semantic/casetypecheck.mtc (+0/-1)
test/cases/semantic/dupfield.mar (+3/-2)
test/cases/semantic/dupfield.mtc (+4/-2)
test/cases/semantic/dupfield2.mar (+5/-0)
test/cases/semantic/dupfield2.mtc (+5/-0)
test/cases/semantic/dupfield3.mtc (+1/-1)
test/cases/semantic/dupvarcase.mar (+16/-0)
test/cases/semantic/dupvarcase.mtc (+8/-0)
test/cases/semantic/dupvarcase2.mar (+17/-0)
test/cases/semantic/dupvarcase2.mtc (+8/-0)
test/cases/semantic/localreadwrite.mtc (+0/-1)
test/cases/semantic/localreadwrite2.mar (+12/-0)
test/cases/semantic/localreadwrite2.mtc (+5/-0)
test/cases/semantic/localtypevar.mar (+14/-0)
test/cases/semantic/localtypevar.mtc (+7/-0)
test/cases/semantic/localtypevar2.mar (+10/-0)
test/cases/semantic/localtypevar2.mtc (+6/-0)
test/cases/semantic/monomorphism.mar (+16/-0)
test/cases/semantic/monomorphism.mtc (+9/-0)
test/cases/semantic/monomorphism2.mar (+23/-0)
test/cases/semantic/monomorphism2.mtc (+9/-0)
test/cases/semantic/typeerror2.mar (+6/-0)
test/cases/semantic/typeerror2.mtc (+9/-0)
test/cases/semantic/typeerror3.mar (+6/-0)
test/cases/semantic/typeerror3.mtc (+9/-0)
test/cases/semantic/typeerror4.mar (+6/-0)
test/cases/semantic/typeerror4.mtc (+9/-0)
test/cases/semantic/undefvar2.mar (+4/-2)
test/cases/semantic/undefvar2.mtc (+1/-3)
Changed in mars: | |
status: | Fix Committed → Fix Released |
The CFG representation does actually contain an assoc_list mapping varnames to types. However, it is given the wrong set of variables by ast_cfg. func_body_ to_cfg (which simply copies the AST decls over to the CFG). This can be fixed by having ast_cfg create a new decls map involving the types of all of the new CFG variables.