Skip to content
This repository has been archived by the owner on Sep 13, 2022. It is now read-only.

First Blood #1

Merged
merged 4 commits into from Aug 14, 2019
Merged

First Blood #1

merged 4 commits into from Aug 14, 2019

Conversation

mohanson
Copy link
Contributor

  • The main framework of compiler(Passed the Fibonacci test)

README.md Outdated

```
$ npm install
$ ts-node src/index.ts build tests/ts/application/fibonacci.ts
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

npm start

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fix.

src/index.ts Outdated
// [0] https://github.com/microsoft/TypeScript/wiki/Using-the-Compiler-API
// [1] https://github.com/microsoft/TypeScript/blob/master/doc/spec.md

import * as child_process from 'child_process';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggest removing *

import x from 'xxx';

@@ -0,0 +1,31 @@
import os
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you change the test to ave? Remove python code.

package.json Outdated
"commander": "^3.0.0",
"llvm-node": "^2.1.0",
"typescript": "^3.5.3",
"yarn": "^1.17.3"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why dependence yarn?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you want to do this globally, you should execute npm i -g yarn.

src/index.ts Outdated
}

function mainRun(): void {
if (typeof argv.output === 'undefined') {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

argv.output === undefined

argv.output = '/tmp/minits.ll';
}
mainBuild();
const p = child_process.spawn('lli', [argv.output]);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the point of starting another process?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use lli to execute the LLVM IR.

src/codegen.ts Outdated
}

public genSourceFile(sourceFile: ts.SourceFile): void {
sourceFile.forEachChild(node => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
sourceFile.forEachChild(node => {
sourceFile.forEachChild(this.genNode)


public genNode(
node: ts.Node
): llvm.Constant | llvm.Type | llvm.Value | undefined | void {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

llvm.Type | llvm.Value | null

@yejiayu yejiayu merged commit 4d3474d into master Aug 14, 2019
@mohanson mohanson deleted the fb branch August 15, 2019 06:31
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants