Commit 73af8363 authored by Andre Lipke's avatar Andre Lipke

Merge branch 'release' into 'master'

Release

See merge request !1
parents de7aab67 64d4a47c
# lambda
A new Flutter project.
## Getting Started
For help getting started with Flutter, view our online
[documentation](http://flutter.io/).
I'm on the play store!
https://play.google.com/store/apps/details?id=com.pxtst.lambda
\ No newline at end of file
......@@ -26,7 +26,7 @@ android {
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "com.yourcompany.lambda"
applicationId "com.pxtst.lambda"
}
buildTypes {
......
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.yourcompany.lambda"
package="com.pxtst.lambda"
android:versionCode="1"
android:versionName="0.0.1">
......
File added
<?xml version="1.0" encoding="UTF-8"?>
<module type="FLUTTER_MODULE_TYPE" version="4">
<module type="WEB_MODULE" version="4">
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$">
......@@ -9,6 +9,7 @@
</content>
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" name="Dart SDK" level="project" />
<orderEntry type="library" name="Flutter Plugins" level="project" />
<orderEntry type="library" name="Dart Packages" level="project" />
</component>
</module>
\ No newline at end of file
import 'dart:async';
import 'dart:collection';
class _CoroutineEnd {}
class Coroutine {
Coroutine(void func(dynamic d)) {
zone = runZoned(() {
func(yield());
}, zoneValues: {
"coroutine": this,
}, onError: (e) {
if (e is! _CoroutineEnd) {
throw e;
}
});
}
Zone zone;
final _overflowStack = new Queue<Completer>();
final _yieldStack = new Queue<Completer>();
final _resumeStack = new Queue<Completer>()..add(new Completer());
static Future yield([dynamic x]) async {
final co = Zone.current["coroutine"] as Coroutine;
if (co == null) throw new Exception("Attempt to yield when not inside a coroutine");
co._resumeStack.removeFirst().complete(x);
var c = new Completer();
co._yieldStack.add(c);
if (co._overflowStack.isNotEmpty) {
co._overflowStack.removeFirst().complete();
}
return await c.future;
}
bool resuming = false;
Future resume([dynamic x]) async {
if (_yieldStack.isEmpty) {
var c = new Completer();
_overflowStack.add(c);
await c.future;
}
_yieldStack.removeFirst().complete(x);
var c = new Completer();
_resumeStack.add(c);
return await c.future;
}
}
......@@ -53,7 +53,7 @@ class Expr {
dropzoneKeys = [];
}
Expr.fromJson(Map d) : type = ExprType.values[d["type"]], name = d["name"] {
children = (d["children"] as List<Map>).map((cd) => new Expr.fromJson(cd)..parent = this).toList();
children = (d["children"] as List<Map>).map((cd) => cd == null ? null : (new Expr.fromJson(cd)..parent = this)).toList();
dropzoneKeys = new List.generate(children.length, (i) => new GlobalKey());
}
......
......@@ -120,9 +120,9 @@ class LambdaPanelState extends State<LambdaPanel> with TickerProviderStateMixin
new LambdaItem("λn", () => new Expr.lambda("n")),
new LambdaItem("λm", () => new Expr.lambda("m")),
new LambdaItem("λs", () => new Expr.lambda("s")),
new LambdaItem("λ", () => new Expr.lambda("x")),
//new LambdaItem("λ", () => new Expr.lambda("x")),
],
"Integer": [
/*"Integer": [
new LambdaItem("0", () => new Expr.variable("0")),
new LambdaItem("SUCC", () => new Expr.variable("SUCC")),
new LambdaItem("PRED", () => new Expr.variable("PRED")),
......@@ -167,7 +167,7 @@ class LambdaPanelState extends State<LambdaPanel> with TickerProviderStateMixin
],
"Recursive": [
new LambdaItem("Y", () => new Expr.lambda("x")),
],
],*/
};
bool expanded;
......
......@@ -90,7 +90,7 @@ class SettingsPageState extends State<SettingsPage> {
new Switch(value: data.insert, onChanged: (b) => setState(() => data.insert = b)),
])), onTap: () => setState(() => data.insert = !data.insert))),
new Padding(padding: const EdgeInsets.only(top: 16.0)),
/*new Padding(padding: const EdgeInsets.only(top: 16.0)),
new Center(child: const Text("Solver")),
const Divider(),
......@@ -133,7 +133,7 @@ class SettingsPageState extends State<SettingsPage> {
setState(() {});
},
), width: 160.0),
])),
])),*/
]),
);
}
......
import 'dart:async';
import 'coroutine.dart';
import 'dart:collection';
class ExprPointer {
ExprPointer(this.expr, this.stack);
Expr expr;
List<Expr> stack = [];
}
abstract class Expr {
bool get isStub;
int get complexity;
Expr get breakdown => this;
Expr copy(int jmp) {
List<Expr> lambdaStack = [];
Expr sCopy(Expr e) {
if (e is Lambda) {
lambdaStack.add(e);
var o = new Lambda(sCopy(e.body), name: e.name);
lambdaStack.removeLast();
return o;
} else if (e is Ref) {
if (e.index < lambdaStack.length) { // Reference is within scope
return new Ref(e.index, name: e.name);
} else {
if (e.index + jmp < lambdaStack.length) throw "Invalid jump";
return new Ref(e.index + jmp, name: e.name);
}
} else if (e is Apply) {
return new Apply(sCopy(e.lambda), sCopy(e.param));
}
throw "Unhandled Expr $e";
}
return sCopy(this);
}
void shift(int jmp) {
List<Expr> lambdaStack = [];
sShift(Expr e) {
if (e is Lambda) {
lambdaStack.add(e);
sShift(e.body);
lambdaStack.removeLast();
} else if (e is Ref) {
if (e.index >= lambdaStack.length) { // Reference outside of scope
if (e.index + jmp < lambdaStack.length) throw "Invalid jump";
e.index += jmp;
}
} else if (e is Apply) {
sShift(e.lambda);
sShift(e.param);
}
throw "Unhandled Expr $e";
}
sShift(this);
}
}
class Lambda extends Expr {
Lambda.empty();
Lambda(this.body, {this.name});
String name;
Expr body;
get isStub => body != null;
get complexity => body.complexity + 1;
}
/*typedef Expr _ExprGetter(Generator g);
typedef bool _BoolGetter(Generator g);
typedef int _IntGetter(Generator g);
typedef void _JumpHandler(int base, int jmp);*/
/*class Generator extends Expr {
_ExprGetter getExpr;
_IntGetter getComplexity;
_ExprGetter getBreakdown;
_BoolGetter getIsStub;
_JumpHandler handleJump;
Generator({this.getExpr, this.getBreakdown, this.getIsStub, this.getComplexity, this.handleJump, this.name});
String name;
Expr get expr => getExpr(this);
int get complexity => getComplexity(this);
Expr get breakdown => getBreakdown(this);
bool get isStub => getIsStub(this);
}*/
class Ref extends Expr {
Ref(this.index, {this.name});
String name;
int index;
get isStub => false;
get complexity => 1;
}
class Apply extends Expr {
Apply(this.lambda, this.param);
Expr lambda;
Expr param;
get isStub => lambda == null || param == null;
get complexity => lambda.complexity + param.complexity + 1;
}
/*class NumberExpr extends Expr {
NumberExpr(this.value);
int value;
get isStub => false;
get breakdown {
return new Generator(
getExpr: () {
return new Generator(
)
}
)
}
get complexity => (value * 2) + 3;
}*/
abstract class Solver {
Expr root;
Future<Expr> solve();
}
typedef Expr ParamSolver();
class HybridSolver extends Solver {
HybridSolver(this.root);
Expr root;
solve() {
List<Lambda> lambdaStack = [];
List<int> usedStack = [];
Map<Lambda, ParamSolver> solvers = {};
int used;
Expr step(Expr e) {
e = e.breakdown;
if (e is Lambda) {
lambdaStack.add(e);
usedStack.add(0);
step(e.body);
used = usedStack.removeLast();
lambdaStack.removeLast();
} else if (e is Apply) {
Apply apply = e;
if (apply.lambda is! Lambda) {
apply.lambda = step(apply.lambda);
if (used == 0) return (apply.lambda as Lambda).body..shift(-1);
}
if (apply.lambda is! Lambda) {
return apply;
} else {
Expr solved;
int depth = lambdaStack.length;
solvers[apply.lambda] = () {
if (solved == null) {
var save = lambdaStack;
lambdaStack = lambdaStack.take(depth).toList();
solved = step(apply.param);
lambdaStack = save;
}
return solved.copy(lambdaStack.length - depth);
};
var out = (step(apply.lambda) as Lambda).body;
solvers.remove(apply.lambda);
return out..shift(-1);
}
} else if (e is Ref) {
if (e.isStub || e.index >= lambdaStack.length) return e;
return solvers[lambdaStack[lambdaStack.length - (e.index + 1)]]();
}
return e;
}
root = step(root);
}
}
......@@ -2,10 +2,10 @@ name: lambda
description: A new Flutter project.
dependencies:
flutter:
sdk: flutter
shared_preferences: "^0.2.4+1"
flutter:
sdk: flutter
tuple: "^1.0.1"
uuid: "^0.5.3"
......
cp build/app/outputs/apk/app-release.apk .
zipalign -v -p 4 app-release.apk app-release-aligned.apk
apksigner sign --ks ~/lambda.jks --out app-release-signed.apk app-release-aligned.apk
echo "success"
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment