Shi
Loading...
Searching...
No Matches
shi.hpp
Go to the documentation of this file.
1
6
7#pragma once
8
9// clang-format off
11#define SHI_STACK_SIZE 256
12
14#define SHI_ERASED_WORD 0xFFFFFFFF
15
17#define SHI_ENABLE_NUMBER_PREFIX 1
18
20#define SHI_ENABLE_PRINT 1
21
23#define SHI_ENABLE_REDEFINITION 0
24
25// Enable words individually
26// Core words
27#define SHI_ENABLE_STORE 1
28#define SHI_ENABLE_TICK 1
29#define SHI_ENABLE_TIMES 1
30#define SHI_ENABLE_TIMES_DIV 1
31#define SHI_ENABLE_TIMES_DIV_MOD 1
32#define SHI_ENABLE_PLUS 1
33#define SHI_ENABLE_PLUS_STORE 1
34#define SHI_ENABLE_PLUS_LOOP 1
35#define SHI_ENABLE_COMMA 1
36#define SHI_ENABLE_MINUS 1
37#define SHI_ENABLE_DIV 1
38#define SHI_ENABLE_DIV_MOD 1
39#define SHI_ENABLE_ZERO_LESS 1
40#define SHI_ENABLE_ZERO_EQUAL 1
41#define SHI_ENABLE_ONE_PLUS 1
42#define SHI_ENABLE_ONE_MINUS 1
43#define SHI_ENABLE_TWO_STORE 1
44#define SHI_ENABLE_TWO_TIMES 1
45#define SHI_ENABLE_TWO_DIV 1
46#define SHI_ENABLE_TWO_FETCH 1
47#define SHI_ENABLE_TWO_DROP 1
48#define SHI_ENABLE_TWO_DUP 1
49#define SHI_ENABLE_TWO_OVER 1
50#define SHI_ENABLE_TWO_SWAP 1
51#define SHI_ENABLE_COLON 1
52#define SHI_ENABLE_SEMI 1
53#define SHI_ENABLE_LESS 1
54#define SHI_ENABLE_EQUAL 1
55#define SHI_ENABLE_MORE 1
56#define SHI_ENABLE_TO_BODY 1
57#define SHI_ENABLE_TO_IN 1
58#define SHI_ENABLE_TO_R 1
59#define SHI_ENABLE_Q_DUP 1
60#define SHI_ENABLE_FETCH 1
61#define SHI_ENABLE_ABS 1
62#define SHI_ENABLE_ALIGN 1
63#define SHI_ENABLE_ALIGNED 1
64#define SHI_ENABLE_ALLOT 1
65#define SHI_ENABLE_AND 1
66#define SHI_ENABLE_BASE 1
67#define SHI_ENABLE_BEGIN 1
68#define SHI_ENABLE_C_STORE 1
69#define SHI_ENABLE_C_COMMA 1
70#define SHI_ENABLE_C_FETCH 1
71#define SHI_ENABLE_CELL_PLUS 1
72#define SHI_ENABLE_CELLS 1
73#define SHI_ENABLE_CHAR_PLUS 1
74#define SHI_ENABLE_CHARS 1
75#define SHI_ENABLE_CONSTANT 1
76#define SHI_ENABLE_CREATE 1
77#define SHI_ENABLE_DECIMAL 1
78#define SHI_ENABLE_DEPTH 1
79#define SHI_ENABLE_DO 1
80#define SHI_ENABLE_DOES 1
81#define SHI_ENABLE_DROP 1
82#define SHI_ENABLE_DUP 1
83#define SHI_ENABLE_ELSE 1
84#define SHI_ENABLE_EXECUTE 1
85#define SHI_ENABLE_EXIT 1
86#define SHI_ENABLE_FILL 1
87#define SHI_ENABLE_FIND 1
88#define SHI_ENABLE_FM_DIV_MOD 1
89#define SHI_ENABLE_HERE 1
90#define SHI_ENABLE_I 1
91#define SHI_ENABLE_IF 1
92#define SHI_ENABLE_IMMEDIATE 1
93#define SHI_ENABLE_INVERT 1
94#define SHI_ENABLE_J 1
95#define SHI_ENABLE_LEAVE 1
96#define SHI_ENABLE_LITERAL 1
97#define SHI_ENABLE_LOOP 1
98#define SHI_ENABLE_LSHIFT 1
99#define SHI_ENABLE_M_TIMES 1
100#define SHI_ENABLE_MAX 1
101#define SHI_ENABLE_MIN 1
102#define SHI_ENABLE_MOD 1
103#define SHI_ENABLE_MOVE 1
104#define SHI_ENABLE_NEGATE 1
105#define SHI_ENABLE_OR 1
106#define SHI_ENABLE_OVER 1
107#define SHI_ENABLE_POSTPONE 1
108#define SHI_ENABLE_R_FROM 1
109#define SHI_ENABLE_R_FETCH 1
110#define SHI_ENABLE_RECURSE 1
111#define SHI_ENABLE_REPEAT 1
112#define SHI_ENABLE_ROT 1
113#define SHI_ENABLE_RSHIFT 1
114#define SHI_ENABLE_S_TO_D 1
115#define SHI_ENABLE_SIGN 1
116#define SHI_ENABLE_SM_DIV_REM 1
117#define SHI_ENABLE_SOURCE 1
118#define SHI_ENABLE_STATE 1
119#define SHI_ENABLE_SWAP 1
120#define SHI_ENABLE_THEN 1
121#define SHI_ENABLE_U_LESS 1
122#define SHI_ENABLE_UM_TIMES 1
123#define SHI_ENABLE_UM_DIV_MOD 1
124#define SHI_ENABLE_UNLOOP 1
125#define SHI_ENABLE_UNTIL 1
126#define SHI_ENABLE_VARIABLE 1
127#define SHI_ENABLE_WHILE 1
128#define SHI_ENABLE_XOR 1
129#define SHI_ENABLE_BRACKET_LEFT 1
130#define SHI_ENABLE_BRACKET_TICK 1
131#define SHI_ENABLE_BRACKET_RIGHT 1
132#define SHI_ENABLE_ZERO_NE 1
133#define SHI_ENABLE_ZERO_MORE 1
134#define SHI_ENABLE_TWO_TO_R 1
135#define SHI_ENABLE_TWO_R_FROM 1
136#define SHI_ENABLE_TWO_R_FETCH 1
137#define SHI_ENABLE_NE 1
138#define SHI_ENABLE_Q_DO 1
139#define SHI_ENABLE_ACTION_OF 1
140#define SHI_ENABLE_AGAIN 1
141#define SHI_ENABLE_BUFFER_COLON 1
142#define SHI_ENABLE_CASE 1
143#define SHI_ENABLE_COMPILE_COMMA 1
144#define SHI_ENABLE_ENDCASE 1
145#define SHI_ENABLE_ENDOF 1
146#define SHI_ENABLE_ERASE 1
147#define SHI_ENABLE_FALSE 1
148#define SHI_ENABLE_HEX 1
149#define SHI_ENABLE_NIP 1
150#define SHI_ENABLE_OF 1
151#define SHI_ENABLE_PARSE_NAME 1
152#define SHI_ENABLE_PICK 1
153#define SHI_ENABLE_ROLL 1
154#define SHI_ENABLE_TRUE 1
155#define SHI_ENABLE_TUCK 1
156#define SHI_ENABLE_U_MORE 1
157#define SHI_ENABLE_UNUSED 1
158#define SHI_ENABLE_VALUE 1
159#define SHI_ENABLE_WITHIN 1
160
161// Shi words
162#define SHI_ENABLE_H_STORE 1
163#define SHI_ENABLE_H_FETCH 1
164#define SHI_ENABLE_INLINE 1
165#define SHI_ENABLE_TO_TEXT_Q 1
166#define SHI_ENABLE_TO_DATA_Q 1
167#define SHI_ENABLE_TO_TEXT 1
168#define SHI_ENABLE_TO_DATA 1
169// clang-format on
170
171// C/C++
172
173# include <stddef.h>
174# include <stdint.h>
175# include <string.h>
176
177extern "C" {
178
179typedef void (*void_fp)();
180extern uint32_t shi_context;
181
182void shi_evaluate_asm(char const* str, size_t len);
183void shi_variable_asm(char const* name, size_t len);
185void_fp shi_tick_asm(char const* str, size_t len);
186
187}
188
189// C only
190
194static inline void shi_push_number(int32_t t) {
195 asm volatile("ldr r0, [%0] \n"
196 "str %1, [r0, #-4]! \n"
197 "str r0, [%0] \n"
198 :
199 : "r"(&shi_context), "r"(t)
200 : "memory", "r0");
201}
202
206static inline void shi_push_double(int64_t t) {
207 asm volatile("ldr r0, [%0] \n"
208 "ldrd r1, r2, [%1] \n"
209 "strd r2, r1, [r0, #-8]! \n"
210 "str r0, [%0] \n"
211 :
212 : "r"(&shi_context), "r"(&t)
213 : "memory", "r0", "r1", "r2");
214}
215
220static inline void shi_push_struct(void* t, size_t n) {
221 asm volatile("ldr r0, [%0] \n"
222
223 // Insert padding if size isn't multiple of 4
224 "mov r1, #0 \n"
225 "str r1, [r0, #-4] \n"
226 "and r1, %2, #3 \n"
227 "sub r0, r0, r1 \n"
228
229 // Do not change input operands
230 "sub r1, r0, %2 \n"
231 "add r2, %1, %2 \n"
232
233 "1: cmp r0, r1 \n"
234 "beq 1f \n"
235 "ldrb r3, [r2, #-1]! \n"
236 "strb r3, [r0, #-1]! \n"
237 "b 1b \n"
238
239 "1: str r0, [%0] \n"
240 :
241 : "r"(&shi_context), "r"(t), "r"(n)
242 : "cc", "memory", "r0", "r1", "r2", "r3");
243}
244
248static inline int32_t shi_pop_number() {
249 int32_t t;
250
251 asm volatile("ldr r0, [%1] \n"
252 "ldr %0, [r0], #4 \n"
253 "str r0, [%1] \n"
254 : "=&r"(t)
255 : "r"(&shi_context)
256 : "memory", "r0");
257
258 return t;
259}
260
264static inline int64_t shi_pop_double() {
265 int64_t t;
266
267 asm volatile("ldr r0, [%0] \n"
268 "ldrd r1, r2, [r0], #8 \n"
269 "strd r2, r1, [%1] \n"
270 "str r0, [%0] \n"
271 :
272 : "r"(&shi_context), "r"(&t)
273 : "memory", "r0", "r1", "r2");
274
275 return t;
276}
277
282static inline void shi_pop_struct(void* t, size_t n) {
283 asm volatile("ldr r0, [%0] \n"
284
285 // Do not change input operands
286 "adds r1, r0, %2 \n"
287 "movs r2, %1 \n"
288
289 "1: cmp r0, r1 \n"
290 "beq 1f \n"
291 "ldrb r3, [r0], #1 \n"
292 "strb r3, [r2], #1 \n"
293 "b 1b \n"
294
295 // Align
296 "1: add r0, r0, #3 \n"
297 "bic r0, r0, #3 \n"
298 "str r0, [%0] \n"
299 :
300 : "r"(&shi_context), "r"(t), "r"(n)
301 : "cc", "memory", "r0", "r1", "r2", "r3");
302}
303
308static inline int32_t shi_top_number(size_t offset) {
309 int32_t t;
310
311 asm volatile("ldr r0, [%1] \n"
312 "ldr %0, [r0, %2, lsl #2] \n"
313 : "=r"(t)
314 : "r"(&shi_context), "r"(offset)
315 : "memory", "r0");
316
317 return t;
318}
319
324static inline int64_t shi_top_double(size_t offset) {
325 int64_t t;
326
327 asm volatile("ldr r0, [%0] \n"
328 "add r0, r0, %2, lsl #2 \n"
329 "ldrd r1, r2, [r0] \n"
330 "strd r2, r1, [%1] \n"
331 :
332 : "r"(&shi_context), "r"(&t), "r"(offset)
333 : "memory", "r0", "r1", "r2");
334
335 return t;
336}
337
342static inline void shi_top_struct(void** t, size_t offset) {
343 asm volatile("ldr r0, [%1] \n"
344 "add %0, r0, %2, lsl #2 \n"
345 : "=r"(*t)
346 : "r"(&shi_context), "r"(offset)
347 : "memory", "r0");
348}
349
353static inline size_t shi_depth() {
354 size_t size;
355
356 asm volatile("ldr r0, [%1] \n"
357 "sub %0, %1, r0 \n"
358 "lsr %0, %0, #2 \n"
359 "sub %0, #1 \n"
360 : "=r"(size)
361 : "r"(&shi_context)
362 : "memory", "r0");
363
364 return size;
365}
366
370static inline size_t shi_size() {
371 return shi_depth();
372}
373
375typedef struct {
376 uint32_t data_begin;
377 uint32_t data_end;
378 uint32_t text_begin;
379 uint32_t text_end;
381} Shi_init;
382
384
388static inline void shi_init(Shi_init s) {
389 shi_init_asm(&s);
390}
391
395static inline void shi_evaluate(char const* str) {
396 shi_evaluate_asm(str, strlen(str));
397}
398
403static inline void shi_evaluate_len(char const* str, size_t len) {
404 shi_evaluate_asm(str, len);
405}
406
411static inline void shi_variable(void* adr, char const* str) {
412 shi_push_number((int32_t)(adr));
413 shi_variable_asm(str, strlen(str));
414}
415
421static inline void shi_variable_len(void* adr, char const* str, size_t len) {
422 shi_push_number((int32_t)(adr));
423 shi_variable_asm(str, len);
424}
425
427static inline void shi_clear() {
429}
430
432typedef struct {
434} Word;
435
440static inline Word shi_tick(char const* str) {
441 Word w = {shi_tick_asm(str, strlen(str))};
442 return w;
443}
444
450static inline Word shi_tick_len(char const* str, size_t len) {
451 Word w = {shi_tick_asm(str, len)};
452 return w;
453}
454
458static inline void shi_word(Word w) {
459 if (w.fp)
460 asm volatile("ldrd r7, r8, [%0] \n"
461 "ldr r6, [r7], #4 \n"
462 "push {%0} \n"
463 "blx %1 \n"
464 "pop {%0} \n"
465 "str r6, [r7, #-4]! \n"
466 "strd r7, r8, [%0] \n"
467 :
468 : "r"(&shi_context), "r"(w.fp)
469 : "cc", "memory", "r6", "r7", "r8", "lr");
470}
471
472// C++ only
473
474# include <tuple>
475# include <type_traits>
476# include <functional>
477
478namespace shi {
479
480// Shouldn't this be part of C++20?
481template<typename T>
483 using type = std::remove_cv_t<std::remove_reference_t<T>>;
484};
485
486template<typename T>
488
489template<typename T>
490struct is_reference_wrapper : std::false_type {};
491
492template<typename U>
493struct is_reference_wrapper<std::reference_wrapper<U>> : std::true_type {};
494
495template<typename T>
497
501inline size_t depth() {
502 size_t size;
503
504 asm volatile("ldr r0, [%1] \n"
505 "sub %0, %1, r0 \n"
506 "lsr %0, %0, #2 \n"
507 "sub %0, #1 \n"
508 : "=r"(size)
509 : "r"(&shi_context)
510 : "memory", "r0");
511
512 return size;
513}
514
518inline size_t size() {
519 return depth();
520}
521
526template<typename T>
527void push(T&& t) {
528 using std::addressof, std::is_arithmetic_v, std::is_pointer_v;
529 using V = remove_cvref_t<T>;
530
531 if constexpr (sizeof(V) <= 4 && (is_arithmetic_v<V> || is_pointer_v<V> ||
533 asm volatile("ldr r0, [%0] \n"
534 "str %1, [r0, #-4]! \n"
535 "str r0, [%0] \n"
536 :
537 : "r"(&shi_context), "r"(t)
538 : "memory", "r0");
539 else if constexpr (sizeof(V) == 8 && is_arithmetic_v<V>)
540 asm volatile("ldr r0, [%0] \n"
541 "ldrd r1, r2, [%1] \n"
542 "strd r2, r1, [r0, #-8]! \n"
543 "str r0, [%0] \n"
544 :
545 : "r"(&shi_context), "r"(addressof(t))
546 : "memory", "r0", "r1", "r2");
547 else {
548 static_assert(sizeof(V) <= SHI_STACK_SIZE);
549 asm volatile("ldr r0, [%0] \n"
550
551 // Insert padding if size isn't multiple of 4
552 "mov r1, #0 \n"
553 "str r1, [r0, #-4] \n"
554 "and r1, %2, #3 \n"
555 "sub r0, r0, r1 \n"
556
557 // Do not change input operands
558 "sub r1, r0, %2 \n"
559 "add r2, %1, %2 \n"
560
561 "1: cmp r0, r1 \n"
562 "beq 1f \n"
563 "ldrb r3, [r2, #-1]! \n"
564 "strb r3, [r0, #-1]! \n"
565 "b 1b \n"
566
567 "1: str r0, [%0] \n"
568 :
569 : "r"(&shi_context), "r"(addressof(t)), "r"(sizeof(V))
570 : "cc", "memory", "r0", "r1", "r2", "r3");
571 }
572}
573
578template<typename... Ts>
579void push(Ts&&... ts) {
580 using std::forward;
581
582 static_assert((0 + ... + sizeof(remove_cvref_t<Ts>)) <= SHI_STACK_SIZE);
583
584 (push(forward<Ts>(ts)), ...);
585}
586
591template<typename T = int32_t>
592T pop() {
593 using std::addressof, std::is_arithmetic_v, std::is_pointer_v;
594
595 T t;
596
597 if constexpr (sizeof(T) <= 4 && (is_arithmetic_v<T> || is_pointer_v<T> ||
599 asm volatile("ldr r0, [%1] \n"
600 "ldr %0, [r0], #4 \n"
601 "str r0, [%1] \n"
602 : "=&r"(t)
603 : "r"(&shi_context)
604 : "memory", "r0");
605 else if constexpr (sizeof(T) == 8 && is_arithmetic_v<T>)
606 asm volatile("ldr r0, [%0] \n"
607 "ldrd r1, r2, [r0], #8 \n"
608 "strd r2, r1, [%1] \n"
609 "str r0, [%0] \n"
610 :
611 : "r"(&shi_context), "r"(addressof(t))
612 : "memory", "r0", "r1", "r2");
613 else {
614 static_assert(sizeof(T) <= SHI_STACK_SIZE);
615 asm volatile("ldr r0, [%0] \n"
616
617 // Do not change input operands
618 "adds r1, r0, %2 \n"
619 "movs r2, %1 \n"
620
621 "1: cmp r0, r1 \n"
622 "beq 1f \n"
623 "ldrb r3, [r0], #1 \n"
624 "strb r3, [r2], #1 \n"
625 "b 1b \n"
626
627 // Align
628 "1: add r0, r0, #3 \n"
629 "bic r0, r0, #3 \n"
630 "str r0, [%0] \n"
631 :
632 : "r"(&shi_context), "r"(addressof(t)), "r"(sizeof(T))
633 : "cc", "memory", "r0", "r1", "r2", "r3");
634 }
635
636 return t;
637}
638
643template<typename... Ts, typename = std::enable_if_t<(sizeof...(Ts) > 1)>>
644std::tuple<Ts...> pop() {
645 using std::tuple;
646
647 static_assert((0 + ... + sizeof(Ts)) <= SHI_STACK_SIZE);
648
649 return tuple<Ts...>{pop<Ts>()...};
650}
651
658template<typename T = int32_t>
659decltype(auto) top(size_t offset = 0) {
660 using std::add_lvalue_reference_t, std::addressof, std::is_arithmetic_v,
661 std::is_pointer_v;
662
663 if constexpr (sizeof(T) <= 4 && (is_arithmetic_v<T> || is_pointer_v<T> ||
665 T t;
666 asm volatile("ldr r0, [%1] \n"
667 "ldr %0, [r0, %2, lsl #2] \n"
668 : "=r"(t)
669 : "r"(&shi_context), "r"(offset)
670 : "memory", "r0");
671 return t;
672 } else if constexpr (sizeof(T) == 8 && is_arithmetic_v<T>) {
673 T t;
674 asm volatile("ldr r0, [%0] \n"
675 "add r0, r0, %2, lsl #2 \n"
676 "ldrd r1, r2, [r0] \n"
677 "strd r2, r1, [%1] \n"
678 :
679 : "r"(&shi_context), "r"(addressof(t)), "r"(offset)
680 : "memory", "r0", "r1", "r2");
681 return t;
682 } else {
683 static_assert(sizeof(T) <= SHI_STACK_SIZE);
684 T* t;
685 asm volatile("ldr r0, [%1] \n"
686 "add %0, r0, %2, lsl #2 \n"
687 : "=r"(t)
688 : "r"(&shi_context), "r"(offset)
689 : "memory", "r0");
690 return add_lvalue_reference_t<T>(*t);
691 }
692}
693
695struct Init {
696 uint32_t data_begin{};
697 uint32_t data_end{};
698 uint32_t text_begin{};
699 uint32_t text_end{};
700 uint8_t text_p2align{2};
701};
702
703extern "C" void shi_init_asm(Init&);
704
708inline void init(Init s) {
709 shi_init_asm(s);
710}
711
715inline void evaluate(char const* str) {
716 shi_evaluate_asm(str, strlen(str));
717}
718
723inline void evaluate(char const* str, size_t len) {
724 shi_evaluate_asm(str, len);
725}
726
732template<typename T>
733void variable(T adr, char const* str) {
734 using std::is_pointer_v;
735
736 static_assert(sizeof(T) == 4 &&
737 (is_pointer_v<T> || is_reference_wrapper_v<T>));
738
739 push(adr);
740 shi_variable_asm(str, strlen(str));
741}
742
749template<typename T>
750void variable(T adr, char const* str, size_t len) {
751 using std::is_pointer_v;
752
753 static_assert(sizeof(T) == 4 &&
754 (is_pointer_v<T> || is_reference_wrapper_v<T>));
755
756 push(adr);
757 shi_variable_asm(str, len);
758}
759
761inline void clear() {
763}
764
769inline void_fp tick(char const* str) {
770 return shi_tick_asm(str, strlen(str));
771}
772
778inline void_fp tick(char const* str, size_t len) {
779 return shi_tick_asm(str, len);
780}
781
783struct Word {
784 constexpr Word() = default;
785 Word(char const* str) : fp{shi_tick_asm(str, strlen(str))} {}
786 Word(char const* str, size_t len) : fp{shi_tick_asm(str, len)} {}
788
793 template<typename... Ts>
794 Word& operator()(Ts&&... ts) {
795 using std::forward;
796
797 if (fp) {
798 push(forward<Ts>(ts)...);
799
800 asm volatile("ldrd r7, r8, [%0] \n"
801 "ldr r6, [r7], #4 \n"
802 "push {%0} \n"
803 "blx %1 \n"
804 "pop {%0} \n"
805 "str r6, [r7, #-4]! \n"
806 "strd r7, r8, [%0] \n"
807 :
808 : "r"(&shi_context), "r"(fp)
809 : "cc", "memory", "r6", "r7", "r8", "lr");
810 }
811
812 return *this;
813 }
814
816 template<typename T>
817 operator T() {
818 return pop<T>();
819 }
820
822 template<typename... Ts>
823 operator std::tuple<Ts...>() {
824 return pop<Ts...>();
825 }
826
827private:
828 void_fp fp{nullptr};
829};
830
831namespace literals {
832
837inline void operator"" _s(char const* str, size_t len) {
838 shi_evaluate_asm(str, len);
839}
840
846inline auto operator""_v(char const* str, size_t len) {
847 return [=](auto adr) {
848 using std::is_pointer_v;
849
850 static_assert(sizeof(adr) == 4 && (is_pointer_v<decltype(adr)> ||
851 is_reference_wrapper_v<decltype(adr)>));
852
853 push(adr);
854 shi_variable_asm(str, len);
855 };
856}
857
863template<typename T, T... Cs>
864Word operator""_w() {
865 static constexpr char c[]{Cs...};
866 static Word word{c, sizeof...(Cs)};
867 return word;
868}
869
870} // namespace literals
871
872} // namespace shi
873
874
Definition shi.hpp:478
void evaluate(char const *str)
Definition shi.hpp:715
decltype(auto) top(size_t offset=0)
Definition shi.hpp:659
typename remove_cvref< T >::type remove_cvref_t
Definition shi.hpp:487
size_t depth()
Definition shi.hpp:501
constexpr bool is_reference_wrapper_v
Definition shi.hpp:496
void variable(T adr, char const *str)
Definition shi.hpp:733
void init(Init s)
Definition shi.hpp:708
size_t size()
Definition shi.hpp:518
void shi_init_asm(Init &)
void push(T &&t)
Definition shi.hpp:527
void clear()
Clear stack.
Definition shi.hpp:761
T pop()
Definition shi.hpp:592
void_fp tick(char const *str)
Definition shi.hpp:769
void_fp shi_tick_asm(char const *str, size_t len)
static void shi_top_struct(void **t, size_t offset)
Definition shi.hpp:342
static void shi_push_double(int64_t t)
Definition shi.hpp:206
static void shi_evaluate(char const *str)
Definition shi.hpp:395
static size_t shi_depth()
Definition shi.hpp:353
void shi_variable_asm(char const *name, size_t len)
void shi_clear_asm()
void(* void_fp)()
Definition shi.hpp:179
static void shi_pop_struct(void *t, size_t n)
Definition shi.hpp:282
#define SHI_STACK_SIZE
Data-stack size (must be a multiple of 4 bytes)
Definition shi.hpp:11
static void shi_init(Shi_init s)
Definition shi.hpp:388
static size_t shi_size()
Definition shi.hpp:370
void shi_evaluate_asm(char const *str, size_t len)
void shi_init_asm(Shi_init *)
static void shi_word(Word w)
Definition shi.hpp:458
uint32_t shi_context
static void shi_evaluate_len(char const *str, size_t len)
Definition shi.hpp:403
static void shi_clear()
Clear stack.
Definition shi.hpp:427
static void shi_variable_len(void *adr, char const *str, size_t len)
Definition shi.hpp:421
static Word shi_tick(char const *str)
Definition shi.hpp:440
static int64_t shi_top_double(size_t offset)
Definition shi.hpp:324
static void shi_push_number(int32_t t)
Definition shi.hpp:194
static void shi_variable(void *adr, char const *str)
Definition shi.hpp:411
static int64_t shi_pop_double()
Definition shi.hpp:264
static Word shi_tick_len(char const *str, size_t len)
Definition shi.hpp:450
static void shi_push_struct(void *t, size_t n)
Definition shi.hpp:220
static int32_t shi_top_number(size_t offset)
Definition shi.hpp:308
static int32_t shi_pop_number()
Definition shi.hpp:248
Init struct.
Definition shi.hpp:375
uint32_t data_end
Definition shi.hpp:377
uint32_t text_begin
Definition shi.hpp:378
uint32_t text_end
Definition shi.hpp:379
uint8_t text_p2align
Definition shi.hpp:380
uint32_t data_begin
Definition shi.hpp:376
Word.
Definition shi.hpp:432
void_fp fp
Definition shi.hpp:433
Init struct.
Definition shi.hpp:695
uint32_t text_end
Definition shi.hpp:699
uint32_t text_begin
Definition shi.hpp:698
uint32_t data_end
Definition shi.hpp:697
uint32_t data_begin
Definition shi.hpp:696
uint8_t text_p2align
Definition shi.hpp:700
Word.
Definition shi.hpp:783
Word & operator()(Ts &&... ts)
Definition shi.hpp:794
Word(char const *str, size_t len)
Definition shi.hpp:786
constexpr Word()=default
Word(char const *str)
Definition shi.hpp:785
void_fp fp
Definition shi.hpp:828
Word(void_fp fp)
Definition shi.hpp:787
Definition shi.hpp:490
Definition shi.hpp:482
std::remove_cv_t< std::remove_reference_t< T > > type
Definition shi.hpp:483