forked from jasder/antlr
Add `new` keyword to return proper InputStreams
Currently the JS runtime sometimes returns (and mangles) the global `window` object instead of a proper InputStream. This is prevented by using the `new` keyword in all cases.
This commit is contained in:
parent
b404abb11e
commit
5e648f0867
|
@ -144,3 +144,4 @@ YYYY/MM/DD, github id, Full name, email
|
|||
2017/03/15, robertvanderhulst, Robert van der Hulst, robert@xsharp.eu
|
||||
2017/03/28, cmd-johnson, Jonas Auer, jonas.auer.94@gmail.com
|
||||
2017/04/12, lys0716, Yishuang Lu, luyscmu@gmail.com
|
||||
2017/05/11, jimallman, Jim Allman, jim@ibang.com
|
||||
|
|
|
@ -18,7 +18,7 @@ var fs = isNodeJs ? require("fs") : null;
|
|||
var CharStreams = {
|
||||
// Creates an InputStream from a string.
|
||||
fromString: function(str) {
|
||||
return InputStream(str, true);
|
||||
return new InputStream(str, true);
|
||||
},
|
||||
|
||||
// Asynchronously creates an InputStream from a blob given the
|
||||
|
@ -41,7 +41,7 @@ var CharStreams = {
|
|||
// encoding of the bytes in that buffer (defaults to 'utf8' if
|
||||
// encoding is null).
|
||||
fromBuffer: function(buffer, encoding) {
|
||||
return InputStream(buffer.toString(encoding), true);
|
||||
return new InputStream(buffer.toString(encoding), true);
|
||||
},
|
||||
|
||||
// Asynchronously creates an InputStream from a file on disk given
|
||||
|
@ -64,7 +64,7 @@ var CharStreams = {
|
|||
// 'utf8' if encoding is null).
|
||||
fromPathSync: function(path, encoding) {
|
||||
var data = fs.readFileSync(path, encoding);
|
||||
return InputStream(data, true);
|
||||
return new InputStream(data, true);
|
||||
}
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in New Issue