archivesOfToyLang/tshunhue/docs/build/html/index.html

311 lines
No EOL
9.6 KiB
HTML
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<!DOCTYPE html>
<html class="writer-html5" lang="zh-tw" >
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Welcome to Tshunhue Documentss documentation! &mdash; Tshunhue Documents documentation</title>
<link rel="stylesheet" href="_static/css/theme.css" type="text/css" />
<link rel="stylesheet" href="_static/pygments.css" type="text/css" />
<!--[if lt IE 9]>
<script src="_static/js/html5shiv.min.js"></script>
<![endif]-->
<script type="text/javascript" id="documentation_options" data-url_root="./" src="_static/documentation_options.js"></script>
<script src="_static/jquery.js"></script>
<script src="_static/underscore.js"></script>
<script src="_static/doctools.js"></script>
<script src="_static/language_data.js"></script>
<script type="text/javascript" src="_static/js/theme.js"></script>
<link rel="index" title="Index" href="genindex.html" />
<link rel="search" title="Search" href="search.html" />
<link rel="next" title="基本函數介紹" href="%E5%9F%BA%E6%9C%AC%E5%87%BD%E6%95%B8%E4%BB%8B%E7%B4%B9.html" />
</head>
<body class="wy-body-for-nav">
<div class="wy-grid-for-nav">
<nav data-toggle="wy-nav-shift" class="wy-nav-side">
<div class="wy-side-scroll">
<div class="wy-side-nav-search" >
<a href="#" class="icon icon-home" alt="Documentation Home"> Tshunhue Documents
</a>
<div role="search">
<form id="rtd-search-form" class="wy-form" action="search.html" method="get">
<input type="text" name="q" placeholder="Search docs" />
<input type="hidden" name="check_keywords" value="yes" />
<input type="hidden" name="area" value="default" />
</form>
</div>
</div>
<div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation">
<p class="caption"><span class="caption-text">Contents</span></p>
<ul>
<li class="toctree-l1"><a class="reference internal" href="%E5%9F%BA%E6%9C%AC%E5%87%BD%E6%95%B8%E4%BB%8B%E7%B4%B9.html">基本函數介紹</a></li>
<li class="toctree-l1"><a class="reference internal" href="%E5%9E%8B%E5%88%A5.html">型別</a></li>
</ul>
</div>
</div>
</nav>
<section data-toggle="wy-nav-shift" class="wy-nav-content-wrap">
<nav class="wy-nav-top" aria-label="top navigation">
<i data-toggle="wy-nav-top" class="fa fa-bars"></i>
<a href="#">Tshunhue Documents</a>
</nav>
<div class="wy-nav-content">
<div class="rst-content">
<div role="navigation" aria-label="breadcrumbs navigation">
<ul class="wy-breadcrumbs">
<li><a href="#" class="icon icon-home"></a> &raquo;</li>
<li>Welcome to Tshunhue Documentss documentation!</li>
<li class="wy-breadcrumbs-aside">
<a href="_sources/index.rst.txt" rel="nofollow"> View page source</a>
</li>
</ul>
<hr/>
</div>
<div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article">
<div itemprop="articleBody">
<div class="section" id="welcome-to-tshunhue-documents-s-documentation">
<h1>Welcome to Tshunhue Documentss documentation!<a class="headerlink" href="#welcome-to-tshunhue-documents-s-documentation" title="Permalink to this headline"></a></h1>
<div class="toctree-wrapper compound">
<p class="caption"><span class="caption-text">Contents</span></p>
<ul>
<li class="toctree-l1"><a class="reference internal" href="%E5%9F%BA%E6%9C%AC%E5%87%BD%E6%95%B8%E4%BB%8B%E7%B4%B9.html">基本函數介紹</a><ul>
<li class="toctree-l2"><a class="reference internal" href="%E5%9F%BA%E6%9C%AC%E5%87%BD%E6%95%B8%E4%BB%8B%E7%B4%B9.html#id2">四則運算</a></li>
<li class="toctree-l2"><a class="reference internal" href="%E5%9F%BA%E6%9C%AC%E5%87%BD%E6%95%B8%E4%BB%8B%E7%B4%B9.html#id3">布爾值</a></li>
<li class="toctree-l2"><a class="reference internal" href="%E5%9F%BA%E6%9C%AC%E5%87%BD%E6%95%B8%E4%BB%8B%E7%B4%B9.html#id4">流程控制</a></li>
<li class="toctree-l2"><a class="reference internal" href="%E5%9F%BA%E6%9C%AC%E5%87%BD%E6%95%B8%E4%BB%8B%E7%B4%B9.html#id5">影印字元</a></li>
<li class="toctree-l2"><a class="reference internal" href="%E5%9F%BA%E6%9C%AC%E5%87%BD%E6%95%B8%E4%BB%8B%E7%B4%B9.html#id6">定義變數 (=)</a><ul>
<li class="toctree-l3"><a class="reference internal" href="%E5%9F%BA%E6%9C%AC%E5%87%BD%E6%95%B8%E4%BB%8B%E7%B4%B9.html#id7">非函數</a></li>
<li class="toctree-l3"><a class="reference internal" href="%E5%9F%BA%E6%9C%AC%E5%87%BD%E6%95%B8%E4%BB%8B%E7%B4%B9.html#id8">函數(閉包)</a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="%E5%9F%BA%E6%9C%AC%E5%87%BD%E6%95%B8%E4%BB%8B%E7%B4%B9.html#lambda-function">匿名函數 (lambda function)</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="%E5%9E%8B%E5%88%A5.html">型別</a><ul>
<li class="toctree-l2"><a class="reference internal" href="%E5%9E%8B%E5%88%A5.html#id2">簡單型別</a><ul>
<li class="toctree-l3"><a class="reference internal" href="%E5%9E%8B%E5%88%A5.html#id3">數字</a></li>
<li class="toctree-l3"><a class="reference internal" href="%E5%9E%8B%E5%88%A5.html#id4">字串</a></li>
<li class="toctree-l3"><a class="reference internal" href="%E5%9E%8B%E5%88%A5.html#id5">布林</a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="%E5%9E%8B%E5%88%A5.html#id6">複雜型別</a><ul>
<li class="toctree-l3"><a class="reference internal" href="%E5%9E%8B%E5%88%A5.html#id7">自訂型別</a></li>
</ul>
</li>
</ul>
</li>
</ul>
</div>
</div>
<div class="section" id="indices-and-tables">
<h1>Indices and tables<a class="headerlink" href="#indices-and-tables" title="Permalink to this headline"></a></h1>
<ul class="simple">
<li><p><a class="reference internal" href="genindex.html"><span class="std std-ref">Index</span></a></p></li>
<li><p><a class="reference internal" href="py-modindex.html"><span class="std std-ref">Module Index</span></a></p></li>
<li><p><a class="reference internal" href="search.html"><span class="std std-ref">Search Page</span></a></p></li>
</ul>
</div>
<div class="section" id="tshunhue">
<h1>Tshunhue 是什麼呢?<a class="headerlink" href="#tshunhue" title="Permalink to this headline"></a></h1>
<p>Tshunhue河洛語春花是一個 Lisp 系的玩具程式語言。主要的特徵有:</p>
<blockquote>
<div><ul class="simple">
<li><p>不可變物件。</p></li>
<li><p>閉包作為第一類物件。</p></li>
<li><p>靜態型別。</p></li>
<li><p>和型別 (Sum Type) 和積型別 (Product Type)。</p></li>
</ul>
</div></blockquote>
</div>
<div class="section" id="id1">
<h1>其他<a class="headerlink" href="#id1" title="Permalink to this headline"></a></h1>
<div class="section" id="id2">
<h2>垃圾回收<a class="headerlink" href="#id2" title="Permalink to this headline"></a></h2>
<p>先不實現垃圾回收。若是要實現垃圾回收,可以用引用記數。做一個這樣的表格:</p>
<table class="docutils align-default">
<colgroup>
<col style="width: 50%" />
<col style="width: 50%" />
</colgroup>
<tbody>
<tr class="row-odd"><td><p>記憶體位址</p></td>
<td><p>引用次數</p></td>
</tr>
<tr class="row-even"><td><p>0x12345</p>
<p>……</p>
</td>
<td><p>1</p>
<p>……</p>
</td>
</tr>
</tbody>
</table>
<p>以下有一個範例:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>(Type IntPair (IntPair Int Int))
(def IntPair a (IntPair x y))
; 這個時候我們可以呼叫引用計數增加函數 inc_ref_count()
; inc_ref_count(&amp;a);
; inc_ref_count(&amp;x);
; inc_ref_count(&amp;y);
...程式碼
; x 活著的程式碼區段結束時,呼叫引用記數減少函數 dec_ref_count()
; dec_ref_count(&amp;a);
; dec_ref_count(&amp;a[0]); // &amp;x
; dec_ref_count(&amp;a[1]); // &amp;y
</pre></div>
</div>
</div>
<div class="section" id="id3">
<h2>實做方式<a class="headerlink" href="#id3" title="Permalink to this headline"></a></h2>
<p>用 Python3 將原始碼轉成 AST以 s-expression 表示。再進行型別推測後,進行閉包轉換,不進行 CPS 變換,利用 llvmlite 生成 LLVM IR。</p>
<p>需要的東西:</p>
<ul class="simple">
<li><p>llvmlite</p></li>
<li><p>python3</p></li>
</ul>
</div>
</div>
</div>
</div>
<footer>
<div class="rst-footer-buttons" role="navigation" aria-label="footer navigation">
<a href="%E5%9F%BA%E6%9C%AC%E5%87%BD%E6%95%B8%E4%BB%8B%E7%B4%B9.html" class="btn btn-neutral float-right" title="基本函數介紹" accesskey="n" rel="next">Next <span class="fa fa-arrow-circle-right"></span></a>
</div>
<hr/>
<div role="contentinfo">
<p>
&copy; Copyright 2020, Yoxem Chen
</p>
</div>
Built with <a href="http://sphinx-doc.org/">Sphinx</a> using a
<a href="https://github.com/rtfd/sphinx_rtd_theme">theme</a>
provided by <a href="https://readthedocs.org">Read the Docs</a>.
</footer>
</div>
</div>
</section>
</div>
<script type="text/javascript">
jQuery(function () {
SphinxRtdTheme.Navigation.enable(true);
});
</script>
</body>
</html>