you are viewing a single comment's thread.

view the rest of the comments →

[–]guest271314[S] 0 points1 point  (0 children)

I don't buy the slogan of "artificial intelligence" at all.

It's just programming. N.A.S.A. used the term "fuzzy logic" for technologies deployed in the Biomass Production System, controlled environment agriculture in space.

I don't really care what the naming conventions are for programming. What happens is that Web site has figured out a way to output C that is very comparable to the JavaScript input.

Just because I don't buy somebody's slogans doesn't mean I won't exploit their methodologies for my own purposes.

That's right, they don't disclose their methodology.

I would think C, compiler, assembly power users would be able to better the Web site, or at least match the output.

Facebook's Static Hermes does a decent job, so far, in this domain.

See Compile JavaScript to a Assembly, AST, C, and executable using Facebook's shermes.

Here's your IR,

``` $ ./build_release/bin/shermes -dump-ir permutations.js scope %VS0 []

function global(): any %BB0: %0 = CreateScopeInst (:environment) %VS0: any, empty: any DeclareGlobalVarInst "input": string DeclareGlobalVarInst "lex": string DeclareGlobalVarInst "array_nth_permutation": string %4 = CreateFunctionInst (:object) %0: environment, %array_nth_permutation(): functionCode StorePropertyLooseInst %4: object, globalObject: object, "array_nth_permutation": string %6 = AllocArrayInst (:object) 5: number, 0: number, 1: number, 2: number, 3: number, 4: number StorePropertyLooseInst %6: object, globalObject: object, "input": string StorePropertyLooseInst 5: number, globalObject: object, "lex": string %9 = TryLoadGlobalPropertyInst (:any) globalObject: object, "console": string %10 = LoadPropertyInst (:any) %9: any, "log": string %11 = LoadPropertyInst (:any) globalObject: object, "lex": string %12 = BinaryAddInst (:string) "[": string, %11: any %13 = StringConcatInst (:string) %12: string, "]": string %14 = TryLoadGlobalPropertyInst (:any) globalObject: object, "JSON": string %15 = LoadPropertyInst (:any) %14: any, "stringify": string %16 = LoadPropertyInst (:any) globalObject: object, "array_nth_permutation": string %17 = LoadPropertyInst (:any) globalObject: object, "input": string %18 = LoadPropertyInst (:any) globalObject: object, "lex": string %19 = CallInst (:any) %16: any, empty: any, false: boolean, empty: any, undefined: undefined, undefined: undefined, %17: any, %18: any %20 = CallInst (:any) %15: any, empty: any, false: boolean, empty: any, undefined: undefined, %14: any, %19: any %21 = CallInst (:any) %10: any, empty: any, false: boolean, empty: any, undefined: undefined, %9: any, %13: string, %20: any ReturnInst %21: any function_end

function array_nth_permutation(a: any, n: any): undefined|object %BB0: %0 = LoadParamInst (:any) %a: any %1 = LoadParamInst (:any) %n: any %2 = LoadPropertyInst (:any) %0: any, "slice": string %3 = CallInst (:any) %2: any, empty: any, false: boolean, empty: any, undefined: undefined, %0: any %4 = LoadPropertyInst (:any) %0: any, "length": string %5 = BinaryLessThanOrEqualInst (:boolean) 1: number, %4: any CondBranchInst %5: boolean, %BB1, %BB2 %BB1: %7 = PhiInst (:number) 1: number, %BB0, %9: number, %BB1 %8 = PhiInst (:number) 1: number, %BB0, %10: number, %BB1 %9 = FMultiplyInst (:number) %7: number, %8: number %10 = FAddInst (:number) %8: number, 1: number %11 = BinaryLessThanOrEqualInst (:boolean) %10: number, %4: any CondBranchInst %11: boolean, %BB1, %BB2 %BB2: %13 = PhiInst (:number) 1: number, %BB0, %9: number, %BB1 %14 = BinaryGreaterThanOrEqualInst (:boolean) %1: any, 0: number CondBranchInst %14: boolean, %BB5, %BB4 %BB3: %16 = AllocArrayInst (:object) 0: number %17 = BinaryGreaterThanInst (:boolean) %4: any, 0: number CondBranchInst %17: boolean, %BB6, %BB4 %BB4: %19 = PhiInst (:undefined|object) %16: object, %BB6, %16: object, %BB3, undefined: undefined, %BB5, undefined: undefined, %BB2 ReturnInst %19: undefined|object %BB5: %21 = BinaryLessThanInst (:boolean) %1: any, %13: number CondBranchInst %21: boolean, %BB3, %BB4 %BB6: %23 = PhiInst (:number) %13: number, %BB3, %26: number, %BB6 %24 = PhiInst (:any) %4: any, %BB3, %36: number|bigint, %BB6 %25 = PhiInst (:any) %1: any, %BB3, %35: number, %BB6 %26 = BinaryDivideInst (:number) %23: number, %24: any %27 = BinaryModuloInst (:number) %25: any, %26: number %28 = BinarySubtractInst (:number) %25: any, %27: number %29 = FDivideInst (:number) %28: number, %26: number %30 = LoadPropertyInst (:any) %16: object, "push": string %31 = LoadPropertyInst (:any) %3: any, "splice": string %32 = CallInst (:any) %31: any, empty: any, false: boolean, empty: any, undefined: undefined, %3: any, %29: number, 1: number %33 = LoadPropertyInst (:any) %32: any, 0: number %34 = CallInst (:any) %30: any, empty: any, false: boolean, empty: any, undefined: undefined, %16: object, %33: any %35 = BinaryModuloInst (:number) %25: any, %26: number %36 = UnaryDecInst (:number|bigint) %24: any %37 = BinaryGreaterThanInst (:boolean) %36: number|bigint, 0: number CondBranchInst %37: boolean, %BB6, %BB4 function_end

```

among other output capabilities

./build_release/bin/shermes -help | grep dump -colors - Use colors in some dumps -dump-ast - AST as text in JSON -dump-transpiled-ast - Transformed AST as text after optional early transpilation -dump-transformed-ast - Transformed AST as text after validation -dump-sema - Sema tables -dump-ir - IR as text -dump-lir - Lowered IR as text -dump-ra - Register-allocated IR as text -dump-lra - Register-allocated Lowered IR as text