Skip to content

Commit

Permalink
Merge pull request #1063 from andrew-johnson-4/param-print
Browse files Browse the repository at this point in the history
Param print
  • Loading branch information
andrew-johnson-4 authored Jan 10, 2025
2 parents 9df83c8 + eaeb4ab commit 9a60abb
Show file tree
Hide file tree
Showing 10 changed files with 23,113 additions and 23,072 deletions.
46,154 changes: 23,086 additions & 23,068 deletions BOOTSTRAP/cli.c

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "lambda_mountain"
version = "1.20.1"
version = "1.20.2"
authors = ["Andrew <andrew@subarctic.org>"]
license = "MIT"
description = "Typed Macro Assembler (backed by Coq proofs-of-correctness)"
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@

dev: install-production
lm EXAMPLES/phi-types.lsts
lm tests/regress/eprint.lsts
cc -O3 tmp.c
./a.out

Expand Down
1 change: 1 addition & 0 deletions PLATFORM/C/LIB/default.lm
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,4 @@ import PLATFORM/C/LIB/array.lm;
import PLATFORM/C/LIB/io.lm;
import PLATFORM/C/LIB/regex.lm;
import PLATFORM/C/LIB/cmp.lsts;
import PLATFORM/C/LIB/print.lsts;
5 changes: 5 additions & 0 deletions PLATFORM/C/LIB/io.lm
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,14 @@ import string.h;
import unistd.h;
import sys/wait.h;

stdin := λ: Blob(). (: (:expression stdin_l) IO::File);
stdout := λ: Blob(). (: (:expression stdout_l) IO::File);
stderr := λ: Blob(). (: (:expression stderr_l) IO::File);

strcmp := λ: FFI(: l U8[])(: r U8[]). (: () I32);
memcmp := λ: FFI(: l ?[])(: r ?[])(: len U64). (: () U32);
printf := λ: FFI(: format String)(: arg Any). (: () U32);
fprintf := λ: FFI(: io IO::File)(: format String)(: arg Any). (: () U32);
putchar := λ: FFI(: x U32). (: () U32);
exit := λ: FFI(: x U32). (: () Nil);
malloc := λ: FFI(: sz U64). (: () ?[]);
Expand Down
8 changes: 8 additions & 0 deletions PLATFORM/C/LIB/print.lsts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@

let print(e: x): Nil = (
print( stdout(), e );
);

let eprint(e: x): Nil = (
print( stderr(), e );
);
4 changes: 2 additions & 2 deletions PLATFORM/C/LIB/u64.lm
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ fragment type U64; size U64 8; atom suffix U64 _u64;

(declare-unop( into-branch-conditional U64 BranchConditional ( x ) ));

print := λ(: x U64). (: (
(printf( '%lu_s x )) ()
print := λ(: io IO::File)(: x U64). (: (
(fprintf( io '%lu_s x )) ()
) Nil);

max := λ(: x U64)(: y U64). (: (
Expand Down
1 change: 1 addition & 0 deletions PLUGINS/BACKEND/C/mangle-c-type.lm
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ mangle-c-type-internal := λ(: tt Type). (: (
( (TGround( 'F64_s _ )) (set r (SAtom 'double_s)) )
( (TGround( 'String_s _ )) (set r (SAtom 'char*_s)) )
( (TGround( 'File_s _ )) (set r (SAtom 'FILE_s)) )
( (TGround( 'IO::File_s _ )) (set r (SAtom 'FILE*_s)) )
( (TGround( 'PID_s _ )) (set r (SAtom 'pid_t_s)) )
( (TGround( 'Regex_s _ )) (set r (SAtom 'regex_t_s)) )
( (TGround( 'Array_s (LCons( _ (LCons( array-base _ )) )) )) (set r (+( (mangle-c-type array-base) (SAtom '*_s) ))) )
Expand Down
7 changes: 7 additions & 0 deletions tests/regress/eprint.lsts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@

import LIB/default.lm;

let main(): Nil = (
print(1);
eprint(2);
);
1 change: 1 addition & 0 deletions tests/regress/eprint.lsts.out
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
1

0 comments on commit 9a60abb

Please sign in to comment.