|
@@ -24,6 +24,7 @@ open Ast
|
|
|
open Type
|
|
|
open Common
|
|
|
open ExtList
|
|
|
+open Error
|
|
|
|
|
|
type pos = Globals.pos
|
|
|
|
|
@@ -74,7 +75,7 @@ let get_exposed ctx path meta = try
|
|
|
(match args with
|
|
|
| [ EConst (String s), _ ] -> [s]
|
|
|
| [] -> [path]
|
|
|
- | _ -> abort "Invalid @:expose parameters" pos)
|
|
|
+ | _ -> error "Invalid @:expose parameters" pos)
|
|
|
with Not_found -> []
|
|
|
|
|
|
let dot_path = Globals.s_type_path
|
|
@@ -158,7 +159,7 @@ let println ctx =
|
|
|
newline ctx
|
|
|
end)
|
|
|
|
|
|
-let unsupported p = abort "This expression cannot be compiled to Lua" p
|
|
|
+let unsupported p = error "This expression cannot be compiled to Lua" p
|
|
|
|
|
|
let basename path =
|
|
|
try
|
|
@@ -342,7 +343,7 @@ let rec gen_call ctx e el =
|
|
|
(match e.eexpr , el with
|
|
|
| TConst TSuper , params ->
|
|
|
(match ctx.current.cl_super with
|
|
|
- | None -> abort "Missing api.setCurrentClass" e.epos
|
|
|
+ | None -> error "Missing api.setCurrentClass" e.epos
|
|
|
| Some (c,_) ->
|
|
|
print ctx "%s.super(%s" (ctx.type_accessor (TClassDecl c)) (this ctx);
|
|
|
List.iter (fun p -> print ctx ","; gen_value ctx p) params;
|
|
@@ -350,7 +351,7 @@ let rec gen_call ctx e el =
|
|
|
);
|
|
|
| TField ({ eexpr = TConst TSuper },f) , params ->
|
|
|
(match ctx.current.cl_super with
|
|
|
- | None -> abort "Missing api.setCurrentClass" e.epos
|
|
|
+ | None -> error "Missing api.setCurrentClass" e.epos
|
|
|
| Some (c,_) ->
|
|
|
let name = field_name f in
|
|
|
print ctx "%s.prototype%s(%s" (ctx.type_accessor (TClassDecl c)) (field name) (this ctx);
|
|
@@ -395,7 +396,7 @@ let rec gen_call ctx e el =
|
|
|
if List.length(fields) > 0 then incr count;
|
|
|
| { eexpr = TConst(TNull)} -> ()
|
|
|
| _ ->
|
|
|
- abort "__lua_table__ only accepts array or anonymous object arguments" e.epos;
|
|
|
+ error "__lua_table__ only accepts array or anonymous object arguments" e.epos;
|
|
|
)) el;
|
|
|
spr ctx "})";
|
|
|
| TIdent "__lua__", [{ eexpr = TConst (TString code) }] ->
|
|
@@ -1436,13 +1437,13 @@ let check_multireturn ctx c =
|
|
|
match c with
|
|
|
| _ when Meta.has Meta.MultiReturn c.cl_meta ->
|
|
|
if not c.cl_extern then
|
|
|
- abort "MultiReturns must be externs" c.cl_pos
|
|
|
+ error "MultiReturns must be externs" c.cl_pos
|
|
|
else if List.length c.cl_ordered_statics > 0 then
|
|
|
- abort "MultiReturns must not contain static fields" c.cl_pos
|
|
|
+ error "MultiReturns must not contain static fields" c.cl_pos
|
|
|
else if (List.exists (fun cf -> match cf.cf_kind with Method _ -> true | _-> false) c.cl_ordered_fields) then
|
|
|
- abort "MultiReturns must not contain methods" c.cl_pos;
|
|
|
+ error "MultiReturns must not contain methods" c.cl_pos;
|
|
|
| {cl_super = Some(csup,_)} when Meta.has Meta.MultiReturn csup.cl_meta ->
|
|
|
- abort "Cannot extend a MultiReturn" c.cl_pos
|
|
|
+ error "Cannot extend a MultiReturn" c.cl_pos
|
|
|
| _ -> ()
|
|
|
|
|
|
|
|
@@ -1469,7 +1470,7 @@ let generate_package_create ctx (p,_) =
|
|
|
let check_field_name c f =
|
|
|
match f.cf_name with
|
|
|
| "prototype" | "__proto__" | "constructor" ->
|
|
|
- abort ("The field name '" ^ f.cf_name ^ "' is not allowed in Lua") (match f.cf_expr with None -> c.cl_pos | Some e -> e.epos);
|
|
|
+ error ("The field name '" ^ f.cf_name ^ "' is not allowed in Lua") (match f.cf_expr with None -> c.cl_pos | Some e -> e.epos);
|
|
|
| _ -> ()
|
|
|
|
|
|
(* convert a.b.c to ["a"]["b"]["c"] *)
|
|
@@ -1557,7 +1558,7 @@ let generate_class ctx c =
|
|
|
ctx.current <- c;
|
|
|
ctx.id_counter <- 0;
|
|
|
(match c.cl_path with
|
|
|
- | [],"Function" -> abort "This class redefines a native one" c.cl_pos
|
|
|
+ | [],"Function" -> error "This class redefines a native one" c.cl_pos
|
|
|
| _ -> ());
|
|
|
let p = s_path ctx c.cl_path in
|
|
|
let hxClasses = has_feature ctx "Type.resolveClass" in
|
|
@@ -1753,7 +1754,7 @@ let generate_require ctx path meta =
|
|
|
| [(EConst(String(module_name)),_) ; (EConst(String(object_path)),_)] ->
|
|
|
print ctx "%s = _G.require(\"%s\").%s" p module_name object_path
|
|
|
| _ ->
|
|
|
- abort "Unsupported @:luaRequire format" mp);
|
|
|
+ error "Unsupported @:luaRequire format" mp);
|
|
|
|
|
|
newline ctx
|
|
|
|
|
@@ -1768,7 +1769,7 @@ let generate_type ctx = function
|
|
|
if p = "Std" && c.cl_ordered_statics = [] then
|
|
|
()
|
|
|
else if (not c.cl_extern) && Meta.has Meta.LuaDotMethod c.cl_meta then
|
|
|
- abort "LuaDotMethod is valid for externs only" c.cl_pos
|
|
|
+ error "LuaDotMethod is valid for externs only" c.cl_pos
|
|
|
else if not c.cl_extern then
|
|
|
generate_class ctx c
|
|
|
else if Meta.has Meta.InitPackage c.cl_meta then
|