Skip to content
This repository was archived by the owner on Apr 14, 2020. It is now read-only.

Commit e33ca10

Browse files
committed
Fixed uint/int warnings by replacing with isize/usize
1 parent b17c7cc commit e33ca10

File tree

14 files changed

+147
-148
lines changed

14 files changed

+147
-148
lines changed

compiler.rs

Lines changed: 49 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -39,38 +39,38 @@ pub enum Instruction {
3939
DoubleGE,
4040
IntToDouble,
4141
DoubleToInt,
42-
Push(uint),
43-
PushGlobal(uint),
44-
PushInt(int),
42+
Push(usize),
43+
PushGlobal(usize),
44+
PushInt(isize),
4545
PushFloat(f64),
4646
PushChar(char),
4747
Mkap,
4848
Eval,
4949
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),
5454
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),
6161
MkapDictionary,
62-
ConstructDictionary(uint),
63-
PushDictionaryRange(uint, uint)
62+
ConstructDictionary(usize),
63+
PushDictionaryRange(usize, usize)
6464
}
6565
#[derive(Show)]
6666
enum Var<'a> {
67-
Stack(uint),
68-
Global(uint),
67+
Stack(usize),
68+
Global(usize),
6969
Constructor(u16, u16),
7070
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),
7474
Newtype
7575
}
7676

@@ -119,19 +119,19 @@ impl <'a> Clone for Var<'a> {
119119
}
120120

121121
pub struct SuperCombinator {
122-
pub arity : uint,
122+
pub arity : usize,
123123
pub name: Name,
124-
pub assembly_id: uint,
124+
pub assembly_id: usize,
125125
pub instructions : Vec<Instruction>,
126126
pub typ: Qualified<Type, Name>
127127
}
128128
pub struct Assembly {
129129
pub superCombinators: Vec<SuperCombinator>,
130-
pub instance_dictionaries: Vec<Vec<uint>>,
130+
pub instance_dictionaries: Vec<Vec<usize>>,
131131
pub classes: Vec<Class<Id>>,
132132
pub instances: Vec<(Vec<Constraint<Name>>, Type)>,
133133
pub data_definitions: Vec<DataDefinition<Name>>,
134-
pub offset: uint
134+
pub offset: usize
135135
}
136136

