1
1
use interner:: * ;
2
2
use core:: * ;
3
- use types:: { int_type, double_type, function_type, function_type_, Qualified , qualified} ;
3
+ use types:: { int_type, double_type, function_type, function_type_, qualified} ;
4
4
use typecheck:: { Types , DataTypes , TypeEnvironment , find_specialized_instances} ;
5
5
use scoped_map:: ScopedMap ;
6
6
use std:: iter:: range_step;
7
- use std:: vec:: FromVec ;
8
7
use std:: io:: IoResult ;
9
8
10
9
use core:: translate:: { translate_module, translate_modules} ;
@@ -259,11 +258,11 @@ impl Types for Module<Id> {
259
258
for instance in self . instances . iter ( ) {
260
259
let y = match extract_applied_type ( & instance. typ ) {
261
260
& TypeConstructor ( ref x) => x,
262
- _ => fail ! ( )
261
+ _ => panic ! ( )
263
262
} ;
264
263
let z = match extract_applied_type ( typ) {
265
264
& TypeConstructor ( ref x) => x,
266
- _ => fail ! ( )
265
+ _ => panic ! ( )
267
266
} ;
268
267
if classname == instance. classname && y. name == z. name {
269
268
return Some ( ( instance. constraints . as_slice ( ) , & instance. typ ) ) ;
@@ -318,15 +317,15 @@ impl Types for Assembly {
318
317
& TypeApplication ( ref op, ref t) => {
319
318
let x = match extract_applied_type ( * op) {
320
319
& TypeConstructor ( ref x) => x,
321
- _ => fail ! ( )
320
+ _ => panic ! ( )
322
321
} ;
323
322
let y = match extract_applied_type ( * t) {
324
323
& TypeConstructor ( ref x) => x,
325
- _ => fail ! ( )
324
+ _ => panic ! ( )
326
325
} ;
327
326
let z = match extract_applied_type ( typ) {
328
327
& TypeConstructor ( ref x) => x,
329
- _ => fail ! ( )
328
+ _ => panic ! ( )
330
329
} ;
331
330
if classname. name == x. name && y. name == z. name {
332
331
let o : & Type = * t;
@@ -439,16 +438,15 @@ impl <'a> Compiler<'a> {
439
438
}
440
439
self . module = None ;
441
440
Assembly {
442
- superCombinators : FromVec :: from_vec ( superCombinators) ,
443
- instance_dictionaries : FromVec :: from_vec ( instance_dictionaries) ,
441
+ superCombinators : superCombinators,
442
+ instance_dictionaries : instance_dictionaries,
444
443
offset : self . assemblies . iter ( ) . flat_map ( |assembly| assembly. superCombinators . iter ( ) ) . len ( ) ,
445
444
classes : module. classes . clone ( ) ,
446
- instances : FromVec :: < ( Vec < Constraint < Name > > , Type ) > :: from_vec (
447
- module. instances . iter ( )
445
+ instances : module. instances . iter ( )
448
446
. map ( |x| ( x. constraints . clone ( ) , Type :: new_op ( x. classname . name , box [ x. typ . clone ( ) ] ) ) )
449
447
. collect ( )
450
- ) ,
451
- data_definitions : FromVec :: from_vec ( data_definitions)
448
+ ,
449
+ data_definitions : data_definitions
452
450
}
453
451
}
454
452
@@ -476,7 +474,7 @@ impl <'a> Compiler<'a> {
476
474
typ : bind. name . typ . clone ( ) ,
477
475
name : bind. name . name ,
478
476
arity : arity,
479
- instructions : FromVec :: from_vec ( instructions)
477
+ instructions : instructions
480
478
}
481
479
}
482
480
@@ -699,7 +697,7 @@ impl <'a> Compiler<'a> {
699
697
instructions. push ( Eval ) ;
700
698
}
701
699
}
702
- & Lambda ( _, _) => fail ! ( "Error: Found non-lifted lambda when compiling expression" )
700
+ & Lambda ( _, _) => panic ! ( "Error: Found non-lifted lambda when compiling expression" )
703
701
}
704
702
}
705
703
fn compile_apply < ' a > ( & mut self , expr : & Expr < Id > , args : ArgList < ' a > , instructions : & mut Vec < Instruction > , strict : bool ) {
@@ -719,7 +717,7 @@ impl <'a> Compiler<'a> {
719
717
//might be created which is returned here and added to the assembly
720
718
let mut is_primitive = false ;
721
719
let var = self . find ( name. name )
722
- . unwrap_or_else ( || fail ! ( "Error: Undefined variable {}" , * name) ) ;
720
+ . unwrap_or_else ( || panic ! ( "Error: Undefined variable {}" , * name) ) ;
723
721
match var {
724
722
PrimitiveVariable ( ..) => is_primitive = true ,
725
723
_ => ( )
@@ -748,7 +746,7 @@ impl <'a> Compiler<'a> {
748
746
instructions. push ( instruction) ;
749
747
}
750
748
else {
751
- fail ! ( "Expected {} arguments for {}, got {}" , num_args, name, arg_length)
749
+ panic ! ( "Expected {} arguments for {}, got {}" , num_args, name, arg_length)
752
750
}
753
751
is_function = false ;
754
752
}
@@ -765,7 +763,7 @@ impl <'a> Compiler<'a> {
765
763
GlobalVariable ( index) => {
766
764
instructions. push ( PushGlobal ( index) ) ;
767
765
}
768
- _ => fail ! ( )
766
+ _ => panic ! ( )
769
767
}
770
768
}
771
769
}
@@ -820,7 +818,7 @@ impl <'a> Compiler<'a> {
820
818
instructions. push ( PushGlobal ( index) ) ;
821
819
instructions. push ( Mkap ) ;
822
820
}
823
- _ => fail ! ( "Unregistered instance function {}" , instance_fn_name)
821
+ _ => panic ! ( "Unregistered instance function {}" , instance_fn_name)
824
822
}
825
823
}
826
824
None => {
@@ -900,14 +898,14 @@ impl <'a> Compiler<'a> {
900
898
debug ! ( "No dict for {}" , var) ;
901
899
}
902
900
}
903
- _ => fail ! ( "Did not expect generic" )
901
+ _ => panic ! ( "Did not expect generic" )
904
902
}
905
903
}
906
904
907
905
///Lookup which index in the instance dictionary that holds the function called 'name'
908
906
fn push_dictionary_member ( & self , constraints : & [ Constraint < Name > ] , name : Name ) -> Option < uint > {
909
907
if constraints. len ( ) == 0 {
910
- fail ! ( "Attempted to push dictionary member '{}' with no constraints" , name)
908
+ panic ! ( "Attempted to push dictionary member '{}' with no constraints" , name)
911
909
}
912
910
let mut ii = 0 ;
913
911
for c in constraints. iter ( ) {
@@ -951,11 +949,11 @@ impl <'a> Compiler<'a> {
951
949
}
952
950
953
951
if constraints. len ( ) == 0 {
954
- fail ! ( "Error: Attempted to compile dictionary with no constraints at <unknown>" ) ;
952
+ panic ! ( "Error: Attempted to compile dictionary with no constraints at <unknown>" ) ;
955
953
}
956
954
let mut function_indexes = Vec :: new ( ) ;
957
955
self . add_class ( constraints, & mut function_indexes) ;
958
- self . instance_dictionaries . push ( ( constraints. to_owned ( ) , FromVec :: from_vec ( function_indexes) ) ) ;
956
+ self . instance_dictionaries . push ( ( constraints. to_owned ( ) , function_indexes) ) ;
959
957
dict_len
960
958
}
961
959
@@ -973,7 +971,7 @@ impl <'a> Compiler<'a> {
973
971
for decl in declarations. iter ( ) {
974
972
let x = match extract_applied_type ( typ) {
975
973
& TypeConstructor ( ref x) => x,
976
- _ => fail ! ( "{}" , typ)
974
+ _ => panic ! ( "{}" , typ)
977
975
} ;
978
976
let mut b = String :: from_str ( "#" ) ;
979
977
b. push_str ( x. name . as_slice ( ) ) ;
@@ -987,7 +985,7 @@ impl <'a> Compiler<'a> {
987
985
Some ( ConstraintVariable ( index, _, _) ) => {
988
986
function_indexes. push ( index as uint ) ; //TODO this is not really correct since this function requires a dictionary
989
987
}
990
- var => fail ! ( "Did not find function {} {}" , name, var)
988
+ var => panic ! ( "Did not find function {} {}" , name, var)
991
989
}
992
990
}
993
991
None
@@ -1009,7 +1007,7 @@ impl <'a> Compiler<'a> {
1009
1007
branches. push ( instructions. len ( ) ) ;
1010
1008
instructions. push ( Jump ( 0 ) ) ;
1011
1009
}
1012
- _ => fail ! ( "Undefined constructor {}" , * name)
1010
+ _ => panic ! ( "Undefined constructor {}" , * name)
1013
1011
}
1014
1012
instructions. push ( Split ( patterns. len ( ) ) ) ;
1015
1013
self . stackSize += patterns. len ( ) ;
0 commit comments