Skip to content

Commit ff3e34b

Browse files
v0.13.6 (#491)
New Features: - `list->search` and `str->search` now takes an additional optional parameter (the starting position). - `str->search` now returns the end position of the found `str` (as well as the start). - Allow no trailing new line at end of files. - Add `eval` function. - Add `math.log2` and `math.log10`. Bug Fixes: - Fix bug with calling `str->trim(whitespace)`. - Clean up how `io` handles files with newlines on Windows. - Fix error messages for all `bool` methods. - Fix error where ref counting in upvals was not done correctly in some cases. Internal Changes: - Clean up directory structure - Clean up tests for errors - Start preliminary work on GC.
1 parent ef0f3e7 commit ff3e34b

File tree

417 files changed

+1364
-820
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

417 files changed

+1364
-820
lines changed

CMakeLists.txt

Lines changed: 117 additions & 102 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,11 @@ set(CMAKE_CXX_STANDARD 11)
2020

2121
# 4244 is lossy coercions:
2222
# https://docs.microsoft.com/en-us/cpp/error-messages/compiler-warnings/compiler-warning-levels-3-and-4-c4244
23+
# 4003 is empty macro parameters:
24+
# https://learn.microsoft.com/en-us/cpp/error-messages/compiler-warnings/compiler-warning-level-1-c4003?view=msvc-170
2325
if(MSVC)
2426
add_definitions(-D_CRT_SECURE_NO_WARNINGS)
25-
set(CMAKE_C_FLAGS "/WX /W3 /wd4244")
27+
set(CMAKE_C_FLAGS "/WX /W3 /wd4244 /wd4003")
2628
endif()
2729

2830
if (NOT "${CMAKE_C_COMPILER_ID}" MATCHES ".*MSVC.*")
@@ -43,112 +45,116 @@ endif()
4345
set(CMAKE_VERBOSE_MAKEFILE OFF)
4446

4547
include_directories(.)
46-
include_directories(compiler)
47-
include_directories(data-structures)
48-
include_directories(interpreter)
49-
include_directories(util)
50-
include_directories(std)
48+
include_directories(src)
49+
include_directories(src/common)
50+
include_directories(src/compiler)
51+
include_directories(src/data-structures)
52+
include_directories(src/interpreter)
53+
include_directories(src/util)
54+
include_directories(src/std)
5155
include_directories(test)
5256

5357
add_executable(yasl
54-
opcode.h
55-
yasl.c
56-
yasl_aux.c
57-
main.c
58-
compiler/ast.c
59-
data-structures/YASL_ByteBuffer.c
60-
data-structures/YASL_Buffer.c
61-
data-structures/YASL_Table.c
62-
compiler/compiler.c
63-
compiler/env.c
64-
compiler/lexer.c
65-
compiler/lexinput.c
66-
compiler/middleend.c
67-
compiler/parser.c
68-
interpreter/upvalue.c
69-
interpreter/closure.c
70-
interpreter/bool_methods.c
71-
interpreter/builtins.c
72-
interpreter/float_methods.c
73-
util/yasl_float.c
74-
interpreter/int_methods.c
75-
data-structures/YASL_List.c
76-
interpreter/list_methods.c
77-
interpreter/table_methods.c
78-
interpreter/VM.c
79-
interpreter/YASL_Object.c
80-
interpreter/refcount.c
81-
interpreter/str_methods.c
82-
data-structures/LString.c
83-
data-structures/YASL_String.c
84-
data-structures/YASL_StringSet.c
85-
interpreter/userdata.c
86-
interpreter/undef_methods.c
87-
std/yasl-std-io.c
88-
std/yasl-std-math.c
89-
std/yasl-std-require.c
90-
std/yasl-std-error.c
91-
data-structures/YASL_Set.c
92-
std/yasl-std-collections.c
93-
std/yasl-std-mt.c
94-
std/yasl-std-os.c
95-
std/yasl-std-try.c
96-
util/hash_function.c
97-
util/IO.c
98-
util/prime.c
99-
util/varint.c
100-
yapp.h
101-
yasl_conf.h
102-
yasl_error.h
103-
yasl_types.h
104-
yasl_plat.h)
58+
src/common/opcode.h
59+
src/yasl.c
60+
src/yasl_aux.c
61+
src/main.c
62+
src/compiler/ast.c
63+
src/data-structures/YASL_ByteBuffer.c
64+
src/data-structures/YASL_Buffer.c
65+
src/data-structures/YASL_Table.c
66+
src/compiler/compiler.c
67+
src/compiler/env.c
68+
src/compiler/lexer.c
69+
src/compiler/lexinput.c
70+
src/compiler/middleend.c
71+
src/compiler/parser.c
72+
src/interpreter/upvalue.c
73+
src/interpreter/closure.c
74+
src/interpreter/bool_methods.c
75+
src/interpreter/builtins.c
76+
src/interpreter/float_methods.c
77+
src/util/yasl_float.c
78+
src/interpreter/int_methods.c
79+
src/data-structures/YASL_List.c
80+
src/interpreter/list_methods.c
81+
src/interpreter/table_methods.c
82+
src/interpreter/VM.c
83+
src/interpreter/GC.c
84+
src/interpreter/YASL_Object.c
85+
src/interpreter/refcount.c
86+
src/interpreter/str_methods.c
87+
src/data-structures/LString.c
88+
src/data-structures/YASL_String.c
89+
src/data-structures/YASL_StringSet.c
90+
src/interpreter/userdata.c
91+
src/interpreter/undef_methods.c
92+
src/std/yasl-std-io.c
93+
src/std/yasl-std-math.c
94+
src/std/yasl-std-require.c
95+
src/std/yasl-std-error.c
96+
src/data-structures/YASL_Set.c
97+
src/std/yasl-std-collections.c
98+
src/std/yasl-std-mt.c
99+
src/std/yasl-std-os.c
100+
src/std/yasl-std-try.c
101+
src/util/hash_function.c
102+
src/util/IO.c
103+
src/util/prime.c
104+
src/util/varint.c
105+
src/util/yapp.h
106+
src/yasl_conf.h
107+
src/yasl_error.h
108+
src/interpreter/yasl_types.h
109+
src/yasl_plat.h)
105110

106111
add_library(yaslapi
107-
opcode.h
108-
yasl.c
109-
yasl_aux.c
110-
compiler/ast.c
111-
data-structures/YASL_ByteBuffer.c
112-
data-structures/YASL_Buffer.c
113-
compiler/compiler.c
114-
compiler/env.c
115-
compiler/lexer.c
116-
compiler/lexinput.c
117-
compiler/parser.c
118-
compiler/middleend.c
119-
util/hash_function.c
120-
data-structures/YASL_Table.c
121-
interpreter/bool_methods.c
122-
interpreter/builtins.c
123-
interpreter/float_methods.c
124-
interpreter/upvalue.c
125-
interpreter/closure.c
126-
util/yasl_float.c
127-
interpreter/int_methods.c
128-
data-structures/YASL_List.c
129-
data-structures/LString.c
130-
data-structures/YASL_StringSet.c
131-
interpreter/list_methods.c
132-
interpreter/table_methods.c
133-
interpreter/VM.c
134-
interpreter/YASL_Object.c
135-
interpreter/refcount.c
136-
interpreter/str_methods.c
137-
data-structures/YASL_String.c
138-
interpreter/userdata.c
139-
interpreter/undef_methods.c
140-
util/prime.c
141-
util/IO.c
142-
util/varint.c
143-
std/yasl-std-collections.c
144-
std/yasl-std-error.c
145-
std/yasl-std-io.c
146-
std/yasl-std-math.c
147-
std/yasl-std-require.c
148-
data-structures/YASL_Set.c
149-
std/yasl-std-mt.c
150-
std/yasl-std-os.c
151-
std/yasl-std-try.c)
112+
src/common/opcode.h
113+
src/yasl.c
114+
src/yasl_aux.c
115+
src/compiler/ast.c
116+
src/data-structures/YASL_ByteBuffer.c
117+
src/data-structures/YASL_Buffer.c
118+
src/compiler/compiler.c
119+
src/compiler/env.c
120+
src/compiler/lexer.c
121+
src/compiler/lexinput.c
122+
src/compiler/parser.c
123+
src/compiler/middleend.c
124+
src/util/hash_function.c
125+
src/data-structures/YASL_Table.c
126+
src/interpreter/bool_methods.c
127+
src/interpreter/builtins.c
128+
src/interpreter/float_methods.c
129+
src/interpreter/upvalue.c
130+
src/interpreter/closure.c
131+
src/util/yasl_float.c
132+
src/interpreter/int_methods.c
133+
src/data-structures/YASL_List.c
134+
src/data-structures/LString.c
135+
src/data-structures/YASL_StringSet.c
136+
src/interpreter/list_methods.c
137+
src/interpreter/table_methods.c
138+
src/interpreter/VM.c
139+
src/interpreter/GC.c
140+
src/interpreter/YASL_Object.c
141+
src/interpreter/refcount.c
142+
src/interpreter/str_methods.c
143+
src/data-structures/YASL_String.c
144+
src/interpreter/userdata.c
145+
src/interpreter/undef_methods.c
146+
src/util/prime.c
147+
src/util/IO.c
148+
src/util/varint.c
149+
src/std/yasl-std-collections.c
150+
src/std/yasl-std-error.c
151+
src/std/yasl-std-io.c
152+
src/std/yasl-std-math.c
153+
src/std/yasl-std-require.c
154+
src/data-structures/YASL_Set.c
155+
src/std/yasl-std-mt.c
156+
src/std/yasl-std-os.c
157+
src/std/yasl-std-try.c)
152158

153159
set_property(TARGET yaslapi PROPERTY POSITION_INDEPENDENT_CODE ON)
154160

