-
Notifications
You must be signed in to change notification settings - Fork 437
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
improve code gen for bs.this when this is not used, add a raw example…
… for bs object
- Loading branch information
Hongbo Zhang
committed
Aug 8, 2016
1 parent
6647d7a
commit 11fb926
Showing
6 changed files
with
82 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -39,3 +39,4 @@ let f (x : x ) = | |
end | ||
end | ||
|
||
let u = fun [@bs.this] (_ : int) (x : int) -> x |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
// GENERATED CODE BY BUCKLESCRIPT VERSION 0.9.0 , PLEASE EDIT WITH CARE | ||
'use strict'; | ||
|
||
|
||
var v = { | ||
x: function () { | ||
return 3; | ||
}, | ||
say: function (x) { | ||
var self = this ; | ||
return self.x() + x | 0; | ||
} | ||
}; | ||
|
||
var u = v.x() + v.say(3) | 0; | ||
|
||
exports.v = v; | ||
exports.u = u; | ||
/* v Not a pure module */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
|
||
|
||
|
||
external config : | ||
x : ('self_type -> 'x [@bs.this]) -> | ||
say :('self_type -> 'x -> 'say [@bs.this]) -> | ||
unit -> | ||
(< | ||
x : unit -> 'x [@bs.meth]; | ||
say : 'x -> 'say [@bs.meth] | ||
> Js.t as 'self_type) = "" [@@bs.obj] | ||
|
||
|
||
let v = | ||
let x = 3 in | ||
config | ||
~x:(fun [@bs.this] _ -> x ) | ||
~say:(fun [@bs.this] self x -> self##x () + x) | ||
() | ||
|
||
(** | ||
let x = 3 in | ||
object (self : 'self_type) | ||
method x = x | ||
method say x = self##x + x | ||
end [@bs] | ||
*) | ||
let u = | ||
v##x () + v##say 3 | ||
|
||
|
||
(* local variables: *) | ||
(* compile-command: "bsc -I ../runtime -drawlambda unsafe_obj_external.ml" *) | ||
(* end: *) |