137137
trait Globals {
@@ -176,7 +176,7 @@ impl Globals for Assembly {
176176
}
177177
}
178178

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>> {
180180

181181
for class in module.classes.iter() {
182182
for decl in class.declarations.iter() {
@@ -347,7 +347,7 @@ impl DataTypes for Assembly {
347347
}
348348

349349
impl Instruction {
350-
fn stack_change(&self) -> int {
350+
fn stack_change(&self) -> isize {
351351
match *self {
352352
Add | Sub | Multiply | Divide | Remainder | IntEQ | IntLT | IntLE | IntGT | IntGE |
353353
DoubleAdd | DoubleSub | DoubleMultiply | DoubleDivide | DoubleRemainder | DoubleEQ |
@@ -356,14 +356,14 @@ impl Instruction {
356356
Push(..) | PushGlobal(..) | PushInt(..) | PushFloat(..) | PushChar(..) => 1,
357357
Mkap => -1,
358358
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),
363363
CaseJump(..) | Jump(..) | JumpFalse(..) => 0,
364364
PushDictionary(..) | PushDictionaryMember(..) | PushBuiltin(..) => 1,
365365
MkapDictionary => -1,
366-
ConstructDictionary(size) => (size as int) - 1,
366+
ConstructDictionary(size) => (size as isize) - 1,
367367
PushDictionaryRange(..) => 1
368368
}
369369
}
@@ -376,8 +376,8 @@ enum ArgList<'a> {
376376

377377
pub struct Compiler<'a> {
378378
///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,
381381
///Array of all the assemblies which can be used to lookup functions in
382382
pub assemblies: Vec<&'a Assembly>,
383383
module: Option<&'a Module<Id>>,
@@ -474,7 +474,7 @@ impl <'a> Compiler<'a> {
474474
}
475475
}
476476

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 {
478478
match expr {
479479
&Lambda(ref ident, ref body) => {
480480
self.new_stack_var(ident.name.clone());
@@ -569,7 +569,7 @@ impl <'a> Compiler<'a> {
569569
self.variables.insert(identifier, Var::Stack(self.stackSize));
570570
self.stackSize += 1;
571571
}
572-
fn new_var_at(&mut self, identifier : Name, index: uint) {
572+
fn new_var_at(&mut self, identifier : Name, index: usize) {
573573
self.variables.insert(identifier, Var::Stack(index));
574574
}
575575

@@ -660,11 +660,11 @@ impl <'a> Compiler<'a> {
660660
let alt = &alternatives[i];
661661

662662
self.scope(&mut |this| {
663-
let pattern_start = instructions.len() as int;
663+
let pattern_start = instructions.len() as isize;
664664
let mut branches = Vec::new();
665665
let i = this.stackSize - 1;
666666
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;
668668
this.compile(&alt.expression, instructions, strict);
669669
instructions.push(Slide(stack_increase));
670670
instructions.push(Jump(0));//Should jump to the end
@@ -674,11 +674,11 @@ impl <'a> Compiler<'a> {
674674
//We need to set all the jump instructions to their actual location
675675
//and append Slide instructions to bring the stack back to normal if the match fails
676676
for j in range_step(pattern_end, pattern_start, -1) {
677-
match instructions[j as uint] {
677+
match instructions[j as usize] {
678678
Jump(_) => {
679-
instructions[j as uint] = Jump(instructions.len());
679+
instructions[j as usize] = Jump(instructions.len());
680680
}
681-
JumpFalse(_) => instructions[j as uint] = JumpFalse(instructions.len()),
681+
JumpFalse(_) => instructions[j as usize] = JumpFalse(instructions.len()),
682682
Split(size) => instructions.push(Pop(size)),
683683
_ => ()
684684
}
@@ -784,7 +784,7 @@ impl <'a> Compiler<'a> {
784784
}
785785
}
786786

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 {
788788
match *args {
789789
ArgList::Cons(arg, rest) => {
790790
let i = self.compile_args(rest, instructions, strict);
@@ -900,13 +900,13 @@ impl <'a> Compiler<'a> {
900900
}
901901

902902
///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> {
904904
if constraints.len() == 0 {
905905
panic!("Attempted to push dictionary member '{:?}' with no constraints", name)
906906
}
907907
let mut ii = 0;
908908
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> {
910910
for decl in declarations.iter() {
911911
if decl.name == name {
912912
return Some(ii)
@@ -936,7 +936,7 @@ impl <'a> Compiler<'a> {
936936

937937
///Find the index of the instance dictionary for the constraints and types in 'constraints'
938938
///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 {
940940
//Check if the dictionary already exist
941941
let dict_len = self.instance_dictionaries.len();
942942
for ii in range(0, dict_len) {
@@ -954,7 +954,7 @@ impl <'a> Compiler<'a> {
954954
dict_len
955955
}
956956

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>) {
958958

959959
for &(ref class_name, ref typ) in constraints.iter() {
960960
self.walk_classes(*class_name, &mut |declarations| -> Option<()> {
@@ -970,10 +970,10 @@ impl <'a> Compiler<'a> {
970970
let name = Name { name: f, uid: decl.name.uid };
971971
match self.find(name) {
972972
Some(Var::Global(index)) => {
973-
function_indexes.push(index as uint);
973+
function_indexes.push(index as usize);
974974
}
975975
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
977977
}
978978
var => panic!("Did not find function {:?} {:?}", name, var)
979979
}
@@ -986,14 +986,14 @@ impl <'a> Compiler<'a> {
986986
///Compiles a pattern.
987987
///An index to the Jump instruction which is taken when the match fails is stored in the branches vector
988988
///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 {
990990
debug!("Pattern {:?} at {:?}", pattern, stack_size);
991991
match pattern {
992992
&Pattern::Constructor(ref name, ref patterns) => {
993993
instructions.push(Push(stack_size));
994994
match self.find_constructor(name.name) {
995995
Some((tag, _)) => {
996-
instructions.push(CaseJump(tag as uint));
996+
instructions.push(CaseJump(tag as usize));
997997
branches.push(instructions.len());
998998
instructions.push(Jump(0));
999999
}

core.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ pub struct Alternative<Ident> {
6363
pub enum Pattern<Ident> {
6464
Constructor(Ident, Vec<Ident>),
6565
Identifier(Ident),
66-
Number(int),
66+
Number(isize),
6767
WildCard
6868
}
6969

@@ -688,7 +688,7 @@ impl <'a> Translator<'a> {
688688
result
689689
}
690690

691-
fn unwrap_pattern(&mut self, uid: uint, id: Id<Name>, pattern: module::Pattern<Name>, result: &mut Vec<(Id<Name>, Pattern<Id<Name>>)>) {
691+
fn unwrap_pattern(&mut self, uid: usize, id: Id<Name>, pattern: module::Pattern<Name>, result: &mut Vec<(Id<Name>, Pattern<Id<Name>>)>) {
692692
match pattern {
693693
module::Pattern::Constructor(ctor_name, mut patterns) => {
694694
let index = result.len();
@@ -729,7 +729,7 @@ impl <'a> Translator<'a> {
729729
}
730730
///Translates a pattern list of patterns into a list of patterns which are not nested.
731731
///The first argument of each tuple is the identifier that is expected to be passed to the case.
732-
fn unwrap_patterns(&mut self, uid: uint, arg_ids: &[Id<Name>], arguments: &[module::Pattern<Name>]) -> Vec<(Id<Name>, Pattern<Id<Name>>)> {
732+
fn unwrap_patterns(&mut self, uid: usize, arg_ids: &[Id<Name>], arguments: &[module::Pattern<Name>]) -> Vec<(Id<Name>, Pattern<Id<Name>>)> {
733733
let mut result = Vec::new();
734734
for (p, id) in arguments.iter().zip(arg_ids.iter()) {
735735
self.unwrap_pattern(uid, id.clone(), p.clone(), &mut result);

graph.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,15 @@ use std::iter::repeat;
55
use std::cmp::min;
66

77
#[derive(PartialEq, Copy, Show)]
8-
pub struct VertexIndex(uint);
8+
pub struct VertexIndex(usize);
99
#[derive(PartialEq, Copy, Show)]
10-
pub struct EdgeIndex(uint);
10+
pub struct EdgeIndex(usize);
1111

1212
impl VertexIndex {
13-
fn get(&self) -> uint { let VertexIndex(v) = *self; v }
13+
fn get(&self) -> usize { let VertexIndex(v) = *self; v }
1414
}
1515
impl EdgeIndex {
16-
fn get(&self) -> uint { let EdgeIndex(v) = *self; v }
16+
fn get(&self) -> usize { let EdgeIndex(v) = *self; v }
1717
}
1818

1919
struct Vertex<T> {
@@ -57,7 +57,7 @@ impl <T> Graph<T> {
5757
}
5858

5959
///Returns how many vertices are in the graph
60-
pub fn len(&self) -> uint {
60+
pub fn len(&self) -> usize {
6161
self.vertices.len()
6262
}
6363
}
@@ -82,10 +82,10 @@ pub fn strongly_connected_components<T>(graph: &Graph<T>) -> Vec<Vec<VertexIndex
8282
}
8383

8484
struct TarjanComponents<'a, T: 'a>{
85-
index: uint,
85+
index: usize,
8686
graph: &'a Graph<T>,
87-
valid: Vec<uint>,
88-
lowlink: Vec<uint>,
87+
valid: Vec<usize>,
88+
lowlink: Vec<usize>,
8989
stack: Vec<VertexIndex>,
9090
connections: Vec<Vec<VertexIndex>>
9191
}

infix.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use renamer::Name;
33
use interner::intern;
44
use std::collections::HashMap;
55

6-
pub struct PrecedenceVisitor { precedence: HashMap<Name, (int, Assoc)> }
6+
pub struct PrecedenceVisitor { precedence: HashMap<Name, (isize, Assoc)> }
77

88
impl MutVisitor<Name> for PrecedenceVisitor {
99
fn visit_expr(&mut self, expr: &mut TypedExpr<Name>) {
@@ -35,7 +35,7 @@ impl PrecedenceVisitor {
3535
PrecedenceVisitor { precedence: map }
3636
}
3737

38-
fn get_precedence(&self, name: &Name) -> (int, Assoc) {
38+
fn get_precedence(&self, name: &Name) -> (isize, Assoc) {
3939
self.precedence.get(name)
4040
.map(|x| *x)
4141
.unwrap_or_else(|| (9, Assoc::Left))

interner.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@ use std::cell::RefCell;
44
use std::fmt;
55

66
#[derive(Eq, PartialEq, Clone, Copy, Default, Hash)]
7-
pub struct InternedStr(uint);
7+
pub struct InternedStr(usize);
88

99
pub struct Interner {
10-
indexes: HashMap<String, uint>,
10+
indexes: HashMap<String, usize>,
1111
strings: Vec<String>
1212
}
1313

lambda_lift.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ impl FreeVariables {
3434
//free variables to its arguments and performs an immediate application
3535
//@variables All the local variables in scope, values are how many of the name there exists
3636
//@free_vars The free variables for the returned expression
37-
fn free_variables(&mut self, variables: &mut HashMap<Name, int>, free_vars: &mut HashMap<Name, TypeAndStr>, expr: &mut Expr<TypeAndStr>) {
37+
fn free_variables(&mut self, variables: &mut HashMap<Name, isize>, free_vars: &mut HashMap<Name, TypeAndStr>, expr: &mut Expr<TypeAndStr>) {
3838
match *expr {
3939
Identifier(ref mut i) => {
4040
//If the identifier is a local, add it to the free variables
@@ -262,7 +262,7 @@ test2 x =
262262
}
263263

264264
struct CheckAbstract {
265-
count: int
265+
count: isize
266266
}
267267

268268
fn get_let<'a>(expr: &'a Expr<Id>, args: &mut Vec<InternedStr>) -> &'a Expr<Id> {

0 commit comments

Comments
 (0)