Pārlūkot izejas kodu

allowed > 64k res

Nicolas Cannasse 19 gadi atpakaļ
vecāks
revīzija
d40573b44b
2 mainītis faili ar 9 papildinājumiem un 1 dzēšanām
  1. 1 0
      doc/CHANGES.txt
  2. 8 1
      genneko.ml

+ 1 - 0
doc/CHANGES.txt

@@ -10,6 +10,7 @@
 	fixed scope bug in try/catch with Flash9
 	added remoting over XMLSocket and LocalConnection for Flash9
 	fixed Std.is(*,null) = false
+	allowed >64K haXe/neko strings
 	(TODO) -debug support for both Flash and JS
 	(TODO) resources in Flash9
 

+ 8 - 1
genneko.ml

@@ -153,12 +153,19 @@ let gen_type_path p (path,t) =
 		let epath = List.fold_left (fun e path -> field p e path) (ident p path) l in
 		field p epath t
 
+let rec gen_big_string ctx p s =
+	let max = 1 lsl 16 - 1 in
+	if String.length s > max then
+		(EBinop ("+",str p (String.sub s 0 max),gen_big_string ctx p (String.sub s max (String.length s - max))),p)
+	else
+		str p s
+
 let gen_constant ctx pe c =
 	let p = pos ctx pe in
 	match c with
 	| TInt i -> (try int p (Int32.to_int i) with _ -> Typer.error "This integer is too big to be compiled to a Neko 31-bit integer. Please use a Float instead" pe)
 	| TFloat f -> (EConst (Float f),p)
-	| TString s -> call p (field p (ident p "String") "new") [str p s]
+	| TString s -> call p (field p (ident p "String") "new") [gen_big_string ctx p s]
 	| TBool b -> (EConst (if b then True else False),p)
 	| TNull -> null p
 	| TThis -> this p