Skip to content
This repository has been archived by the owner on Apr 29, 2021. It is now read-only.

Start work on an ARM parser. #68

Merged
merged 7 commits into from Jun 11, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
39 changes: 39 additions & 0 deletions pkg/armv4t_asm/README.md
@@ -0,0 +1,39 @@
<p align="center">
<h1 align="center">armv4t_asm</h1>
<p align="center">
Assembler for the ARMv4T CPU Architecture.
</p>
</p>

_Recommended reading: ["An Introduction to the GNU Assembler"][intro]._

[intro]: doc/gnu_assembler.pdf

## Installation

This package can be used as a standalone executable, or as a dependency.

### CLI

Use [`pub global activate`](https://www.dartlang.org/tools/pub/cmd/pub-global)
to install the assembler as a local program to be used on the command-line:

```bash
$ pub global activate armv4t_asm
$ armv4t_asm filename.s
> Assembling filename.s as filename.o...
> Wrote filename.o in 10ms.
```

Use `armv4t_asm --help` to get full usage information.

### Pub

```yaml
dependencies:
armv4t_asm:
```

## Usage

TBD.
Binary file added pkg/armv4t_asm/doc/gnu_assembler.pdf
Binary file not shown.
22 changes: 22 additions & 0 deletions pkg/armv4t_asm/lib/src/evaluate.dart
@@ -0,0 +1,22 @@
import 'package:func/func.dart';
import 'package:math_expressions/math_expressions.dart';

/// Returns the result of evaluating a mathematical [expression].
dynamic eval(String expression, int lookup(String varName)) => new Parser()
.parse(expression)
.evaluate(EvaluationType.REAL, new _DynamicContext(lookup));

class _DynamicContext extends ContextModel {
final Func1<String, int> _lookup;

_DynamicContext(this._lookup);

@override
Expression getExpression(String varName) {
final result = _lookup(varName);
if (result != null) {
return new Parser().parse('$result');
}
return super.getExpression(varName);
}
}