Giter Club home page Giter Club logo

tsll's People

Contributors

lung21 avatar nvrdftd avatar taquangtrung avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

qtcodes igorjs

tsll's Issues

Failed to install typescriptllvm globally

Typescriptllvm fails to find LLVM 13 during the global installation:

LLVM environment:

$ npm config set cmake_LLVM_DIR $(/home/trungtq/llvm/llvm-sbip/bin/llvm-config --cmakedir)
$ /home/trungtq/llvm/llvm-sbip/bin/llvm-config --version
13.0.1

Error during compilation of Typescriptllvm: LLVM 8 is detected, but not LLVM 13

sudo npm install -g @lungchen/typescriptllvm
[sudo] password for trungtq:
npm ERR! code 1
npm ERR! path /usr/local/lib/node_modules/@lungchen/typescriptllvm/node_modules/@lungchen/llvm-node
npm ERR! command failed
npm ERR! command sh -c cmake-js compile
npm ERR! [
npm ERR!   '/usr/bin/node',
npm ERR!   '/usr/local/lib/node_modules/@lungchen/typescriptllvm/node_modules/.bin/cmake-js',
npm ERR!   'compile'
npm ERR! ]
npm ERR! Not searching for unused variables given on the command line.
npm ERR! -- The C compiler identification is GNU 9.3.0
npm ERR! -- The CXX compiler identification is GNU 9.3.0
npm ERR! -- Check for working C compiler: /usr/bin/cc
npm ERR! -- Check for working C compiler: /usr/bin/cc -- works
npm ERR! -- Detecting C compiler ABI info
npm ERR! -- Detecting C compiler ABI info - done
npm ERR! -- Detecting C compile features
npm ERR! -- Detecting C compile features - done
npm ERR! -- Check for working CXX compiler: /usr/bin/c++
npm ERR! -- Check for working CXX compiler: /usr/bin/c++ -- works
npm ERR! -- Detecting CXX compiler ABI info
npm ERR! -- Detecting CXX compiler ABI info - done
npm ERR! -- Detecting CXX compile features
npm ERR! -- Detecting CXX compile features - done
npm ERR! -- Found LLVM 8.0.1
npm ERR! -- Using LLVMConfig.cmake in: /usr/lib/llvm-8/cmake
npm ERR! -- Configuring done
npm ERR! -- Generating done
npm ERR! -- Build files have been written to: /usr/local/lib/node_modules/@lungchen/typescriptllvm/node_modules/@lungchen/llvm-node/build

Compilation of library imports into LLVM IR/Bitcode

Motivation

It is not enough to run a program in LLVM IR or Bitcode by itself, because the program may have been written with other library functions, classes, etc. In order for us to run it with lli, an LLVM interpreter, we need a way to compile and link these libraries used in that program.

Example

If we have the following program where console.log is from another library, we should compile its definition into LLVM IR, or link the compiled library with lli.

let str = 'string';
let a = 3;
let b = 4 + 1;
let c = a + 1;
function testCase1(a: number): void {
    return;
}

a = b;

console.log('print something meaningful');

Expected output

Then, we should receive the message as follows if we run the program above.

print something meaningful

Translation of Typescript generic types to LLVM IR

It is shown in the following that testing with non-nested generic type declarations against our implementation is currently possible. Please leave a comment if you have doubt over the test result.

Input in Typescript

class AnotherClass<T> {
    private testPrivateMember: T;

    constructor(intro: T) {
        this.testPrivateMember = intro;
    }

    public testPrivateInPublic(): T {
        return this.testPrivateMember;
    }
}

let typicalGeneric = new AnotherClass<number>(100);

Output in LLVM IR

; ModuleID = 'genericType.ts'
source_filename = "genericType.ts"

%AnotherClass = type { double }

define void @main(...) {
  %typicalGeneric = alloca %AnotherClass, align 8
  call void (%AnotherClass*, double, ...) @AnotherClass_Constructor(%AnotherClass* %typicalGeneric, double 1.000000e+02)
  ret void
}

define void @AnotherClass_Constructor(%AnotherClass* %this, double %intro, ...) {
  %1 = alloca double, align 8
  store double %intro, double* %1, align 8
  %2 = getelementptr inbounds %AnotherClass, %AnotherClass* %this, i32 0, i32 0
  %3 = load double, double* %1, align 8
  store double %3, double* %2, align 8
  ret void
}

define double @AnotherClass_testPrivateInPublic(%AnotherClass* %this, ...) {
  %1 = getelementptr inbounds %AnotherClass, %AnotherClass* %this, i32 0, i32 0
  %2 = load double, double* %1, align 8
  ret double %2
}

Node installation issue

Hi @lung21,

I encountered this error when trying to run npm install

npm ERR! code E404
npm ERR! 404 Not Found - GET https://registry.npmjs.org/@lungchen%2fllvm-node - Not found
npm ERR! 404
npm ERR! 404  '@lungchen/llvm-node@^0.0.4' is not in this registry.
npm ERR! 404 You should bug the author to publish it (or use the name yourself!)
npm ERR! 404
npm ERR! 404 Note that you can also install from a
npm ERR! 404 tarball, folder, http url, or git url.

Can you help to check?

Translation of Typescript anyType to LLVM IR

Motivation

Similar to Javascript, Typescript also supports type any that allows a variable of that type to be assigned values of any other types. This also means that the type checking is disabled whenever any is used in Typescript. Now we are trying to find how any constructs with any could be possibly translated into LLVM IR. Below is an example of one variable and two functions that are defined with any in Typescript.

Example

let obj: any = { content: 'heymycontent' };
obj = 23;

function isView(arg: any): boolean {
    // Do something here
}

// the output of this function may be of any
function calculate(argA: string, argB: number): any {
    return argA + argB;
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.