Permalink
Browse files

[enhance] qmlCpsRewriter: @atomic ensures a computation is atomic or …

…fails at compile time

CHANGELOG The directive @atomic(expr) now checks that the compiler is able to emit an atomic expression computation
  • Loading branch information...
1 parent cb9930e commit db992a7f077207f61a6654a50d2d92b86e404431 @OpaOnWindowsNow OpaOnWindowsNow committed Apr 18, 2012
Showing with 7 additions and 4 deletions.
  1. +7 −4 qmlcps/qmlCpsRewriter.ml
@@ -918,10 +918,13 @@ let il_of_qml ?(can_skip_toplvl=false) (env:env) (private_env:private_env) (expr
| _ -> assert false (* cannot be parsed *)
end
- | Q.Directive (_, `atomic, exprs, tys) ->
- let expr = List.get_only_element exprs in
- let expr = aux expr context in
- IL.Directive (`atomic, [expr], tys)
+ | Q.Directive (_, `atomic, [expr], []) ->
+ begin match aux_can_skip expr context with
+ | (IL.Skip _) as r -> r
+ | _ -> QmlError.error (QmlError.Context.expr expr) "The expression cannot be guaranteed to be atomic"
+ end
+
+ | Q.Directive (_, `atomic, _ , _) -> assert false
| Q.Directive (_, `callcc, [expr], _) ->
let c = IL.fresh_c () and f_callcc = IL.fresh_v () in

0 comments on commit db992a7

Please sign in to comment.