Revision: 1169
Author:
mitc...@gmail.com
Date: Fri Jan 16 20:59:34 2015 UTC
Log: Fix for type skeletons not being written to bytecode
Changed logic in
spitcode.ml to properly write all type
skeletons passed into it by the Codegen module. Previously,
there was a comparison to see if a given type skeleton was a
duplicate of one already written: however, all duplicates
had already been removed, and this check was causing
problems when there were copies of the same type skeleton
already in the list.
Minor indentation changes to
codegen.ml and
absyn.ml
https://code.google.com/p/teyjus/source/detail?r=1169
Modified:
/branches/RenamingRedux/source/compiler/
absyn.ml
/branches/RenamingRedux/source/compiler/
codegen.ml
/branches/RenamingRedux/source/compiler/
spitcode.ml
=======================================
--- /branches/RenamingRedux/source/compiler/
absyn.ml Mon Dec 29 20:36:31
2014 UTC
+++ /branches/RenamingRedux/source/compiler/
absyn.ml Fri Jan 16 20:59:34
2015 UTC
@@ -265,11 +265,11 @@
let string_of_kind (Kind(n,_,_,_,_))=
(Symbol.name n)
-let string_of_kind' (Kind(n,_,_,cat,_))=
+let string_of_kind' (Kind(n,_,indexref,cat,_))=
match cat with
- GlobalKind -> "GK:" ^ (Symbol.name n)
- | LocalKind -> "LK:" ^ (Symbol.name n)
- | PervasiveKind -> "PK:" ^ (Symbol.name n)
+ GlobalKind -> "GK:" ^ (Symbol.name n) ^ "[" ^ string_of_int !indexref
^ "]"
+ | LocalKind -> "LK:" ^ (Symbol.name n) ^ "[" ^ string_of_int !indexref
^ "]"
+ | PervasiveKind -> "PK:" ^ (Symbol.name n) ^ "[" ^
string_of_int !indexref ^ "]"
let print_kind k =
let s = string_of_kind' k in
=======================================
--- /branches/RenamingRedux/source/compiler/
codegen.ml Mon Dec 29 20:36:31
2014 UTC
+++ /branches/RenamingRedux/source/compiler/
codegen.ml Fri Jan 16 20:59:34
2015 UTC
@@ -321,27 +321,26 @@
match skels with
[] -> (List.rev assigned, index)
| (skel :: rest) ->
- (* assign an index to skel: if appeared in skels, then use the index *)
+ (* assign an index to skel: if appeared in skels, then use the
index *)
(* recorded there, otherwise, use the index as the given argument
and*)
(* add skel to the "assigned"
list. *)
- let rec mergeOrAssign skels =
- match skels with
- [] ->
- Absyn.setSkeletonNew skel true;
- Absyn.setSkeletonIndex skel index;
- (skel :: assigned, index + 1)
- | (skel' :: rest') ->
- if (skel' == skel) then (* already dealt with: remove *)
- (assigned, index)
- else
- if (Types.equalMappedTypeSkels skel skel') then
- (Absyn.setSkeletonNew skel false;
- Absyn.setSkeletonIndex skel (Absyn.getSkeletonIndex skel');
- (assigned, index))
- else mergeOrAssign rest'
- in
- let (newAssigned, newIndex) = mergeOrAssign assigned in
- assignSkelIndexAux rest newAssigned newIndex
+ let rec mergeOrAssign skels =
+ match skels with
+ [] ->
+ Absyn.setSkeletonNew skel true;
+ Absyn.setSkeletonIndex skel index;
+ (skel :: assigned, index + 1)
+ | (skel' :: rest') ->
+ if (skel' == skel) then (* already dealt with: remove *)
+ (assigned, index)
+ else
+ if (Types.equalMappedTypeSkels skel skel') then
+ (Absyn.setSkeletonNew skel false;
+ Absyn.setSkeletonIndex skel (Absyn.getSkeletonIndex
skel'); (assigned, index))
+ else mergeOrAssign rest'
+ in
+ let (newAssigned, newIndex) = mergeOrAssign assigned in
+ assignSkelIndexAux rest newAssigned newIndex
in
(* function body of assignSkelIndex *)
=======================================
--- /branches/RenamingRedux/source/compiler/
spitcode.ml Mon Dec 29 20:36:31
2014 UTC
+++ /branches/RenamingRedux/source/compiler/
spitcode.ml Fri Jan 16 20:59:34
2015 UTC
@@ -108,9 +108,7 @@
in
let writeOneTypeSkel tySkel =
- if (Absyn.getSkeletonNew tySkel) then
- writeType (Absyn.getSkeletonType tySkel)
- else ()
+ writeType (Absyn.getSkeletonType tySkel)
in
let Codegen.TypeSkeletonList(tySkelList, numTySkels) = tyskels in