Skip to content

Commit

Permalink
remove is_valid_identifier checks for object inlining
Browse files Browse the repository at this point in the history
escaping is still an open question
  • Loading branch information
nadako committed May 16, 2020
1 parent 32d9084 commit e6fbf8f
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 2 deletions.
2 changes: 1 addition & 1 deletion src/optimization/inlineConstructors.ml
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ let inline_constructors ctx e =
end
| TNew({ cl_constructor = Some ({cf_kind = Method MethInline; cf_expr = Some _} as cf)} as c,_,pl),_ when is_extern_ctor c cf ->
error "Extern constructor could not be inlined" e.epos;
| TObjectDecl fl, _ when captured && fl <> [] && List.for_all (fun((s,_,_),_) -> Lexer.is_valid_identifier s) fl -> (* TODO: check what we wanna do with is_valid_identifier here *)
| TObjectDecl fl, _ when captured && fl <> [] ->
let v = alloc_var VGenerated "inlobj" e.etype e.epos in
let ev = mk (TLocal v) v.v_type e.epos in
let el = List.map (fun ((s,_,_),e) ->
Expand Down
1 change: 0 additions & 1 deletion src/optimization/optimizer.ml
Original file line number Diff line number Diff line change
Expand Up @@ -471,7 +471,6 @@ let inline_constructors ctx e =
begin try
let ev = mk (TLocal v) v.v_type e.epos in
let el = List.fold_left (fun acc ((s,_,_),e) ->
if not (Lexer.is_valid_identifier s) then raise Exit; (* TODO: check what we wanna do with is_valid_identifier here *)
let ef = mk (TField(ev,FDynamic s)) e.etype e.epos in
let e = mk (TBinop(OpAssign,ef,e)) e.etype e.epos in
e :: acc
Expand Down

0 comments on commit e6fbf8f

Please sign in to comment.