Преглед изворни кода

Lua : Add support for throwing errors.

Lua uses an "error" method to throw an exception, instead of "throw".
So, we just need to change the word a bit, and call it as a function.

Note that we're not handling these exceptions with try/catch.  Lua
doesn't have those either, and they'll require additional work to get
something equivalent working.
Justin Donaldson пре 10 година
родитељ
комит
26cb1db708
1 измењених фајлова са 2 додато и 1 уклоњено
  1. 2 1
      genlua.ml

+ 2 - 1
genlua.ml

@@ -478,8 +478,9 @@ and gen_expr ctx e =
 		    gen_value ctx e) el;
 		print ctx " }, %i)" !count;
 	| TThrow e ->
-		spr ctx "throw ";
+		spr ctx "error(";
 		gen_value ctx e;
+		spr ctx ")";
 	| TVar (v,eo) ->
 		begin match eo with
 			| None ->