llvm 0.0.8

  • README.md
  • Example
  • Installing
  • Versions
  • 45

llvm

Support for generating LLVM IR, and using the LLVM toolchain within Dart.

example/main.dart

/// Based on the tutorial found [here](http://releases.llvm.org/2.6/docs/tutorial/JITTutorial1.html).
library llvm.example.a_first_function;

import 'package:indenting_buffer/indenting_buffer.dart';
import 'package:llvm/llvm.dart';

main() {
  var mod = new LlvmModule('test');

  // %define i32 mul_add(i32 %x, i32 %y, i32 %z)
  var mulAdd = new LlvmFunction('mul_add', returnType: LlvmType.i32);
  mulAdd.parameters.addAll([
    new LlvmParameter('x', LlvmType.i32),
    new LlvmParameter('y', LlvmType.i32),
    new LlvmParameter('z', LlvmType.i32)
  ]);

  // entry:
  var basicBlock = new LlvmBasicBlock('entry', mulAdd);

  // %tmp = mul i32 %x, %y
  var tmp = new LlvmValue('tmp');
  basicBlock.addStatement(tmp.assign(new LlvmBinaryExpression(
      Instruction.mul,
      new LlvmValue.reference('x', LlvmType.i32),
      new LlvmValue.reference('y', LlvmType.i32))));

  // %tmp2 = add i32 %x, %y
  var tmp2 = new LlvmValue('tmp2');
  basicBlock.addStatement(tmp2.assign(new LlvmBinaryExpression(
      Instruction.add, tmp, new LlvmValue.reference('z', LlvmType.i32))));

  // %ret i32 %tmp2
  basicBlock.addStatement(tmp2.asReturn());

  mulAdd.blocks.add(basicBlock);
  mod.functions.add(mulAdd);

  var buf = new IndentingBuffer();
  mod.compile(buf);

  var ir = buf.toString();
  print('Generated LLVM IR:\n');
  print(ir);
}

1. Depend on it

Add this to your package's pubspec.yaml file:


dependencies:
  llvm: "^0.0.8"

2. Install it

You can install packages from the command line:

with pub:


$ pub get

with Flutter:


$ flutter packages get

Alternatively, your editor might support pub get or packages get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


import 'package:llvm/llvm.dart';
        
Version Uploaded Documentation Archive
0.0.8 Nov 21, 2017 Go to the documentation of llvm 0.0.8 Download llvm 0.0.8 archive
0.0.7 Nov 21, 2017 Go to the documentation of llvm 0.0.7 Download llvm 0.0.7 archive
0.0.6 Nov 21, 2017 Go to the documentation of llvm 0.0.6 Download llvm 0.0.6 archive
0.0.5 Nov 21, 2017 Go to the documentation of llvm 0.0.5 Download llvm 0.0.5 archive
0.0.4 Nov 21, 2017 Go to the documentation of llvm 0.0.4 Download llvm 0.0.4 archive
0.0.3 Nov 21, 2017 Go to the documentation of llvm 0.0.3 Download llvm 0.0.3 archive
0.0.2 Nov 21, 2017 Go to the documentation of llvm 0.0.2 Download llvm 0.0.2 archive
0.0.1 Nov 21, 2017 Go to the documentation of llvm 0.0.1 Download llvm 0.0.1 archive
0.0.0 Nov 18, 2017 Go to the documentation of llvm 0.0.0 Download llvm 0.0.0 archive

Analysis

We analyzed this package on Apr 23, 2018, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.0.0-dev.49.0
  • pana: 0.10.6

Scores

Popularity:
Describes how popular the package is relative to other packages. [more]
0 / 100
Health:
Code health derived from static analysis. [more]
98 / 100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
80 / 100
Overall score:
Weighted score of the above. [more]
45
Learn more about scoring.

Platforms

Detected platforms: Flutter, other

Primary library: package:llvm/llvm.dart with components: io.

Suggestions

  • Maintain CHANGELOG.md.

    Changelog entries help clients to follow the progress in your code.

  • Package is pre-v1 release.

    While there is nothing inherently wrong with versions of 0.*.*, it usually means that the author is still experimenting with the general direction API.

  • Fix analysis and formatting issues.

    Analysis or formatting checks reported 9 hints.

    Run dartfmt to format lib/src/ast/binary.dart.

    Run dartfmt to format lib/src/ast/block.dart.

    Similar analysis of the following files failed:

    • lib/src/ast/call.dart (hint)
    • lib/src/ast/constant.dart (hint)
    • lib/src/ast/declare.dart (hint)
    • lib/src/ast/expression.dart (hint)
    • lib/src/ast/statement.dart (hint)
    • lib/src/ast/type.dart (hint)
    • lib/src/toolchain/toolchain.dart (hint)

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=1.19.0
indenting_buffer ^1.0.0 1.0.1
meta ^1.0.0 1.1.2
process ^2.0.0 2.0.9 3.0.1
random_string ^0.0.1 0.0.1
Transitive dependencies
charcode 1.1.1
file 3.0.0 5.0.0
intl 0.15.6
path 1.5.1
platform 2.1.2