Skip to content

Commit

Permalink
Make docs
Browse files Browse the repository at this point in the history
  • Loading branch information
nielstron committed Mar 20, 2023
1 parent 8956f40 commit bc120eb
Show file tree
Hide file tree
Showing 8 changed files with 823 additions and 219 deletions.
478 changes: 268 additions & 210 deletions docs/index.js

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions docs/opshin/compiler.html
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ <h1 class="title">Module <code>opshin.compiler</code></h1>
from .rewrite.rewrite_inject_builtin_constr import RewriteInjectBuiltinsConstr
from .rewrite.rewrite_remove_type_stuff import RewriteRemoveTypeStuff
from .rewrite.rewrite_tuple_assign import RewriteTupleAssign
from .rewrite.rewrite_zero_ary import RewriteZeroAry
from .optimize.optimize_remove_pass import OptimizeRemovePass
from .optimize.optimize_remove_deadvars import OptimizeRemoveDeadvars
from .optimize.optimize_varlen import OptimizeVarlen
Expand Down Expand Up @@ -927,6 +928,7 @@ <h1 class="title">Module <code>opshin.compiler</code></h1>
# The type inference needs to be run after complex python operations were rewritten
AggressiveTypeInferencer(),
# Rewrites that circumvent the type inference or use its results
RewriteZeroAry(),
RewriteInjectBuiltinsConstr(),
RewriteRemoveTypeStuff(),
]
Expand Down Expand Up @@ -981,6 +983,7 @@ <h2 class="section-title" id="header-functions">Functions</h2>
# The type inference needs to be run after complex python operations were rewritten
AggressiveTypeInferencer(),
# Rewrites that circumvent the type inference or use its results
RewriteZeroAry(),
RewriteInjectBuiltinsConstr(),
RewriteRemoveTypeStuff(),
]
Expand Down
3 changes: 2 additions & 1 deletion docs/opshin/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,8 @@ <h3 id="name">Name</h3>
[&hellip;] Eopsin was believed to be a pitch-black snake that had ears. <a href="https://en.wikipedia.org/wiki/Eopsin">[1]</a></p>
</blockquote>
<p>Since this project tries to merge Python (a large serpent) and Pluto/Plutus (Greek wealth gods), the name appears fitting.
The name eopsin is pronounced <em>op-shin</em>.</p>
The name e_opsin is pronounced <em>op-shin</em>.
e</p>
<h2 id="contributing">Contributing</h2>
<h3 id="architecture">Architecture</h3>
<p>This program consists of a few independent components:</p>
Expand Down
5 changes: 5 additions & 0 deletions docs/opshin/rewrite/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,10 @@ <h2 class="section-title" id="header-submodules">Sub-modules</h2>
<dd>
<div class="desc"></div>
</dd>
<dt><code class="name"><a title="opshin.rewrite.rewrite_zero_ary" href="rewrite_zero_ary.html">opshin.rewrite.rewrite_zero_ary</a></code></dt>
<dd>
<div class="desc"></div>
</dd>
</dl>
</section>
<section>
Expand Down Expand Up @@ -198,6 +202,7 @@ <h1>Index</h1>
<li><code><a title="opshin.rewrite.rewrite_inject_builtins" href="rewrite_inject_builtins.html">opshin.rewrite.rewrite_inject_builtins</a></code></li>
<li><code><a title="opshin.rewrite.rewrite_remove_type_stuff" href="rewrite_remove_type_stuff.html">opshin.rewrite.rewrite_remove_type_stuff</a></code></li>
<li><code><a title="opshin.rewrite.rewrite_tuple_assign" href="rewrite_tuple_assign.html">opshin.rewrite.rewrite_tuple_assign</a></code></li>
<li><code><a title="opshin.rewrite.rewrite_zero_ary" href="rewrite_zero_ary.html">opshin.rewrite.rewrite_zero_ary</a></code></li>
</ul>
</li>
</ul>
Expand Down
336 changes: 336 additions & 0 deletions docs/opshin/rewrite/rewrite_zero_ary.html

Large diffs are not rendered by default.

204 changes: 202 additions & 2 deletions docs/opshin/tests/test_misc.html
Original file line number Diff line number Diff line change
Expand Up @@ -813,7 +813,59 @@ <h1 class="title">Module <code>opshin.tests.test_misc</code></h1>
ast = compiler.parse(source_code)
code = compiler.compile(ast).compile()
res = uplc_eval(uplc.Apply(code, uplc.PlutusInteger(0))).value
self.assertEqual(res, 0)</code></pre>
self.assertEqual(res, 0)

