-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
(many) Use Perlang strings and native C functions for writing to stdout #389
Conversation
790226c
to
2fdbb69
Compare
@@ -19,12 +19,14 @@ namespace Perlang.Interpreter.Internals | |||
/// </summary> | |||
internal class AstPrinter : Expr.IVisitor<string>, Stmt.IVisitor<string> | |||
{ | |||
// TODO: Return Perlang string instead |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// string as an AsciiString in the created Literal. | ||
return new Expr.Literal(AsciiString.from(chars)); | ||
Lang.String nativeString = Lang.String.from(s); | ||
return new Expr.Literal(nativeString); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The code that used to be here was pretty much inlined in String.from
, to make it be generically usable from elsewhere.
|
||
public void WriteStdoutLine(String s) | ||
{ | ||
int bytesWritten = Libc.Internal.write(Libc.Internal.STDOUT_FILENO, s.Bytes, (int)s.Length); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Interestingly enough, this approach seems to work on both Linux and windows (tested on Windows 10). 😲 If we don't need to write platform-dependent code, we should obviously not be writing platform-dependent code...
(Reading keypresses might be a bigger challenge. We'll get to that eventually, trying to do without Console.ReadKey
)
See #390 for the over-arching goal.