@@ -58,10 +58,8 @@ let verify_invoke_args args const_info func_name =
5858 if (List. length args <> List. length const_info) then
5959 raise(WrongInvokedArgumentsLength (" actual and formal argument lists differ in length" ))
6060 else
61- begin
62- (* Use List.iter2 to compare to list*)
61+ (* Use List.iter2 to compare to list*)
6362 List. iter2 compare_args args const_info
64- end
6563
6664(* verify declared types of variables in constructor arguments or methods arguments *)
6765let verify_declared_args current_env arguments =
@@ -101,28 +99,12 @@ let verify_name s env current_env =
10199(* check the type of the assignment operation *)
102100let verify_assignop_type t1 t2 op =
103101 if t1 <> t2 then
104- begin
105- raise(WrongTypesAssignOperation (stringOfOpt t1, string_of_assign_op op ,stringOfOpt t2));
106- match t1 with
107- | Some t ->
108- print_string " \n ************************\n " ;
109- print_string ((stringOf t));
110- print_string " \n ************************\n " ;
111- match t2 with
112- | Some t ->
113- print_string " \n ++++++++++++++++++++++\n " ;
114- print_string ((stringOf t));
115- print_string " \n ++++++++++++++++++++++\n " ;
116- | None -> ()
117- | None -> ()
118- end
102+ raise(WrongTypesAssignOperation (stringOfOpt t1, string_of_assign_op op ,stringOfOpt t2))
119103
120104(* check the type of the operation eg: ==, + *)
121105let verify_operation_type t1 op t2 =
122106 if t1 <> t2 then
123- begin
124- raise(WrongTypesOperation (stringOfOpt t1, string_of_infix_op op, stringOfOpt t2));
125- end
107+ raise(WrongTypesOperation (stringOfOpt t1, string_of_infix_op op, stringOfOpt t2))
126108
127109(* check the type of call expression when it existe the method name, the arguments and global env *)
128110let verify_call_expr meth_name args env class_name =
@@ -153,7 +135,6 @@ let rec verify_array_init_list el =
153135 raise(WrongTypeArrayInitList (stringOfOpt h.etype, stringOfOpt h1.etype)));
154136 verify_array_init_list t
155137
156-
157138(* check the type of the expressions *)
158139let rec verify_expression env current_env e =
159140 (* print_string(string_of_expression_desc(e.edesc)); *)
@@ -416,10 +397,6 @@ let rec verify_statement current_env envs statement =
416397
417398(* check type for constructors *)
418399let verify_constructors envs current_class consts =
419- (* consts is of astconst structure *)
420- (* print_endline ("=====verify_constructors======");
421- print_class_env(Hashtbl.find envs current_class);
422- print_endline ("=====verify_constructors======"); *)
423400 let current_env = {
424401 returntype = Type. Ref ({ tpath = [] ; tid = consts.cname });
425402 variables = Hashtbl. create 17 ;
@@ -471,7 +448,6 @@ let add_constructors env current_class consts =
471448 let consts_table = (Hashtbl. find env current_class).constructors in
472449 if (Hashtbl. mem consts_table consts.cname) <> true
473450 then (
474- (* print_const " " consts; *)
475451 Hashtbl. add consts_table consts.cname
476452 {ftype = Type. Ref {tpath= [] ; tid= current_class};
477453 fargs = consts.cargstype;
@@ -484,21 +460,19 @@ let add_methods env current_class meths =
484460 let meths_table = (Hashtbl. find env current_class).methods in
485461 if (Hashtbl. mem meths_table meths.mname) <> true
486462 then (
487- (* print_method " " meths; *)
488463 Hashtbl. add meths_table meths.mname
489464 {ftype = meths.mreturntype;
490465 fargs = meths.margstype;
491466 fthrows = meths.mthrows }
492467 )
493- (* TODO: check override and overload*)
468+ (* TODO: check override and overload *)
494469 else raise(MethodAlreadyExists (meths.mname))
495470
496471(* check if attribute has already exist in hash table *)
497472let add_attributes env current_class attrs =
498473 let attrs_table = (Hashtbl. find env current_class).attributes in
499474 if (Hashtbl. mem attrs_table attrs.aname) <> true
500475 then (
501- (* print_attribute " " attrs; *)
502476 Hashtbl. add attrs_table attrs.aname attrs.atype
503477 )
504478 else raise(AttributeAlreadyExists (attrs.aname))
0 commit comments