@@ -39,38 +39,38 @@ pub enum Instruction {
39
39
DoubleGE ,
40
40
IntToDouble ,
41
41
DoubleToInt ,
42
- Push ( uint ) ,
43
- PushGlobal ( uint ) ,
44
- PushInt ( int ) ,
42
+ Push ( usize ) ,
43
+ PushGlobal ( usize ) ,
44
+ PushInt ( isize ) ,
45
45
PushFloat ( f64 ) ,
46
46
PushChar ( char ) ,
47
47
Mkap ,
48
48
Eval ,
49
49
Unwind ,
50
- Update ( uint ) ,
51
- Pop ( uint ) ,
52
- Slide ( uint ) ,
53
- Split ( uint ) ,
50
+ Update ( usize ) ,
51
+ Pop ( usize ) ,
52
+ Slide ( usize ) ,
53
+ Split ( usize ) ,
54
54
Pack ( u16 , u16 ) ,
55
- CaseJump ( uint ) ,
56
- Jump ( uint ) ,
57
- JumpFalse ( uint ) ,
58
- PushDictionary ( uint ) ,
59
- PushDictionaryMember ( uint ) ,
60
- PushBuiltin ( uint ) ,
55
+ CaseJump ( usize ) ,
56
+ Jump ( usize ) ,
57
+ JumpFalse ( usize ) ,
58
+ PushDictionary ( usize ) ,
59
+ PushDictionaryMember ( usize ) ,
60
+ PushBuiltin ( usize ) ,
61
61
MkapDictionary ,
62
- ConstructDictionary ( uint ) ,
63
- PushDictionaryRange ( uint , uint )
62
+ ConstructDictionary ( usize ) ,
63
+ PushDictionaryRange ( usize , usize )
64
64
}
65
65
#[ derive( Show ) ]
66
66
enum Var < ' a > {
67
- Stack ( uint ) ,
68
- Global ( uint ) ,
67
+ Stack ( usize ) ,
68
+ Global ( usize ) ,
69
69
Constructor ( u16 , u16 ) ,
70
70
Class ( & ' a Type , & ' a [ Constraint < Name > ] , & ' a TypeVariable ) ,
71
- Constraint ( uint , & ' a Type , & ' a [ Constraint < Name > ] ) ,
72
- Builtin ( uint ) ,
73
- Primitive ( uint , Instruction ) ,
71
+ Constraint ( usize , & ' a Type , & ' a [ Constraint < Name > ] ) ,
72
+ Builtin ( usize ) ,
73
+ Primitive ( usize , Instruction ) ,
74
74
Newtype
75
75
}
76
76
@@ -119,19 +119,19 @@ impl <'a> Clone for Var<'a> {
119
119
}
120
120
121
121
pub struct SuperCombinator {
122
- pub arity : uint ,
122
+ pub arity : usize ,
123
123
pub name : Name ,
124
- pub assembly_id : uint ,
124
+ pub assembly_id : usize ,
125
125
pub instructions : Vec < Instruction > ,
126
126
pub typ : Qualified < Type , Name >
127
127
}
128
128
pub struct Assembly {
129
129
pub superCombinators : Vec < SuperCombinator > ,
130
- pub instance_dictionaries : Vec < Vec < uint > > ,
130
+ pub instance_dictionaries : Vec < Vec < usize > > ,
131
131
pub classes : Vec < Class < Id > > ,
132
132
pub instances : Vec < ( Vec < Constraint < Name > > , Type ) > ,
133
133
pub data_definitions : Vec < DataDefinition < Name > > ,
134
- pub offset : uint
134
+ pub offset : usize
135
135
}
136
136
137
137
trait Globals {
@@ -176,7 +176,7 @@ impl Globals for Assembly {
176
176
}
177
177
}
178
178
179
- fn find_global < ' a > ( module : & ' a Module < Id > , offset : uint , name : Name ) -> Option < Var < ' a > > {
179
+ fn find_global < ' a > ( module : & ' a Module < Id > , offset : usize , name : Name ) -> Option < Var < ' a > > {
180
180
181
181
for class in module. classes . iter ( ) {
182
182
for decl in class. declarations . iter ( ) {
@@ -347,7 +347,7 @@ impl DataTypes for Assembly {
347
347
}
348
348
349
349
impl Instruction {
350
- fn stack_change ( & self ) -> int {
350
+ fn stack_change ( & self ) -> isize {
351
351
match * self {
352
352
Add | Sub | Multiply | Divide | Remainder | IntEQ | IntLT | IntLE | IntGT | IntGE |
353
353
DoubleAdd | DoubleSub | DoubleMultiply | DoubleDivide | DoubleRemainder | DoubleEQ |
@@ -356,14 +356,14 @@ impl Instruction {
356
356
Push ( ..) | PushGlobal ( ..) | PushInt ( ..) | PushFloat ( ..) | PushChar ( ..) => 1 ,
357
357
Mkap => -1 ,
358
358
Eval | Unwind | Update ( ..) => 0 ,
359
- Pop ( s) => -( s as int ) ,
360
- Slide ( s) => -( s as int ) ,
361
- Split ( s) => ( s as int ) - 1 ,
362
- Pack ( _, s) => 1 - ( s as int ) ,
359
+ Pop ( s) => -( s as isize ) ,
360
+ Slide ( s) => -( s as isize ) ,
361
+ Split ( s) => ( s as isize ) - 1 ,
362
+ Pack ( _, s) => 1 - ( s as isize ) ,
363
363
CaseJump ( ..) | Jump ( ..) | JumpFalse ( ..) => 0 ,
364
364
PushDictionary ( ..) | PushDictionaryMember ( ..) | PushBuiltin ( ..) => 1 ,
365
365
MkapDictionary => -1 ,
366
- ConstructDictionary ( size) => ( size as int ) - 1 ,
366
+ ConstructDictionary ( size) => ( size as isize ) - 1 ,
367
367
PushDictionaryRange ( ..) => 1
368
368
}
369
369
}
@@ -376,8 +376,8 @@ enum ArgList<'a> {
376
376
377
377
pub struct Compiler < ' a > {
378
378
///Hashmap containging class names mapped to the functions it contains
379
- pub instance_dictionaries : Vec < ( Vec < ( Name , Type ) > , Vec < uint > ) > ,
380
- pub stackSize : uint ,
379
+ pub instance_dictionaries : Vec < ( Vec < ( Name , Type ) > , Vec < usize > ) > ,
380
+ pub stackSize : usize ,
381
381
///Array of all the assemblies which can be used to lookup functions in
382
382
pub assemblies : Vec < & ' a Assembly > ,
383
383
module : Option < & ' a Module < Id > > ,
@@ -474,7 +474,7 @@ impl <'a> Compiler<'a> {
474
474
}
475
475
}
476
476
477
- fn compile_lambda_binding ( & mut self , expr : & Expr < Id > , instructions : & mut Vec < Instruction > ) -> uint {
477
+ fn compile_lambda_binding ( & mut self , expr : & Expr < Id > , instructions : & mut Vec < Instruction > ) -> usize {
478
478
match expr {
479
479
& Lambda ( ref ident, ref body) => {
480
480
self . new_stack_var ( ident. name . clone ( ) ) ;
@@ -569,7 +569,7 @@ impl <'a> Compiler<'a> {
569
569
self . variables . insert ( identifier, Var :: Stack ( self . stackSize ) ) ;
570
570
self . stackSize += 1 ;
571
571
}
572
- fn new_var_at ( & mut self , identifier : Name , index : uint ) {
572
+ fn new_var_at ( & mut self , identifier : Name , index : usize ) {
573
573
self . variables . insert ( identifier, Var :: Stack ( index) ) ;
574
574
}
575
575
@@ -660,11 +660,11 @@ impl <'a> Compiler<'a> {
660
660
let alt = & alternatives[ i] ;
661
661
662
662
self . scope ( & mut |this| {
663
- let pattern_start = instructions. len ( ) as int ;
663
+ let pattern_start = instructions. len ( ) as isize ;
664
664
let mut branches = Vec :: new ( ) ;
665
665
let i = this. stackSize - 1 ;
666
666
let stack_increase = this. compile_pattern ( & alt. pattern , & mut branches, instructions, i) ;
667
- let pattern_end = instructions. len ( ) as int ;
667
+ let pattern_end = instructions. len ( ) as isize ;
668
668
this. compile ( & alt. expression , instructions, strict) ;
669
669
instructions. push ( Slide ( stack_increase) ) ;
670
670
instructions. push ( Jump ( 0 ) ) ; //Should jump to the end
@@ -674,11 +674,11 @@ impl <'a> Compiler<'a> {
674
674
//We need to set all the jump instructions to their actual location
675
675
//and append Slide instructions to bring the stack back to normal if the match fails
676
676
for j in range_step ( pattern_end, pattern_start, -1 ) {
677
- match instructions[ j as uint ] {
677
+ match instructions[ j as usize ] {
678
678
Jump ( _) => {
679
- instructions[ j as uint ] = Jump ( instructions. len ( ) ) ;
679
+ instructions[ j as usize ] = Jump ( instructions. len ( ) ) ;
680
680
}
681
- JumpFalse ( _) => instructions[ j as uint ] = JumpFalse ( instructions. len ( ) ) ,
681
+ JumpFalse ( _) => instructions[ j as usize ] = JumpFalse ( instructions. len ( ) ) ,
682
682
Split ( size) => instructions. push ( Pop ( size) ) ,
683
683
_ => ( )
684
684
}
@@ -784,7 +784,7 @@ impl <'a> Compiler<'a> {
784
784
}
785
785
}
786
786
787
- fn compile_args ( & mut self , args : & ArgList , instructions : & mut Vec < Instruction > , strict : bool ) -> uint {
787
+ fn compile_args ( & mut self , args : & ArgList , instructions : & mut Vec < Instruction > , strict : bool ) -> usize {
788
788
match * args {
789
789
ArgList :: Cons ( arg, rest) => {
790
790
let i = self . compile_args ( rest, instructions, strict) ;
@@ -900,13 +900,13 @@ impl <'a> Compiler<'a> {
900
900
}
901
901
902
902
///Lookup which index in the instance dictionary that holds the function called 'name'
903
- fn push_dictionary_member ( & self , constraints : & [ Constraint < Name > ] , name : Name ) -> Option < uint > {
903
+ fn push_dictionary_member ( & self , constraints : & [ Constraint < Name > ] , name : Name ) -> Option < usize > {
904
904
if constraints. len ( ) == 0 {
905
905
panic ! ( "Attempted to push dictionary member '{:?}' with no constraints" , name)
906
906
}
907
907
let mut ii = 0 ;
908
908
for c in constraints. iter ( ) {
909
- let result = self . walk_classes ( c. class , & mut |declarations| -> Option < uint > {
909
+ let result = self . walk_classes ( c. class , & mut |declarations| -> Option < usize > {
910
910
for decl in declarations. iter ( ) {
911
911
if decl. name == name {
912
912
return Some ( ii)
@@ -936,7 +936,7 @@ impl <'a> Compiler<'a> {
936
936
937
937
///Find the index of the instance dictionary for the constraints and types in 'constraints'
938
938
///Returns the index
939
- fn find_dictionary_index ( & mut self , constraints : & [ ( Name , Type ) ] ) -> uint {
939
+ fn find_dictionary_index ( & mut self , constraints : & [ ( Name , Type ) ] ) -> usize {
940
940
//Check if the dictionary already exist
941
941
let dict_len = self . instance_dictionaries . len ( ) ;
942
942
for ii in range ( 0 , dict_len) {
@@ -954,7 +954,7 @@ impl <'a> Compiler<'a> {
954
954
dict_len
955
955
}
956
956
957
- fn add_class ( & self , constraints : & [ ( Name , Type ) ] , function_indexes : & mut Vec < uint > ) {
957
+ fn add_class ( & self , constraints : & [ ( Name , Type ) ] , function_indexes : & mut Vec < usize > ) {
958
958
959
959
for & ( ref class_name, ref typ) in constraints. iter ( ) {
960
960
self . walk_classes ( * class_name, & mut |declarations| -> Option < ( ) > {
@@ -970,10 +970,10 @@ impl <'a> Compiler<'a> {
970
970
let name = Name { name : f, uid : decl. name . uid } ;
971
971
match self . find ( name) {
972
972
Some ( Var :: Global ( index) ) => {
973
- function_indexes. push ( index as uint ) ;
973
+ function_indexes. push ( index as usize ) ;
974
974
}
975
975
Some ( Var :: Constraint ( index, _, _) ) => {
976
- function_indexes. push ( index as uint ) ; //TODO this is not really correct since this function requires a dictionary
976
+ function_indexes. push ( index as usize ) ; //TODO this is not really correct since this function requires a dictionary
977
977
}
978
978
var => panic ! ( "Did not find function {:?} {:?}" , name, var)
979
979
}
@@ -986,14 +986,14 @@ impl <'a> Compiler<'a> {
986
986
///Compiles a pattern.
987
987
///An index to the Jump instruction which is taken when the match fails is stored in the branches vector
988
988
///These instructions will need to be updated later with the correct jump location.
989
- fn compile_pattern ( & mut self , pattern : & Pattern < Id > , branches : & mut Vec < uint > , instructions : & mut Vec < Instruction > , stack_size : uint ) -> uint {
989
+ fn compile_pattern ( & mut self , pattern : & Pattern < Id > , branches : & mut Vec < usize > , instructions : & mut Vec < Instruction > , stack_size : usize ) -> usize {
990
990
debug ! ( "Pattern {:?} at {:?}" , pattern, stack_size) ;
991
991
match pattern {
992
992
& Pattern :: Constructor ( ref name, ref patterns) => {
993
993
instructions. push ( Push ( stack_size) ) ;
994
994
match self . find_constructor ( name. name ) {
995
995
Some ( ( tag, _) ) => {
996
- instructions. push ( CaseJump ( tag as uint ) ) ;
996
+ instructions. push ( CaseJump ( tag as usize ) ) ;
997
997
branches. push ( instructions. len ( ) ) ;
998
998
instructions. push ( Jump ( 0 ) ) ;
999
999
}
0 commit comments