Permalink
Browse files

[fix] compiler, database: += <expr> as update operation (was restrict…

…ed by syntactic integer)
  • Loading branch information...
1 parent 1454da5 commit 7fd744ed34ab96db668ffd557726061593607cf1 @BourgerieQuentin BourgerieQuentin committed May 11, 2012
@@ -1218,11 +1218,11 @@ module Preprocess = struct
| Db.URemove e -> Db.URemove (coerce_list context e ty)
| Db.UAppendAll e -> Db.UAppendAll (coerce e ty)
| Db.URemoveAll e -> Db.URemoveAll (coerce e ty)
- | Db.UIncr _ when (
- match ty with (* TODO - unify! *)
+ | Db.UIncr e when (
+ match ty with
| Q.TypeConst Q.TyInt -> true
| _ -> false
- ) -> u
+ ) -> Db.UIncr (coerce e ty)
| (Db.UPop | Db.UShift) when (
match ty with (* TODO - unify???! *)
| Q.TypeName ([_], name) when Q.TypeIdent.to_string name = "list" -> true
View
@@ -170,7 +170,7 @@ struct
(* Simple updating*)
| UExpr of 'expr
| UId of 'expr * 'expr update
- | UIncr of int (* TODO : expr*)
+ | UIncr of 'expr
(* List updating *)
| UAppend of 'expr
@@ -285,7 +285,7 @@ struct
(function (f, u) ->
pp fmt "%a : %a," (pp_field pp_expr) f (pp_update pp_expr) u) fields;
pp fmt "}";
- | UIncr i -> pp fmt "+=%i" i
+ | UIncr i -> pp fmt "+=%a" pp_expr i
| UAppend expr -> pp fmt "<+ %a" pp_expr expr
| UAppendAll expr -> pp fmt "<++ %a" pp_expr expr
| URemove expr -> pp fmt "+> %a" pp_expr expr
@@ -477,7 +477,8 @@ struct
let rec sub_db_update sub_e sub_ty = function
- | (UPop | UShift | UIncr _) as e -> TU.sub_ignore e
+ | (UPop | UShift) as e -> TU.sub_ignore e
+ | UIncr expr -> TU.wrap (fun e -> UIncr e) (sub_e expr)
| UExpr expr -> TU.wrap (fun e -> UExpr e) (sub_e expr)
| UId (id, update) ->
TU.wrap
@@ -396,7 +396,6 @@ module Generator = struct
match inc with
| [] -> acc
| (field, value)::q ->
- let annotmap, value = C.int annotmap value in
let annotmap, field = expr_of_strexprpath_rev gamma annotmap field in
aux (add_to_document0 gamma annotmap field value ~ty doc) q
in
@@ -124,14 +124,18 @@ update_fields <-
update_simple <- update_list / update_incr
update_incr <-
- / (=Opa_lexer.exact_symbol("++"))
- {{ QmlAst.Db.UIncr 1 }}
- / (=Opa_lexer.exact_symbol("+=")) spacing Opa_lexer.int:i
- {{ QmlAst.Db.UIncr i }}
- / (=Opa_lexer.exact_symbol("--"))
- {{ QmlAst.Db.UIncr (-1) }}
- / (=Opa_lexer.exact_symbol("-=")) spacing Opa_lexer.int:i
- {{ QmlAst.Db.UIncr (-i) }}
+ / (=Opa_lexer.deco((=Opa_lexer.exact_symbol("++")))):d
+ {{ QmlAst.Db.UIncr ((SurfaceAst.Const (SurfaceAst.CInt (Big_int.big_int_of_int 1))), label d) }}
+ / (=Opa_lexer.exact_symbol("+=")) spacing Opa_parser.expr:e
+ {{ QmlAst.Db.UIncr e }}
+ / (=Opa_lexer.deco((=Opa_lexer.exact_symbol("--")))):d
+ {{ QmlAst.Db.UIncr (SurfaceAst.Const (SurfaceAst.CInt (Big_int.big_int_of_int (-1))), label d) }}
+ / (=Opa_lexer.exact_symbol("-=")) spacing Opa_parser.expr:e
+ {{
+ let l = label e in
+ let minus = (SurfaceAst.Ident Opacapi.unary_minus, l) in
+ QmlAst.Db.UIncr (minus &. [e], l)
+ }}
update_list <-
/ (=Opa_lexer.exact_symbol("<+")) spacing Opa_parser.expr:e

0 comments on commit 7fd744e

Please sign in to comment.