Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 3 additions & 8 deletions devel/200_21.md
Original file line number Diff line number Diff line change
@@ -1,18 +1,13 @@
# [200_21] 从 s7.c 拆分出 s7_r7rs.h 和 s7_r7rs.c

## 任务相关的代码文件
- `src/s7.c`
- `src/s7.h`
- 新文件:`src/s7_r7rs.h`
- 新文件:`src/s7_r7rs.c`

# 200_21
## 如何测试
```
xmake config --yes -vD
xmake build
bin/goldfish tests/test_all.scm
```

## 2026/02/14 s7_scheme_inexact

## 2026/02/14 将 nan? 从 s7.c 迁移至 s7_r7rs.c

## 2026/02/14 将 sqrt 从 s7.c 迁移至 s7_r7rs.c
Expand Down
5 changes: 2 additions & 3 deletions src/s7.c
Original file line number Diff line number Diff line change
Expand Up @@ -408,7 +408,7 @@
#endif

#include "s7.h"
#include "s7_r7rs.h"
#include "s7_scheme_inexact.h"

/* there is also apparently __STDC_NO_COMPLEX__ */
#if WITH_CLANG_PP
Expand Down Expand Up @@ -13197,7 +13197,7 @@ static bool is_positive(s7_scheme *sc, s7_pointer x);
static bool is_negative(s7_scheme *sc, s7_pointer x);
static s7_pointer make_ratio(s7_scheme *sc, s7_int a, s7_int b);

/* is_NaN is declared in s7_r7rs.h and defined in s7_r7rs.c */
/* is_NaN is declared in s7_scheme_inexact.h and defined in s7_scheme_inexact.c */
/* callgrind says this is faster than isnan, I think (very confusing data...) */

#if defined(__sun) && defined(__SVR4)
Expand Down Expand Up @@ -98552,7 +98552,6 @@ static void change_scheme_version(s7_scheme *sc, s7_pointer val)
/* need to check old and new curlet and whether we're coming from s7 or r5rs if envs match, and if either is rootlet, more headaches */
/* if ((!sc->r7rs_inited) || (sc->curlet != sc->rootlet)) */ /* TODO: check multiple threads here, also if not rootlet before and not == now, call r7rs_init again (or don't set flag if local?) */
r7rs_init(sc);
s7_load_c_string_with_environment(sc, r7rs_scm, strlen(r7rs_scm), sc->curlet);
sc->args = args;
}
if ((val == sc->r7rs_symbol) || (val == sc->r5rs_symbol))
Expand Down
6 changes: 2 additions & 4 deletions src/s7_r7rs.c → src/s7_scheme_inexact.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* s7_r7rs.c - R7RS specific implementations for s7 Scheme interpreter
/* s7_scheme_inexact.c - inexact number implementations for s7 Scheme interpreter
*
* derived from s7, a Scheme interpreter
* SPDX-License-Identifier: 0BSD
Expand All @@ -20,13 +20,11 @@
#endif
#endif

#include "s7_r7rs.h"
#include "s7_scheme_inexact.h"
#include <string.h>
#include <time.h>
#include <math.h>

/* R7RS Scheme code string */
const char r7rs_scm[] = "";

/* -------------------------------- sqrt -------------------------------- */
/* Helper function to check for NaN */
Expand Down
13 changes: 5 additions & 8 deletions src/s7_r7rs.h → src/s7_scheme_inexact.h
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
/* s7_r7rs.h - R7RS specific declarations for s7 Scheme interpreter
/* s7_scheme_inexact.h - inexact number declarations for s7 Scheme interpreter
*
* derived from s7, a Scheme interpreter
* SPDX-License-Identifier: 0BSD
*
* Bill Schottstaedt, bil@ccrma.stanford.edu
*/

#ifndef S7_R7RS_H
#define S7_R7RS_H
#ifndef S7_SCHEME_INEXACT_H
#define S7_SCHEME_INEXACT_H

#include "s7.h"

Expand All @@ -18,19 +18,16 @@ extern "C" {
/* Helper function to check for NaN */
bool is_NaN(s7_double x);

/* R7RS specific function declarations */
/* inexact number function declarations */
s7_pointer sqrt_p_p(s7_scheme *sc, s7_pointer num);
s7_pointer g_sqrt(s7_scheme *sc, s7_pointer args);

/* nan? function */
bool s7_is_nan(s7_scheme *sc, s7_pointer x);
s7_pointer g_is_nan(s7_scheme *sc, s7_pointer args);

/* R7RS Scheme code string */
extern const char r7rs_scm[];

#ifdef __cplusplus
}
#endif

#endif /* S7_R7RS_H */
#endif /* S7_SCHEME_INEXACT_H */
2 changes: 1 addition & 1 deletion xmake.lua
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ target ("goldfish") do
end
add_files ("src/goldfish.cpp")
add_files ("src/s7.c", {languages = "c11"})
add_files ("src/s7_r7rs.c", {languages = "c11"})
add_files ("src/s7_scheme_inexact.c", {languages = "c11"})
add_packages("tbox")
add_packages("argh")
add_packages("cpr")
Expand Down