Browse Source

bug fixes in recent patches

Nicolas Cannasse 14 years ago
parent
commit
0f7d684970
3 changed files with 24 additions and 19 deletions
  1. 17 12
      parser.ml
  2. 1 1
      std/flash9/display/MovieClip.hx
  3. 6 6
      typeload.ml

+ 17 - 12
parser.ml

@@ -689,15 +689,18 @@ and parse_macro_cond allow_op s =
 	| [< '(Const (Ident t | Type t),p) >] ->
 		let e = (EConst (Ident t),p) in
 		if not allow_op then
-			e
-		else (match s with parser
-			| [< '(Binop op,_) >] ->
-				make_binop op e (parse_macro_cond true s)
-			| [< >] -> e)
-	| [< '(POpen, p1); e = parse_macro_cond true; '(PClose, p2) >] ->
-		(EParenthesis e,punion p1 p2)
-	| [< '(Unop op,p); e = parse_macro_cond allow_op >] ->
-		make_unop op e p	
+			None, e
+		else (match Stream.peek s with 
+			| Some (Binop op,_) ->
+				Stream.junk s;
+				let tk, e2 = (try parse_macro_cond true s with Stream.Failure -> serror()) in
+				tk, make_binop op e e2
+			| tk ->
+				tk, e);
+	| [< '(POpen, p1); _,e = parse_macro_cond true; '(PClose, p2) >] ->
+		None, (EParenthesis e,punion p1 p2)
+	| [< '(Unop op,p); tk, e = parse_macro_cond allow_op >] ->
+		tk, make_unop op e p
 
 and toplevel_expr s =
 	try
@@ -761,11 +764,13 @@ let parse ctx code =
 			| EParenthesis e -> loop e
 			| _ -> error Unclosed_macro p
 		in
-		if loop (parse_macro_cond false sraw) then begin
+		let tk, e = parse_macro_cond false sraw in
+		let tk = (match tk with None -> Lexer.token code | Some tk -> tk) in
+		if loop e then begin
 			mstack := p :: !mstack;
-			Lexer.token code;
+			tk
 		end else
-			skip_tokens_loop p true (Lexer.token code)
+			skip_tokens_loop p true tk
 
 	and skip_tokens_loop p test tk =
 		match fst tk with

+ 1 - 1
std/flash9/display/MovieClip.hx

@@ -1,6 +1,6 @@
 package flash.display;
 
-extern class MovieClip extends Sprite, #if !flash_strict implements Dynamic #end {
+extern class MovieClip extends Sprite #if !flash_strict, implements Dynamic #end {
 	var currentFrame(default,null) : Int;
 	@:require(flash10) var currentFrameLabel(default,null) : String;
 	var currentLabel(default,null) : String;

+ 6 - 6
typeload.ml

@@ -624,14 +624,14 @@ let patch_class ctx c fields =
 		in
 		List.rev (loop [] fields)
 
-let init_class ctx c p herits fields meta =
+let init_class ctx c p herits fields =
 	let fields = patch_class ctx c fields in
 	ctx.type_params <- c.cl_types;
 	c.cl_extern <- List.mem HExtern herits;
 	c.cl_interface <- List.mem HInterface herits;
 	set_heritance ctx c herits p;
-	let core_api = has_meta ":core_api" meta in
-	let is_macro = has_meta ":macro" meta in
+	let core_api = has_meta ":core_api" c.cl_meta in
+	let is_macro = has_meta ":macro" c.cl_meta in
 	let fields, herits = if is_macro && not ctx.in_macro then begin
 		c.cl_extern <- true;
 		List.filter (fun f -> List.mem AStatic f.cff_access) fields, []
@@ -732,7 +732,7 @@ let init_class ctx c p herits fields meta =
 				| _ -> error "This notation is not allowed because it can't be checked" p
 			) params in
 			if inline && c.cl_interface then error "You can't declare inline methods in interfaces" p;
-			let is_macro = (is_macro && stat) || has_meta ":macro" meta in
+			let is_macro = (is_macro && stat) || has_meta ":macro" f.cff_meta in
 			if is_macro && not stat then error "Only static methods can be macros" p;
 			let fd = if not is_macro then
 				fd
@@ -872,7 +872,7 @@ let init_class ctx c p herits fields meta =
 		| _ :: l ->
 			check_require l
 	in
-	let cl_req = check_require meta in
+	let cl_req = check_require c.cl_meta in
 	let fl = List.map (fun f ->
 		let fd , constr, f , delayed = loop_cf f in
 		let is_static = List.mem AStatic fd.cff_access in
@@ -1118,7 +1118,7 @@ let type_module ctx m tdecls loadp =
 				ctx.local_using<- ctx.local_using @ [resolve_typedef ctx t])
 		| EClass d ->
 			let c = get_class d.d_name in
-			delays := !delays @ check_overriding ctx c p :: check_interfaces ctx c p :: init_class ctx c p d.d_flags d.d_data d.d_meta
+			delays := !delays @ check_overriding ctx c p :: check_interfaces ctx c p :: init_class ctx c p d.d_flags d.d_data
 		| EEnum d ->
 			let e = get_enum d.d_name in
 			ctx.type_params <- e.e_types;