def test_zero_ary(self):
source_code = &#34;&#34;&#34;
def a() -&gt; None:
assert False, &#34;Executed a&#34;

def validator(x: None) -&gt; None:
b = a
if False:
b()
&#34;&#34;&#34;
ast = compiler.parse(source_code)
code = compiler.compile(ast).compile()
res = uplc_eval(uplc.Apply(code, uplc.PlutusInteger(0)))

@unittest.expectedFailure
def test_zero_ary_exec(self):
source_code = &#34;&#34;&#34;
def a() -&gt; None:
assert False, &#34;Executed a&#34;

def validator(x: None) -&gt; None:
b = a
if True:
b()
&#34;&#34;&#34;
ast = compiler.parse(source_code)
code = compiler.compile(ast).compile()
res = uplc_eval(uplc.Apply(code, uplc.PlutusInteger(0)))

def test_zero_ary_method(self):
source_code = &#34;&#34;&#34;
def validator(x: None) -&gt; None:
b = b&#34;\\xFF&#34;.decode
if False:
b()
&#34;&#34;&#34;
ast = compiler.parse(source_code)
code = compiler.compile(ast).compile()
res = uplc_eval(uplc.Apply(code, uplc.PlutusInteger(0)))

@unittest.expectedFailure
def test_zero_ary_method_exec(self):
source_code = &#34;&#34;&#34;
def validator(x: None) -&gt; None:
b = b&#34;\\xFF&#34;.decode
if True:
b()
&#34;&#34;&#34;
ast = compiler.parse(source_code)
code = compiler.compile(ast).compile()
res = uplc_eval(uplc.Apply(code, uplc.PlutusInteger(0)))</code></pre>
</details>
</section>
<section>
Expand Down Expand Up @@ -1608,7 +1660,59 @@ <h2 class="section-title" id="header-classes">Classes</h2>
ast = compiler.parse(source_code)
code = compiler.compile(ast).compile()
res = uplc_eval(uplc.Apply(code, uplc.PlutusInteger(0))).value
self.assertEqual(res, 0)</code></pre>
self.assertEqual(res, 0)

def test_zero_ary(self):
source_code = &#34;&#34;&#34;
def a() -&gt; None:
assert False, &#34;Executed a&#34;

def validator(x: None) -&gt; None:
b = a
if False:
b()
&#34;&#34;&#34;
ast = compiler.parse(source_code)
code = compiler.compile(ast).compile()
res = uplc_eval(uplc.Apply(code, uplc.PlutusInteger(0)))

@unittest.expectedFailure
def test_zero_ary_exec(self):
source_code = &#34;&#34;&#34;
def a() -&gt; None:
assert False, &#34;Executed a&#34;

def validator(x: None) -&gt; None:
b = a
if True:
b()
&#34;&#34;&#34;
ast = compiler.parse(source_code)
code = compiler.compile(ast).compile()
res = uplc_eval(uplc.Apply(code, uplc.PlutusInteger(0)))

def test_zero_ary_method(self):
source_code = &#34;&#34;&#34;
def validator(x: None) -&gt; None:
b = b&#34;\\xFF&#34;.decode
if False:
b()
&#34;&#34;&#34;
ast = compiler.parse(source_code)
code = compiler.compile(ast).compile()
res = uplc_eval(uplc.Apply(code, uplc.PlutusInteger(0)))

@unittest.expectedFailure
def test_zero_ary_method_exec(self):
source_code = &#34;&#34;&#34;
def validator(x: None) -&gt; None:
b = b&#34;\\xFF&#34;.decode
if True:
b()
&#34;&#34;&#34;
ast = compiler.parse(source_code)
code = compiler.compile(ast).compile()
res = uplc_eval(uplc.Apply(code, uplc.PlutusInteger(0)))</code></pre>
</details>
<h3>Ancestors</h3>
<ul class="hlist">
Expand Down Expand Up @@ -2734,6 +2838,98 @@ <h3>Methods</h3>
f = code.term</code></pre>
</details>
</dd>
<dt id="opshin.tests.test_misc.MiscTest.test_zero_ary"><code class="name flex">
<span>def <span class="ident">test_zero_ary</span></span>(<span>self)</span>
</code></dt>
<dd>
<div class="desc"></div>
<details class="source">
<summary>
<span>Expand source code</span>
</summary>
<pre><code class="python"> def test_zero_ary(self):
source_code = &#34;&#34;&#34;
def a() -&gt; None:
assert False, &#34;Executed a&#34;

