|
@@ -5,13 +5,45 @@ open Typecore
|
|
|
|
|
|
(* PASS 1 begin *)
|
|
|
|
|
|
-let rec verify_ast e = match e.eexpr with
|
|
|
- | TField(_) ->
|
|
|
+let rec verify_ast ctx e =
|
|
|
+ let not_null e e1 = match e1.eexpr with
|
|
|
+ | TConst TNull -> display_error ctx ("Invalid null expression: " ^ (s_expr_pretty "" (s_type (print_context())) e)) e.epos
|
|
|
+ | _ -> ()
|
|
|
+ in
|
|
|
+ let rec loop e = match e.eexpr with
|
|
|
+ | TField(e1,_) ->
|
|
|
+ not_null e e1;
|
|
|
()
|
|
|
+ | TArray(e1,e2) ->
|
|
|
+ not_null e e1;
|
|
|
+ loop e1;
|
|
|
+ loop e2
|
|
|
+ | TCall(e1,el) ->
|
|
|
+ not_null e e1;
|
|
|
+ loop e1;
|
|
|
+ List.iter loop el
|
|
|
+ | TUnop(_,_,e1) ->
|
|
|
+ not_null e e1;
|
|
|
+ loop e1
|
|
|
+ (* probably too messy *)
|
|
|
+(* | TBinop((OpEq | OpNotEq),e1,e2) ->
|
|
|
+ loop e1;
|
|
|
+ loop e2
|
|
|
+ | TBinop((OpAssign | OpAssignOp _),e1,e2) ->
|
|
|
+ not_null e e1;
|
|
|
+ loop e1;
|
|
|
+ loop e2
|
|
|
+ | TBinop(op,e1,e2) ->
|
|
|
+ not_null e e1;
|
|
|
+ not_null e e2;
|
|
|
+ loop e1;
|
|
|
+ loop e2 *)
|
|
|
| TTypeExpr(TClassDecl {cl_kind = KAbstractImpl a}) when not (Meta.has Meta.RuntimeValue a.a_meta) ->
|
|
|
error "Cannot use abstract as value" e.epos
|
|
|
| _ ->
|
|
|
- Type.iter verify_ast e
|
|
|
+ Type.iter loop e
|
|
|
+ in
|
|
|
+ loop e
|
|
|
|
|
|
(*
|
|
|
Wraps implicit blocks in TIf, TFor, TWhile, TFunction and TTry with real ones
|
|
@@ -1120,7 +1152,7 @@ let run com tctx main =
|
|
|
] in
|
|
|
List.iter (run_expression_filters tctx filters) new_types;
|
|
|
Analyzer.Run.run_on_types tctx new_types;
|
|
|
- List.iter (iter_expressions [verify_ast]) new_types;
|
|
|
+ List.iter (iter_expressions [verify_ast tctx]) new_types;
|
|
|
let filters = [
|
|
|
Optimizer.sanitize com;
|
|
|
if com.config.pf_add_final_return then add_final_return else (fun e -> e);
|
|
@@ -1154,7 +1186,7 @@ let run com tctx main =
|
|
|
rename_local_vars tctx;
|
|
|
] in
|
|
|
List.iter (run_expression_filters tctx filters) new_types;
|
|
|
- List.iter (iter_expressions [verify_ast]) new_types;
|
|
|
+ List.iter (iter_expressions [verify_ast tctx]) new_types;
|
|
|
end;
|
|
|
next_compilation();
|
|
|
List.iter (fun f -> f()) (List.rev com.filters); (* macros onGenerate etc. *)
|