@@ -181,22 +187,31 @@ add_executable(tests
181187
test/unit_tests/test_methods/listtest.c
182188
test/unit_tests/test_methods/strtest.c
183189
test/unit_tests/test_vm/vmtest.c
190+
test/unit_tests/test_gc/gctest.c
184191
test/unit_tests/test_util/utiltest.c
185192
test/unit_tests/test_api/fntest.c
186193
test/unit_tests/test_api/deltest.c
187194
test/unit_tests/test_api/tablenexttest.c
188195
test/unit_tests/test_api/listitertest.c)
189196

197+
add_library(test_module SHARED
198+
test/test_module.c
199+
)
200+
201+
set_property(TARGET test_module PROPERTY POSITION_INDEPENDENT_CODE ON)
202+
190203
if (NOT "${CMAKE_CXX_COMPILER_ID}" MATCHES ".*MSVC.*")
191204
target_link_libraries(yasl m)
192205
target_link_libraries(yaslapi m)
193206
target_link_libraries(tests m)
194207
endif()
195208

196209
target_link_libraries(tests yaslapi)
210+
target_link_libraries(test_module yaslapi)
197211

198212
if (NOT WIN32)
199213
target_link_libraries(yasl dl)
200214
target_link_libraries(yaslapi dl)
201215
target_link_libraries(tests dl)
216+
target_link_libraries(test_module dl)
202217
endif()

azure-pipelines.yml

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ jobs:
2121
make yasl
2222
make yaslapi
2323
make tests
24+
make test_module
2425
displayName: "Compile"
2526
- script:
2627
tests.exe
@@ -65,6 +66,7 @@ jobs:
6566
make yasl
6667
make yaslapi
6768
make tests
69+
make test_module
6870
displayName: "Compile"
6971
- script:
7072
./tests
@@ -88,6 +90,7 @@ jobs:
8890
make yasl
8991
make yaslapi
9092
make tests
93+
make test_module
9194
displayName: "Compile"
9295
- script:
9396
./tests
@@ -113,6 +116,7 @@ jobs:
113116
make yasl
114117
make yaslapi
115118
make tests
119+
make test_module
116120
displayName: "Compile"
117121
- script:
118122
./tests
@@ -138,6 +142,7 @@ jobs:
138142
make yasl
139143
make yaslapi
140144
make tests
145+
make test_module
141146
displayName: "Compile"
142147
- script:
143148
./tests
@@ -162,6 +167,7 @@ jobs:
162167
make yasl
163168
make yaslapi
164169
make tests
170+
make test_module
165171
displayName: "Compile"
166172
- script:
167173
./tests
@@ -188,6 +194,7 @@ jobs:
188194
make yasl
189195
make yaslapi
190196
make tests
197+
make test_module
191198
displayName: "Compile"
192199
- script:
193200
./tests
@@ -198,7 +205,7 @@ jobs:
198205
- job:
199206
displayName: "C Clang MacOS"
200207
pool:
201-
vmImage: 'macOS-11'
208+
vmImage: 'macOS-12'
202209
steps:
203210
- script: |
204211
set -e
@@ -208,6 +215,7 @@ jobs:
208215
make yasl
209216
make yaslapi
210217
make tests
218+
make test_module
211219
displayName: "Compile"
212220
- script:
213221
./tests
@@ -218,7 +226,7 @@ jobs:
218226
- job:
219227
displayName: "C++ Clang MacOS"
220228
pool:
221-
vmImage: 'macOS-11'
229+
vmImage: 'macOS-12'
222230
steps:
223231
- script: |
224232
set -e
@@ -229,6 +237,7 @@ jobs:
229237
make yasl
230238
make yaslapi
231239
make tests
240+
make test_module
232241
displayName: "Compile"
233242
- script:
234243
./tests

configure_tests.sh

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,13 @@ for f in $(find test/inputs -name '*.yasl'); do
44
done;
55
echo '};' >> test/inputs.inl
66

7+
echo 'static const char *try_fail_errors[] = {' > test/try_fail_errors.inl
8+
for f in $(find test/try_fail_errors -name '*.yasl'); do
9+
echo " \"$f\"," >> test/try_fail_errors.inl;
10+
done;
11+
echo '};' >> test/try_fail_errors.inl
12+
13+
714
shopt -s globstar nullglob dotglob;
815

916
make_array () {
@@ -16,7 +23,6 @@ make_array () {
1623
}
1724

1825
make_array divisionbyzero;
19-
make_array error;
2026
make_array assert;
2127
make_array value;
2228
make_array stackoverflow;

install.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,6 @@ if [[ ! -d /usr/local/include/yasl ]]; then
1818
fi
1919

2020
# Copy the files to the appropriate locations
21-
cp yasl.h yasl_error.h yasl_aux.h yasl_conf.h /usr/local/include/yasl/
21+
cp src/yasl.h src/yasl_error.h src/yasl_aux.h src/yasl_conf.h /usr/local/include/yasl/
2222
cp libyaslapi.a /usr/local/lib/
2323
cp yasl /usr/local/bin/

src/common/README.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
This directory covers all YASL-specific code that is used in both //compiler and //interpreter.

0 commit comments

Comments
 (0)