def validator(x: None) -&gt; None:
b = a
if False:
b()
&#34;&#34;&#34;
ast = compiler.parse(source_code)
code = compiler.compile(ast).compile()
res = uplc_eval(uplc.Apply(code, uplc.PlutusInteger(0)))</code></pre>
</details>
</dd>
<dt id="opshin.tests.test_misc.MiscTest.test_zero_ary_exec"><code class="name flex">
<span>def <span class="ident">test_zero_ary_exec</span></span>(<span>self)</span>
</code></dt>
<dd>
<div class="desc"></div>
<details class="source">
<summary>
<span>Expand source code</span>
</summary>
<pre><code class="python"> @unittest.expectedFailure
def test_zero_ary_exec(self):
source_code = &#34;&#34;&#34;
def a() -&gt; None:
assert False, &#34;Executed a&#34;

def validator(x: None) -&gt; None:
b = a
if True:
b()
&#34;&#34;&#34;
ast = compiler.parse(source_code)
code = compiler.compile(ast).compile()
res = uplc_eval(uplc.Apply(code, uplc.PlutusInteger(0)))</code></pre>
</details>
</dd>
<dt id="opshin.tests.test_misc.MiscTest.test_zero_ary_method"><code class="name flex">
<span>def <span class="ident">test_zero_ary_method</span></span>(<span>self)</span>
</code></dt>
<dd>
<div class="desc"></div>
<details class="source">
<summary>
<span>Expand source code</span>
</summary>
<pre><code class="python"> def test_zero_ary_method(self):
source_code = &#34;&#34;&#34;
def validator(x: None) -&gt; None:
b = b&#34;\\xFF&#34;.decode
if False:
b()
&#34;&#34;&#34;
ast = compiler.parse(source_code)
code = compiler.compile(ast).compile()
res = uplc_eval(uplc.Apply(code, uplc.PlutusInteger(0)))</code></pre>
</details>
</dd>
<dt id="opshin.tests.test_misc.MiscTest.test_zero_ary_method_exec"><code class="name flex">
<span>def <span class="ident">test_zero_ary_method_exec</span></span>(<span>self)</span>
</code></dt>
<dd>
<div class="desc"></div>
<details class="source">
<summary>
<span>Expand source code</span>
</summary>
<pre><code class="python"> @unittest.expectedFailure
def test_zero_ary_method_exec(self):
source_code = &#34;&#34;&#34;
def validator(x: None) -&gt; None:
b = b&#34;\\xFF&#34;.decode
if True:
b()
&#34;&#34;&#34;
ast = compiler.parse(source_code)
code = compiler.compile(ast).compile()
res = uplc_eval(uplc.Apply(code, uplc.PlutusInteger(0)))</code></pre>
</details>
</dd>
</dl>
</dd>
</dl>
Expand Down Expand Up @@ -2853,6 +3049,10 @@ <h4><code><a title="opshin.tests.test_misc.MiscTest" href="#opshin.tests.test_mi
<li><code><a title="opshin.tests.test_misc.MiscTest.test_union_type_attr_anytype" href="#opshin.tests.test_misc.MiscTest.test_union_type_attr_anytype">test_union_type_attr_anytype</a></code></li>
<li><code><a title="opshin.tests.test_misc.MiscTest.test_wrap_into_generic_data" href="#opshin.tests.test_misc.MiscTest.test_wrap_into_generic_data">test_wrap_into_generic_data</a></code></li>
<li><code><a title="opshin.tests.test_misc.MiscTest.test_wrapping_contract_compile" href="#opshin.tests.test_misc.MiscTest.test_wrapping_contract_compile">test_wrapping_contract_compile</a></code></li>
<li><code><a title="opshin.tests.test_misc.MiscTest.test_zero_ary" href="#opshin.tests.test_misc.MiscTest.test_zero_ary">test_zero_ary</a></code></li>
<li><code><a title="opshin.tests.test_misc.MiscTest.test_zero_ary_exec" href="#opshin.tests.test_misc.MiscTest.test_zero_ary_exec">test_zero_ary_exec</a></code></li>
<li><code><a title="opshin.tests.test_misc.MiscTest.test_zero_ary_method" href="#opshin.tests.test_misc.MiscTest.test_zero_ary_method">test_zero_ary_method</a></code></li>
<li><code><a title="opshin.tests.test_misc.MiscTest.test_zero_ary_method_exec" href="#opshin.tests.test_misc.MiscTest.test_zero_ary_method_exec">test_zero_ary_method_exec</a></code></li>
</ul>
</li>
</ul>
Expand Down
12 changes: 6 additions & 6 deletions docs/opshin/type_inference.html
Original file line number Diff line number Diff line change
Expand Up @@ -577,11 +577,11 @@ <h1 class="title">Module <code>opshin.type_inference</code></h1>
functyp = tc.func.typ.typ
assert len(tc.args) == len(
functyp.argtyps
), f&#34;Signature of function {ast.dump(node)} does not match number of arguments&#34;
), f&#34;Signature of function does not match number of arguments. Expected {len(functyp.argtyps)} arguments with these types: {functyp.argtyps}&#34;
# all arguments need to be supertypes of the given type
assert all(
ap &gt;= a.typ for a, ap in zip(tc.args, functyp.argtyps)
), f&#34;Signature of function {ast.dump(node)} does not match arguments&#34;
), f&#34;Signature of function does not match arguments. Expected {len(functyp.argtyps)} arguments with these types: {functyp.argtyps}&#34;
tc.typ = functyp.rettyp
return tc
raise TypeInferenceError(&#34;Could not infer type of call&#34;)
Expand Down Expand Up @@ -1290,11 +1290,11 @@ <h2 class="section-title" id="header-classes">Classes</h2>
functyp = tc.func.typ.typ
assert len(tc.args) == len(
functyp.argtyps
), f&#34;Signature of function {ast.dump(node)} does not match number of arguments&#34;
), f&#34;Signature of function does not match number of arguments. Expected {len(functyp.argtyps)} arguments with these types: {functyp.argtyps}&#34;
# all arguments need to be supertypes of the given type
assert all(
ap &gt;= a.typ for a, ap in zip(tc.args, functyp.argtyps)
), f&#34;Signature of function {ast.dump(node)} does not match arguments&#34;
), f&#34;Signature of function does not match arguments. Expected {len(functyp.argtyps)} arguments with these types: {functyp.argtyps}&#34;
tc.typ = functyp.rettyp
return tc
raise TypeInferenceError(&#34;Could not infer type of call&#34;)
Expand Down Expand Up @@ -1744,11 +1744,11 @@ <h3>Methods</h3>
functyp = tc.func.typ.typ
assert len(tc.args) == len(
functyp.argtyps
), f&#34;Signature of function {ast.dump(node)} does not match number of arguments&#34;
), f&#34;Signature of function does not match number of arguments. Expected {len(functyp.argtyps)} arguments with these types: {functyp.argtyps}&#34;
# all arguments need to be supertypes of the given type
assert all(
ap &gt;= a.typ for a, ap in zip(tc.args, functyp.argtyps)
), f&#34;Signature of function {ast.dump(node)} does not match arguments&#34;
), f&#34;Signature of function does not match arguments. Expected {len(functyp.argtyps)} arguments with these types: {functyp.argtyps}&#34;
tc.typ = functyp.rettyp
return tc
raise TypeInferenceError(&#34;Could not infer type of call&#34;)</code></pre>
Expand Down
1 change: 1 addition & 0 deletions docs/opshin/util.html
Original file line number Diff line number Diff line change
Expand Up @@ -790,6 +790,7 @@ <h3>Subclasses</h3>
<li><a title="opshin.rewrite.rewrite_inject_builtins.RewriteInjectBuiltins" href="rewrite/rewrite_inject_builtins.html#opshin.rewrite.rewrite_inject_builtins.RewriteInjectBuiltins">RewriteInjectBuiltins</a></li>
<li><a title="opshin.rewrite.rewrite_remove_type_stuff.RewriteRemoveTypeStuff" href="rewrite/rewrite_remove_type_stuff.html#opshin.rewrite.rewrite_remove_type_stuff.RewriteRemoveTypeStuff">RewriteRemoveTypeStuff</a></li>
<li><a title="opshin.rewrite.rewrite_tuple_assign.RewriteTupleAssign" href="rewrite/rewrite_tuple_assign.html#opshin.rewrite.rewrite_tuple_assign.RewriteTupleAssign">RewriteTupleAssign</a></li>
<li><a title="opshin.rewrite.rewrite_zero_ary.RewriteZeroAry" href="rewrite/rewrite_zero_ary.html#opshin.rewrite.rewrite_zero_ary.RewriteZeroAry">RewriteZeroAry</a></li>
<li><a title="opshin.type_inference.AggressiveTypeInferencer" href="type_inference.html#opshin.type_inference.AggressiveTypeInferencer">AggressiveTypeInferencer</a></li>
</ul>
<h3>Class variables</h3>
Expand Down

0 comments on commit bc120eb

Please sign in to comment.