mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-09-24 21:30:12 +01:00
Thanks to @ammaralassal for #6329 which did the heavy lifting to make this possible! Co-authored-by: Josh L <josh11b@users.noreply.github.com>
31 lines
879 B
Plaintext
31 lines
879 B
Plaintext
// Part of the Carbon Language project, under the Apache License v2.0 with LLVM
|
|
// Exceptions. See /LICENSE for license information.
|
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
|
|
|
// TODO: This library is not part of the design. Either write a matching
|
|
// proposal or remove this.
|
|
|
|
package Core library "io";
|
|
|
|
import library "prelude";
|
|
|
|
// TODO: Support printing other types.
|
|
// TODO: Consider rewriting using native support once library support exists.
|
|
fn Print(x: i32) = "print.int";
|
|
fn PrintChar(x: char) -> i32 = "print.char";
|
|
|
|
fn PrintStr(msg: str) {
|
|
let size: i64 = msg.Size() as i64;
|
|
var i: i64 = 0;
|
|
while (i < size) {
|
|
PrintChar(msg[i]);
|
|
++i;
|
|
}
|
|
}
|
|
|
|
// TODO: Return an `Optional(char)` instead of `i32`.
|
|
fn ReadChar() -> i32 = "read.char";
|
|
|
|
// TODO: Change this to a global constant once they are fully supported.
|
|
fn EOF() -> i32 { return -1; }
|