Browse Source

completed s_expr and s_expr_pretty

Simon Krajewski 12 years ago
parent
commit
11a3bae1e9
3 changed files with 7 additions and 2 deletions
  1. 3 0
      ast.ml
  2. 2 0
      common.ml
  3. 2 2
      type.ml

+ 3 - 0
ast.ml

@@ -136,6 +136,9 @@ module Meta = struct
 
 
 	let has m ml = List.exists (fun (m2,_,_) -> m = m2) ml
 	let has m ml = List.exists (fun (m2,_,_) -> m = m2) ml
 	let get m ml = List.find (fun (m2,_,_) -> m = m2) ml
 	let get m ml = List.find (fun (m2,_,_) -> m = m2) ml
+
+	let to_string_ref = ref (fun _ -> assert false)
+	let to_string (m : strict_meta) : string = !to_string_ref m 
 end
 end
 
 
 type keyword =
 type keyword =

+ 2 - 0
common.ml

@@ -824,3 +824,5 @@ let rec close_times() =
 	| [] -> ()
 	| [] -> ()
 	| t :: _ -> close t; close_times()
 	| t :: _ -> close t; close_times()
 
 
+;;
+Ast.Meta.to_string_ref := fun m -> fst (MetaInfo.to_string m)

+ 2 - 2
type.ml

@@ -1558,7 +1558,7 @@ let rec s_expr s_type e =
 	| TCast (e,t) ->
 	| TCast (e,t) ->
 		sprintf "Cast %s%s" (match t with None -> "" | Some t -> s_type_path (t_path t) ^ ": ") (loop e)
 		sprintf "Cast %s%s" (match t with None -> "" | Some t -> s_type_path (t_path t) ^ ": ") (loop e)
 	| TMeta ((n,el,_),e) ->
 	| TMeta ((n,el,_),e) ->
-		sprintf "@%s%s %s" "TODO" (match el with [] -> "" | _ -> "(" ^ (String.concat ", " (List.map Ast.s_expr el)) ^ ")") (loop e)
+		sprintf "@%s%s %s" (Meta.to_string n) (match el with [] -> "" | _ -> "(" ^ (String.concat ", " (List.map Ast.s_expr el)) ^ ")") (loop e)
 	) in
 	) in
 	sprintf "(%s : %s)" str (s_type e.etype)
 	sprintf "(%s : %s)" str (s_type e.etype)
 
 
@@ -1635,4 +1635,4 @@ let rec s_expr_pretty tabs s_type e =
 	| TCast (e,Some mt) ->
 	| TCast (e,Some mt) ->
 		sprintf "cast (%s,%s)" (loop e) (s_type_path (t_path mt))
 		sprintf "cast (%s,%s)" (loop e) (s_type_path (t_path mt))
 	| TMeta ((n,el,_),e) ->
 	| TMeta ((n,el,_),e) ->
-		sprintf "@%s%s %s" "TODO" (match el with [] -> "" | _ -> "(" ^ (String.concat ", " (List.map Ast.s_expr el)) ^ ")") (loop e)		
+		sprintf "@%s%s %s" (Meta.to_string n) (match el with [] -> "" | _ -> "(" ^ (String.concat ", " (List.map Ast.s_expr el)) ^ ")") (loop e)