\doxysection{stack.\+h}
\hypertarget{stack_8h_source}{}\label{stack_8h_source}\index{workspace/post-\/scarcity/src/memory/stack.h@{workspace/post-\/scarcity/src/memory/stack.h}}
\mbox{\hyperlink{stack_8h}{Go to the documentation of this file.}}
\begin{DoxyCode}{0}
\DoxyCodeLine{\Hypertarget{stack_8h_source_l00001}00001\ \textcolor{comment}{/**}}
\DoxyCodeLine{\Hypertarget{stack_8h_source_l00002}00002\ \textcolor{comment}{\ *\ stack.h}}
\DoxyCodeLine{\Hypertarget{stack_8h_source_l00003}00003\ \textcolor{comment}{\ *}}
\DoxyCodeLine{\Hypertarget{stack_8h_source_l00004}00004\ \textcolor{comment}{\ *\ The\ Lisp\ evaluation\ stack.}}
\DoxyCodeLine{\Hypertarget{stack_8h_source_l00005}00005\ \textcolor{comment}{\ *}}
\DoxyCodeLine{\Hypertarget{stack_8h_source_l00006}00006\ \textcolor{comment}{\ *\ Stack\ frames\ could\ be\ implemented\ in\ cons\ space;\ indeed,\ the\ stack}}
\DoxyCodeLine{\Hypertarget{stack_8h_source_l00007}00007\ \textcolor{comment}{\ *\ could\ simply\ be\ an\ assoc\ list\ consed\ onto\ the\ front\ of\ the\ environment.}}
\DoxyCodeLine{\Hypertarget{stack_8h_source_l00008}00008\ \textcolor{comment}{\ *\ But\ such\ a\ stack\ would\ be\ costly\ to\ search.\ The\ design\ sketched\ here,}}
\DoxyCodeLine{\Hypertarget{stack_8h_source_l00009}00009\ \textcolor{comment}{\ *\ with\ stack\ frames\ as\ special\ objects,\ SHOULD\ be\ substantially\ more}}
\DoxyCodeLine{\Hypertarget{stack_8h_source_l00010}00010\ \textcolor{comment}{\ *\ efficient,\ but\ does\ imply\ we\ need\ to\ generalise\ the\ idea\ of\ cons\ pages}}
\DoxyCodeLine{\Hypertarget{stack_8h_source_l00011}00011\ \textcolor{comment}{\ *\ with\ freelists\ to\ a\ more\ general\ 'equal\ sized\ object\ pages',\ so\ that}}
\DoxyCodeLine{\Hypertarget{stack_8h_source_l00012}00012\ \textcolor{comment}{\ *\ allocating/freeing\ stack\ frames\ can\ be\ more\ efficient.}}
\DoxyCodeLine{\Hypertarget{stack_8h_source_l00013}00013\ \textcolor{comment}{\ *}}
\DoxyCodeLine{\Hypertarget{stack_8h_source_l00014}00014\ \textcolor{comment}{\ *\ Stack\ frames\ are\ not\ yet\ a\ first\ class\ object;\ they\ have\ no\ VECP\ pointer}}
\DoxyCodeLine{\Hypertarget{stack_8h_source_l00015}00015\ \textcolor{comment}{\ *\ in\ cons\ space.}}
\DoxyCodeLine{\Hypertarget{stack_8h_source_l00016}00016\ \textcolor{comment}{\ *}}
\DoxyCodeLine{\Hypertarget{stack_8h_source_l00017}00017\ \textcolor{comment}{\ *\ (c)\ 2017\ Simon\ Brooke\ <simon@journeyman.cc>}}
\DoxyCodeLine{\Hypertarget{stack_8h_source_l00018}00018\ \textcolor{comment}{\ *\ Licensed\ under\ GPL\ version\ 2.0,\ or,\ at\ your\ option,\ any\ later\ version.}}
\DoxyCodeLine{\Hypertarget{stack_8h_source_l00019}00019\ \textcolor{comment}{\ */}}
\DoxyCodeLine{\Hypertarget{stack_8h_source_l00020}00020\ }
\DoxyCodeLine{\Hypertarget{stack_8h_source_l00021}00021\ \textcolor{preprocessor}{\#ifndef\ \_\_psse\_stack\_h}}
\DoxyCodeLine{\Hypertarget{stack_8h_source_l00022}00022\ \textcolor{preprocessor}{\#define\ \_\_psse\_stack\_h}}
\DoxyCodeLine{\Hypertarget{stack_8h_source_l00023}00023\ }
\DoxyCodeLine{\Hypertarget{stack_8h_source_l00024}00024\ \textcolor{preprocessor}{\#include\ "{}\mbox{\hyperlink{consspaceobject_8h}{consspaceobject.h}}"{}}}
\DoxyCodeLine{\Hypertarget{stack_8h_source_l00025}00025\ \textcolor{preprocessor}{\#include\ "{}\mbox{\hyperlink{conspage_8h}{conspage.h}}"{}}}
\DoxyCodeLine{\Hypertarget{stack_8h_source_l00026}00026\ \textcolor{comment}{}}
\DoxyCodeLine{\Hypertarget{stack_8h_source_l00027}00027\ \textcolor{comment}{/**}}
\DoxyCodeLine{\Hypertarget{stack_8h_source_l00028}00028\ \textcolor{comment}{\ *\ macros\ for\ the\ tag\ of\ a\ stack\ frame.}}
\DoxyCodeLine{\Hypertarget{stack_8h_source_l00029}00029\ \textcolor{comment}{\ */}}
\DoxyCodeLine{\Hypertarget{stack_8h_source_l00030}\mbox{\hyperlink{stack_8h_ac3b2f9185aba165e4c772aae48eecfa1}{00030}}\ \textcolor{preprocessor}{\#define\ STACKFRAMETAG\ "{}STAK"{}}}
\DoxyCodeLine{\Hypertarget{stack_8h_source_l00031}\mbox{\hyperlink{stack_8h_a4ee879be4822abe5825ec13126557e40}{00031}}\ \textcolor{preprocessor}{\#define\ STACKFRAMETV\ 1262572627}}
\DoxyCodeLine{\Hypertarget{stack_8h_source_l00032}00032\ \textcolor{comment}{}}
\DoxyCodeLine{\Hypertarget{stack_8h_source_l00033}00033\ \textcolor{comment}{/**}}
\DoxyCodeLine{\Hypertarget{stack_8h_source_l00034}00034\ \textcolor{comment}{\ *\ is\ this\ vector-\/space\ object\ a\ stack\ frame?}}
\DoxyCodeLine{\Hypertarget{stack_8h_source_l00035}00035\ \textcolor{comment}{\ */}}
\DoxyCodeLine{\Hypertarget{stack_8h_source_l00036}\mbox{\hyperlink{stack_8h_a18f65e8c5f1e28111a9a7f2e8a6f6ad5}{00036}}\ \textcolor{preprocessor}{\#define\ stackframep(vso)(((struct\ vector\_space\_object\ *)vso)-\/>header.tag.value\ ==\ STACKFRAMETV)}}
\DoxyCodeLine{\Hypertarget{stack_8h_source_l00037}00037\ }
\DoxyCodeLine{\Hypertarget{stack_8h_source_l00038}00038\ \textcolor{keywordtype}{void}\ \mbox{\hyperlink{stack_8h_a6f06ca39c92c6c67e589086d32d132a8}{set\_reg}}(\ \textcolor{keyword}{struct}\ \mbox{\hyperlink{consspaceobject_8h_structstack__frame}{stack\_frame}}\ *frame,\ \textcolor{keywordtype}{int}\ reg,\ \textcolor{keyword}{struct}\ \mbox{\hyperlink{consspaceobject_8h_structcons__pointer}{cons\_pointer}}\ value\ );}
\DoxyCodeLine{\Hypertarget{stack_8h_source_l00039}00039\ }
\DoxyCodeLine{\Hypertarget{stack_8h_source_l00040}00040\ \textcolor{keyword}{struct\ }\mbox{\hyperlink{consspaceobject_8h_structstack__frame}{stack\_frame}}\ *\mbox{\hyperlink{stack_8h_a81653b4495f0fd4e7e49b9bd99e8e8db}{get\_stack\_frame}}(\ \textcolor{keyword}{struct}\ \mbox{\hyperlink{consspaceobject_8h_structcons__pointer}{cons\_pointer}}\ pointer\ );}
\DoxyCodeLine{\Hypertarget{stack_8h_source_l00041}00041\ }
\DoxyCodeLine{\Hypertarget{stack_8h_source_l00042}00042\ \textcolor{keyword}{struct\ }\mbox{\hyperlink{consspaceobject_8h_structcons__pointer}{cons\_pointer}}\ \mbox{\hyperlink{stack_8h_ae97b7f0d449fa282f7a7c68c521dffd3}{make\_empty\_frame}}(\ struct\ \mbox{\hyperlink{consspaceobject_8h_structcons__pointer}{cons\_pointer}}\ previous\ );}
\DoxyCodeLine{\Hypertarget{stack_8h_source_l00043}00043\ }
\DoxyCodeLine{\Hypertarget{stack_8h_source_l00044}00044\ \textcolor{keyword}{struct\ }\mbox{\hyperlink{consspaceobject_8h_structcons__pointer}{cons\_pointer}}\ \mbox{\hyperlink{stack_8h_af448982b321038e7c24a5873b74533a7}{make\_stack\_frame}}(\ struct\ \mbox{\hyperlink{consspaceobject_8h_structcons__pointer}{cons\_pointer}}\ previous,}
\DoxyCodeLine{\Hypertarget{stack_8h_source_l00045}00045\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ struct\ \mbox{\hyperlink{consspaceobject_8h_structcons__pointer}{cons\_pointer}}\ args,}
\DoxyCodeLine{\Hypertarget{stack_8h_source_l00046}00046\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ struct\ \mbox{\hyperlink{consspaceobject_8h_structcons__pointer}{cons\_pointer}}\ env\ );}
\DoxyCodeLine{\Hypertarget{stack_8h_source_l00047}00047\ }
\DoxyCodeLine{\Hypertarget{stack_8h_source_l00048}00048\ \textcolor{keywordtype}{void}\ \mbox{\hyperlink{stack_8h_ad9c6f148f705d561caa12cd7d64d4016}{free\_stack\_frame}}(\ \textcolor{keyword}{struct}\ \mbox{\hyperlink{consspaceobject_8h_structstack__frame}{stack\_frame}}\ *frame\ );}
\DoxyCodeLine{\Hypertarget{stack_8h_source_l00049}00049\ }
\DoxyCodeLine{\Hypertarget{stack_8h_source_l00050}00050\ \textcolor{keywordtype}{void}\ \mbox{\hyperlink{stack_8h_a90f58a64fc05d37d72099ce6c5ead2f6}{dump\_frame}}(\ \mbox{\hyperlink{fopen_8h_structfcurl__data}{URL\_FILE}}\ *\ output,\ \textcolor{keyword}{struct}\ \mbox{\hyperlink{consspaceobject_8h_structcons__pointer}{cons\_pointer}}\ pointer\ );}
\DoxyCodeLine{\Hypertarget{stack_8h_source_l00051}00051\ }
\DoxyCodeLine{\Hypertarget{stack_8h_source_l00052}00052\ \textcolor{keywordtype}{void}\ \mbox{\hyperlink{stack_8h_acfae3bc46140ba920312eafa2a882d4b}{dump\_stack\_trace}}(\ \mbox{\hyperlink{fopen_8h_structfcurl__data}{URL\_FILE}}\ *\ output,\ \textcolor{keyword}{struct}\ \mbox{\hyperlink{consspaceobject_8h_structcons__pointer}{cons\_pointer}}\ frame\_pointer\ );}
\DoxyCodeLine{\Hypertarget{stack_8h_source_l00053}00053\ }
\DoxyCodeLine{\Hypertarget{stack_8h_source_l00054}00054\ \textcolor{keyword}{struct\ }\mbox{\hyperlink{consspaceobject_8h_structcons__pointer}{cons\_pointer}}\ \mbox{\hyperlink{stack_8h_a1045db640bff11aa4446faa2c8108544}{fetch\_arg}}(\ struct\ \mbox{\hyperlink{consspaceobject_8h_structstack__frame}{stack\_frame}}\ *frame,\ \textcolor{keywordtype}{unsigned}\ \textcolor{keywordtype}{int}\ n\ );}
\DoxyCodeLine{\Hypertarget{stack_8h_source_l00055}00055\ }
\DoxyCodeLine{\Hypertarget{stack_8h_source_l00056}00056\ \textcolor{keyword}{struct\ }\mbox{\hyperlink{consspaceobject_8h_structcons__pointer}{cons\_pointer}}\ \mbox{\hyperlink{stack_8h_a494ca1435350714304b05f67a9fe8ba9}{make\_special\_frame}}(\ struct\ \mbox{\hyperlink{consspaceobject_8h_structcons__pointer}{cons\_pointer}}\ previous,}
\DoxyCodeLine{\Hypertarget{stack_8h_source_l00057}00057\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ struct\ \mbox{\hyperlink{consspaceobject_8h_structcons__pointer}{cons\_pointer}}\ args,}
\DoxyCodeLine{\Hypertarget{stack_8h_source_l00058}00058\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ struct\ \mbox{\hyperlink{consspaceobject_8h_structcons__pointer}{cons\_pointer}}\ env\ );}
\DoxyCodeLine{\Hypertarget{stack_8h_source_l00059}00059\ }
\DoxyCodeLine{\Hypertarget{stack_8h_source_l00060}00060\ \textcolor{comment}{/*}}
\DoxyCodeLine{\Hypertarget{stack_8h_source_l00061}00061\ \textcolor{comment}{\ *\ struct\ stack\_frame\ is\ defined\ in\ consspaceobject.h\ to\ break\ circularity}}
\DoxyCodeLine{\Hypertarget{stack_8h_source_l00062}00062\ \textcolor{comment}{\ *\ \(\backslash\)todo\ refactor.}}
\DoxyCodeLine{\Hypertarget{stack_8h_source_l00063}00063\ \textcolor{comment}{\ */}}
\DoxyCodeLine{\Hypertarget{stack_8h_source_l00064}00064\ }
\DoxyCodeLine{\Hypertarget{stack_8h_source_l00065}00065\ \textcolor{preprocessor}{\#endif}}

\end{DoxyCode}
