kray-g / kinx Goto Github PK
View Code? Open in Web Editor NEWLooks like JavaScript, feels like Ruby, and it is a script language fitting in C programmers.
License: MIT License
Looks like JavaScript, feels like Ruby, and it is a script language fitting in C programmers.
License: MIT License
The code will show the error.
class A() {}
function f(): A {
return new A(); // => Error: Expect return type (object) but (... unknown)
}
Here is the problem.
var a = [{a:1},{b:1}];
System.println(a);
System.println(a.flatten());
The result is as follows.
[{"a":1}, {"b":1}]
{}
Expectation is below.
[{"a":1}, {"b":1}]
[{"a":1}, {"b":1}]
Here is the code.
const A = 1;
const A = 2;
System.println(A);
No error and displaying 1
in this case.
The first impression that one has when trying to clone/build this project i that it's too big in disk size terms for a scrimping language, then after looking around I found this project https://github.com/newren/git-filter-repo to help trim down this repository and did a crude first try by removing the following folders src/extlib
, fonts
, examples/typesetting
and lib/katex
with the command bellow with a reduction is size from 233MB to 18MB, but although the repository history seems to be ok the Makefile need to be fixed to build this project again (not done).
git-filter-repo \
--replace-refs delete-no-add \
--path-glob 'src/extlib/' \
--path-glob 'fonts/' \
--path-glob 'lib/katex/' \
--path-glob 'examples/typesetting/' \
--invert-paths --force
And got this result:
kinx-filtered$ du -h
28K ./bench
264K ./include
4,0K ./.git/logs/refs/remotes
4,0K ./.git/logs/refs/heads
12K ./.git/logs/refs
20K ./.git/logs
12K ./.git/info
768K ./.git/filter-repo/analysis
944K ./.git/filter-repo
4,0K ./.git/branches
52K ./.git/hooks
4,0K ./.git/refs/tags
4,0K ./.git/refs/remotes
4,0K ./.git/refs/heads
16K ./.git/refs
108K ./.git/objects/info
4,8M ./.git/objects/pack
4,9M ./.git/objects
6,1M ./.git
16K ./examples/c
44K ./examples/pdf
32K ./examples/esc
512K ./examples
8,0K ./bin
20K ./utility/src
316K ./utility
548K ./template/theme/standard
552K ./template/theme
576K ./template
44K ./docs/Reference/Object
8,0K ./docs/Reference/Exception
60K ./docs/Reference
1,6M ./docs/utility/images
1,7M ./docs/utility
12K ./docs/benchmark
12K ./docs/spec/others
32K ./docs/spec/definition/native
96K ./docs/spec/definition
8,0K ./docs/spec/lib/function
40K ./docs/spec/lib/primitive
116K ./docs/spec/lib/basic
168K ./docs/spec/lib
100K ./docs/spec/statement/expression
180K ./docs/spec/statement
8,0K ./docs/spec/command
16K ./docs/spec/spectest
52K ./docs/spec/algorithm
536K ./docs/spec
100K ./docs/licenses
2,7M ./docs
12K ./.vscode
28K ./src/optimizer
80K ./src/extlib/onig/test
340K ./src/extlib/onig/m4
56K ./src/extlib/onig/sample/.deps
144K ./src/extlib/onig/sample
1,6M ./src/extlib/onig/autom4te.cache
76K ./src/extlib/onig/src
3,5M ./src/extlib/onig
68K ./src/extlib/kc-json/dist
72K ./src/extlib/kc-json
3,6M ./src/extlib
200K ./src/exec/code
204K ./src/exec
32K ./src/disasm/common
32K ./src/disasm/arch/mips
76K ./src/disasm/arch/x86
40K ./src/disasm/arch/arm
152K ./src/disasm/arch
24K ./src/disasm/gen
12K ./src/disasm/spec
292K ./src/disasm
408K ./src/disasm-x64/libudis86
416K ./src/disasm-x64
1,2M ./src/jit
6,7M ./src
24K ./lib/std/net
228K ./lib/std
8,0K ./lib/exec/3rdparty
84K ./lib/exec
316K ./lib
24K ./.github/workflows
28K ./.github
8,0K ./bucket
18M .
And this is with the original repository:
du -h
28K ./bench
264K ./include
16K ./.git/logs/refs/remotes/origin
20K ./.git/logs/refs/remotes
8,0K ./.git/logs/refs/heads
32K ./.git/logs/refs
40K ./.git/logs
8,0K ./.git/info
768K ./.git/filter-repo/analysis
772K ./.git/filter-repo
4,0K ./.git/branches
52K ./.git/hooks
8,0K ./.git/refs/tags
16K ./.git/refs/remotes/origin
20K ./.git/refs/remotes
8,0K ./.git/refs/heads
40K ./.git/refs
4,0K ./.git/objects/info
146M ./.git/objects/pack
146M ./.git/objects
147M ./.git
16K ./examples/c
44K ./examples/pdf
32K ./examples/esc
512K ./examples
8,0K ./bin
20K ./utility/src
316K ./utility
548K ./template/theme/standard
552K ./template/theme
576K ./template
44K ./docs/Reference/Object
8,0K ./docs/Reference/Exception
60K ./docs/Reference
1,6M ./docs/utility/images
1,7M ./docs/utility
12K ./docs/benchmark
12K ./docs/spec/others
32K ./docs/spec/definition/native
96K ./docs/spec/definition
8,0K ./docs/spec/lib/function
40K ./docs/spec/lib/primitive
116K ./docs/spec/lib/basic
168K ./docs/spec/lib
100K ./docs/spec/statement/expression
180K ./docs/spec/statement
8,0K ./docs/spec/command
16K ./docs/spec/spectest
52K ./docs/spec/algorithm
536K ./docs/spec
100K ./docs/licenses
2,7M ./docs
12K ./.vscode
28K ./src/optimizer
100K ./src/extlib/libssh2/include
2,0M ./src/extlib/libssh2/x64/gcc
344K ./src/extlib/libssh2/x64/vs2017
2,3M ./src/extlib/libssh2/x64
2,4M ./src/extlib/libssh2
32K ./src/extlib/ansicolor
528K ./src/extlib/libxml2/include/libxml2/libxml
532K ./src/extlib/libxml2/include/libxml2
536K ./src/extlib/libxml2/include
9,9M ./src/extlib/libxml2/x64/gcc
12M ./src/extlib/libxml2/x64/vs2017
22M ./src/extlib/libxml2/x64
22M ./src/extlib/libxml2
1,8M ./src/extlib/openssl/include/openssl
1,8M ./src/extlib/openssl/include
14M ./src/extlib/openssl/x64/gcc
7,2M ./src/extlib/openssl/x64/vs2017
21M ./src/extlib/openssl/x64
23M ./src/extlib/openssl
32K ./src/extlib/onig/windows
8,0K ./src/extlib/onig/cmake
252K ./src/extlib/onig/test
340K ./src/extlib/onig/m4
56K ./src/extlib/onig/sample/.deps
220K ./src/extlib/onig/sample
1,6M ./src/extlib/onig/autom4te.cache
2,4M ./src/extlib/onig/src
224K ./src/extlib/onig/doc
48K ./src/extlib/onig/harnesses
6,7M ./src/extlib/onig
264K ./src/extlib/libharu/include
2,7M ./src/extlib/libharu/x64/gcc
2,7M ./src/extlib/libharu/x64/vs2017
5,3M ./src/extlib/libharu/x64
5,6M ./src/extlib/libharu
8,9M ./src/extlib/sqlite
224K ./src/extlib/libcurl/include/curl
228K ./src/extlib/libcurl/include
1,6M ./src/extlib/libcurl/x64/gcc
1,8M ./src/extlib/libcurl/x64/vs2017
3,3M ./src/extlib/libcurl/x64
3,6M ./src/extlib/libcurl
68K ./src/extlib/kc-json/dist
36K ./src/extlib/kc-json/util
16K ./src/extlib/kc-json/sample
56K ./src/extlib/kc-json/src
248K ./src/extlib/kc-json
120K ./src/extlib/zip/include
884K ./src/extlib/zip/x64/gcc
748K ./src/extlib/zip/x64/vs2017
1,6M ./src/extlib/zip/x64
1,8M ./src/extlib/zip
68K ./src/extlib/winiconv
3,7M ./src/extlib/duktape
78M ./src/extlib
200K ./src/exec/code
204K ./src/exec
32K ./src/disasm/common
32K ./src/disasm/arch/mips
76K ./src/disasm/arch/x86
40K ./src/disasm/arch/arm
152K ./src/disasm/arch
24K ./src/disasm/gen
12K ./src/disasm/spec
292K ./src/disasm
408K ./src/disasm-x64/libudis86
416K ./src/disasm-x64
1,2M ./src/jit
81M ./src
24K ./lib/std/net
228K ./lib/std
8,0K ./lib/exec/3rdparty
84K ./lib/exec
316K ./lib
24K ./.github/workflows
28K ./.github
8,0K ./bucket
233M .
There is a condition which an comparison is failed.
It was good in the past, so the code seems to be broken somewhere.
function x(a) { return 10 <= a; }
System.println(x(10.5));
The fix will be also applied back to the 1.0.0.
_
is a placeholder of a function argument, but using it outside a function causes a crash.
This usage is not sense but it had better be fixed.
When I tried to compile this project on an ARM64 I noticed that it depends on executing the binary in utility/kmyacc that is only x86_64 for linux and windows.
So no other operating systems like OSX, ANDROID, FREEBSD, AIX, ...
If this is a limitation of this project I think that is a good idea to specify it clearly on the README.
From Kray-G/gitex#1
#16 で返信をする際に改めて native function を触っておりましたが、どうも native function 内で浮動小数の除算が行われると結果が不定になるようです。
以下、全て同じ実行環境で確認しています。
OS | CPU | Kinx |
---|---|---|
Windows 10 (2004) x64 | AMD Rizen 1600 | v0.8.1 |
function half(n) {
return n / 2;
}
native<int> nativeIntHalf(n: int) {
return n / 2;
}
native<dbl> nativeDblHalf(n: dbl) {
return n / 2;
}
System.println(half(4.5)); // 2.25
System.println(nativeIntHalf(4)); // 2
System.println(nativeDblHalf(4.5)); // 9.88131e-324 (?)
行を切り貼りして function call の順番を変えると 0
を出力したりします。
剰余算でも確認しました。加算・減算・乗算では特に問題が見受けられませんでした。
なお、別件となりますが native function 内で小数のリテラルを書くとエラーになります。
書くだけでエラーになります。呼び出す必要はありません。
native f() {
return 1.0; // Assertion failed at d:\a\kinx\kinx\src\jit/sljitLir.c:1411
}
これも別件になりますが通常関数に型宣言を書いてもエラーになりません。
(これは別に実害がないのでどうでもいいかもしれません)
// approved!
function addOne(n: int) {
const ONE: int = 1;
return n + ONE;
}
System.println(addOne(42)); // 43
It should be written.
We would like to use a current directory path easily.
System.println($pwd);
In the version 1.0.0, you can use System.cwd()
for this.
System.println(System.cwd());
This is a very basic functionality.
So I will port it back also to v1.0.x.
Sysrem
=> System
try {
return something();
} catch (e) {
error();
}
There is no output of POPC when using return
statement with expression in try statement without finally clause.
This may cause a crash by accessing invalid stack field when exception occurs.
I am looking for some language like this, thank you for making it opensource! It looks awesome!
As so far I have read, it seems the documentation has not mentioned how to define structure, anyway to do it?
Also is there a way to interact with C libraries or headers? And, does it have a pointer type?
REPL support.
Here is the list of items to realize it.
!10
..quit
to quit the editor..vars
to show the current held variables and its values..history
to show the history..showdef name
to show the defined function/class/module body..help
to display a small help..fullcode
to input a full code like -i
option..time
to measure the elapsed time..run
to run the code in .fullcode
mode.This is needed especially for an installation by scoop because scoop will only set the path to shim files.
実はこのエラー、fork した方の私のリポジトリでも(Kray-G/kinx/master
と htsign/kinx/master
に差異がないにも関わらず)再現したことがありました。
その際には _function
を function
に変えてスタックトレースを追ってみるとかいろいろやったのですが、知識不足もあり結局原因が分からず、リポジトリを一旦削除して作り直しています。
re-run jobs すると結果が変わることがあり(ジョブをキックする本来ユーザーから見えない .sh がコケていたりした) GitHub 側の問題も疑ってみましたが、今改めて私の方で git pull --rebase upstream master && git push
してみたところ、いきなり同じエラーでコケていたので、もしかしたら本当に kxstartup.kx
に問題があるのかもしれません。
もしくは私の yaml の書き方が悪く、ジョブ毎のタイミングが悪かったりしているのかも…。
Here is the code.
var a = 10;
var { x: ^a, y } = { x: 100, y: 100 };
System.println(y);
Here is a version of function arguments.
var a = 10;
function test({ x: ^a, y }) {
return y;
}
System.println(test({ x: 10, y: 100 }));
System.println(test({ x: 100, y: 100 }));
It is okay when it's an assignment statement.
There is no document about SAT solver as a new introduced feature.
SpecTest is needed.
For example, when you specify the file which doesn't exist.
File.open("no-file", File.READ) {};
The exception which is different from what we have expected occurs.
Uncaught exception: No one catch the exception.
SystemException: Method missing
Stack Trace Information:
at <main-block>((unknown):1)
What we expect is like this.
Uncaught exception: No one catch the exception.
FileException: File open failed: No such file or directory
Stack Trace Information:
at <main-block>((unknown):1)
I feel a read
/write
method is necessary in File
object to handle raw data as a binary, but there is not such a method so far.
提案です。
本リポジトリに多くのKinxライブラリが実装されていくにつれ、最後の引数にコールバック関数を取る関数が多く見られます。
これらは「関数を取る場合はそれが最後になる」という点で一貫しているように思えます。
そこで、「関数を最後に取る関数を呼び出すとき、最後に渡す関数はパーレンの外側に出せる」という構文規則を増やせないものでしょうか。
function f(a, b, fn) {
return fn(a, b);
}
# これを
const result1 = f(1, 2, &(a, b) => a + b);
System.println(result1); # 3
# こう書けるように
const result2 = f(1, 2) &(a, b) => a + b; # syntax error in current kinx
System.println(result2); # 3?
この考えは Swift や Kotlin, Nim などからヒントを得ています。
Ruby は外側にしかブロックを置けなかった(はず)なので参考から除外しています。
// Swift
func f<T>(_ a: T, _ b: T, fn: (T, T) -> T) -> T {
return fn(a, b)
}
let result1 = f(1, 2, fn: { $0 + $1 })
print(result1) // 3
// equivalent of above
let result2 = f(1, 2) { $0 + $1 }
print(result2) // 3
// Kotlin
fun <T> f(a: T, b: T, fn: (T, T) -> T) = fn(a, b)
fun main() {
val result1 = f(1, 2, { a, b -> a + b })
println(result1) // 3
// equivalent of above
val result2 = f(1, 2) { a, b -> a + b }
println(result2) // 3
}
上手く適用できると、読む側にとって優しいコードになれる可能性があります。
パーサー書く側にとっては辛くなりそうですが…。
There is no documentation of Isolate.
It should be added.
Hi,
kinx repl doesn't print non-ascii chars (Turkish), try to execute System.println('çÇşŞiİğĞüÜıI');
with kinx repl.
I created a simple hello.knx file and it still doesn't print Turkish letters.
Thanks
There is no method to copy files in File object.
There is no method to copy directories in Directory object as well.
試しにこのようなコードを書いていました。
よくある Option(Maybe) の簡易実装です。
class Option { }
class Some(value) : Option {
var NotFuncErr = RuntimeException("'fn' must be function type.");
public map(fn) {
throw NotFuncErr if (!fn.isFunction);
var next = fn(value);
return next.isUndefined ? Option.none : Option.some(next);
}
public filter(fn) {
throw NotFuncErr if (!fn.isFunction);
return fn(value).isUndefined ? Option.none : this;
}
public flatMap(fn) {
throw NotFuncErr if (!fn.isFunction);
var next = fn(value);
throw 'type mismatch' if (!next.instanceOf(Option));
return next;
}
public toString() {
return 'Some(%{value})';
}
public count() {
return 1;
}
public isSome() {
return true;
}
public isNone() {
return false;
}
}
class None : Option {
public map(_) {
return this;
}
public filter(_) {
return this;
}
public flatMap(_) {
return this;
}
public toString() {
return 'None';
}
public count() {
return 0;
}
public isSome() {
return false;
}
public isNone() {
return true;
}
}
Option.of = &(value) => value.isUndefined ? new None() : new Some(value);
Option.some = &(value) => new Some(value);
Option.none = new None();
その上で、
var opt = Option.of(3);
System.println(opt);
System.println(opt.toString());
としたとき、出力は
[...]
Some(3)
でした。
ここで、オブジェクトの文字列化について内部実装を拝見したところ、 kx_format
という関数を呼んでいるところまでは分かったのですが、勉強不足ゆえそれ以後の処理を追いきれませんでした。
objval->type != KX_OBJ_T
を満たしたら [...]
になりそう、というのはなんとなく分かりました。
というのを踏まえた上で、クラスなどの独自オブジェクトについて文字列化を行うときの規則を制御する方法はあるのでしょうか。
It seems to be a problem in optimization.
Here is the code.
function test1(data) {
var [a, b, ...c] = data.split(',');
}
function test2(data) {
[a, b, ...c] = data.split(',');
}
function test3(data) {
const [a, b, ...c] = data.split(',');
}
Only test3
is failed with raising an exception. The cause is that the bytecode is different from other 2 functions.
The bytecode is below.
test1: (unknown)(1 - 3)
.L2997
35a3: enter 21, vars(4), args(1)
35a4: pushs ","
35a5: pushvl0 $0(0)
35a6: calls "split", 1
35a7: pushlv $0(1)
35a8: getaryv 0
35a9: pushlv $0(2)
35aa: getaryv 1
35ab: pushlv $0(3)
35ac: getarya 2
35ad: pop
35ae: ret null
35af: halt
test2: (unknown)(4 - 6)
.L2998
35b0: enter 21, vars(4), args(1)
35b1: pushs ","
35b2: pushvl0 $0(0)
35b3: calls "split", 1
35b4: pushlv $0(1)
35b5: getaryv 0
35b6: pushlv $0(2)
35b7: getaryv 1
35b8: pushlv $0(3)
35b9: getarya 2
35ba: pop
35bb: ret null
35bc: halt
test3: (unknown)(7 - 9)
.L2999
35bd: enter 21, vars(4), args(1)
35be: pushs ","
35bf: pushvl0 $0(0)
35c0: calls "split", 1
35c1: dup
35c2: applyvi 0
35c3: pushvl0 $0(1)
35c4: eqeq
35c5: throwifz NoMatchingPatternException
35c6: dup
35c7: applyvi 1
35c8: pushvl0 $0(2)
35c9: eqeq
35ca: throwifz NoMatchingPatternException
35cb: pushlv $0(3)
35cc: getarya 2
35cd: pop
35ce: ret null
35cf: halt
I found this project in the explore section and found it to be way too interesting. So the question here is, what can i do with kinx as it is not mentioned in the documentation?
Hi,
Is it possible to link kinx as a static library and executable?
Thanks
Especially for Linux.
We would like to use it like this.
Directory.change("dirname") {
// do something under the directory of "dirname".
};
FYI, This can be also written below as JavaScript-like in Kinx.
The meaning is exactly same.
Directory.change("dirname", function() {
// do something under the directory of "dirname".
});
This is a very basic functionality.
So I will port it back also to v1.0.x.
ctx
shouldn't be used after cleanup in mainlib.c
.
Adding -g
to CFLAGS, building kinx and running it under valgrind we get this output:
valgrind --track-origins=yes ../kinx fib.kx
==2199== Memcheck, a memory error detector
==2199== Copyright (C) 2002-2017, and GNU GPL'd, by Julian Seward et al.
==2199== Using Valgrind-3.16.1 and LibVEX; rerun with -h for copyright info
==2199== Command: /home/mingo/dev/c/A_programming-languages/kinx/kinx fib.kx
==2199==
==2199== Conditional jump or move depends on uninitialised value(s)
==2199== at 0x4C3571F: __strncpy_sse2_unaligned (vg_replace_strmem.c:553)
==2199== by 0x108FBA: strncpy (string_fortified.h:106)
==2199== by 0x108FBA: get_kinx_path (fileutil.c:297)
==2199== by 0x108CBB: load_kinx_dll (libkinx.h:134)
==2199== by 0x108CBB: kinx_call_main (libkinx.h:185)
==2199== by 0x108CBB: main (main.c:18)
==2199== Uninitialised value was created by a stack allocation
==2199== at 0x108F3A: get_kinx_path (fileutil.c:290)
==2199==
==2199== Conditional jump or move depends on uninitialised value(s)
==2199== at 0x4C3571F: __strncpy_sse2_unaligned (vg_replace_strmem.c:553)
==2199== by 0x593E5BA: strncpy (string_fortified.h:106)
==2199== by 0x593E5BA: get_kinx_path (fileutil.c:297)
==2199== by 0x593E978: kxlib_file_exists_no_current (loadlib.c:112)
==2199== by 0x593DEBF: load_using_module (lexer.c:100)
==2199== by 0x593BB5A: process_using (lexer.c:145)
==2199== by 0x593BB5A: get_keyword_token (lexer.c:250)
==2199== by 0x593BB5A: kx_yylex (lexer.c:987)
==2199== by 0x5941243: kx_yyparse (kmyacc.c.parser:330)
==2199== by 0x58F0190: eval (ir_util.c:401)
==2199== by 0x58F4BFF: eval_file (ir_util.c:482)
==2199== by 0x594024E: do_main (mainlib.c:306)
==2199== by 0x108C9D: kinx_call_main (libkinx.h:198)
==2199== by 0x108C9D: main (main.c:18)
==2199== Uninitialised value was created by a stack allocation
==2199== at 0x593E53A: get_kinx_path (fileutil.c:290)
==2199==
==2199== Conditional jump or move depends on uninitialised value(s)
==2199== at 0x4C3571F: __strncpy_sse2_unaligned (vg_replace_strmem.c:553)
==2199== by 0x834E73A: strncpy (string_fortified.h:106)
==2199== by 0x834E73A: get_actual_exe_path (fileutil.c:314)
==2199== by 0x833D765: System_exepath (kxsystem.c:1626)
==2199== by 0x58E7F43: ir_exec_impl (ir_exec.inl:27)
==2199== by 0x58EF976: ir_exec (ir_exec.inl:284)
==2199== by 0x594043A: do_main (mainlib.c:379)
==2199== by 0x108C9D: kinx_call_main (libkinx.h:198)
==2199== by 0x108C9D: main (main.c:18)
==2199== Uninitialised value was created by a stack allocation
==2199== at 0x834E6C1: get_actual_exe_path (fileutil.c:307)
==2199==
==2199== Conditional jump or move depends on uninitialised value(s)
==2199== at 0x4C3571F: __strncpy_sse2_unaligned (vg_replace_strmem.c:553)
==2199== by 0x834E42A: strncpy (string_fortified.h:106)
==2199== by 0x834E42A: get_kinx_path (fileutil.c:297)
==2199== by 0x833D685: System_kinxpath (kxsystem.c:1614)
==2199== by 0x58E7F43: ir_exec_impl (ir_exec.inl:27)
==2199== by 0x58EF976: ir_exec (ir_exec.inl:284)
==2199== by 0x594043A: do_main (mainlib.c:379)
==2199== by 0x108C9D: kinx_call_main (libkinx.h:198)
==2199== by 0x108C9D: main (main.c:18)
==2199== Uninitialised value was created by a stack allocation
==2199== at 0x834E3AA: get_kinx_path (fileutil.c:290)
==2199==
==2199== Conditional jump or move depends on uninitialised value(s)
==2199== at 0x4C3571F: __strncpy_sse2_unaligned (vg_replace_strmem.c:553)
==2199== by 0x834E442: strncpy (string_fortified.h:106)
==2199== by 0x834E442: setup_actual_exe_path (fileutil.c:51)
==2199== by 0x834E442: get_kinx_path (fileutil.c:298)
==2199== by 0x833D685: System_kinxpath (kxsystem.c:1614)
==2199== by 0x58E7F43: ir_exec_impl (ir_exec.inl:27)
==2199== by 0x58EF976: ir_exec (ir_exec.inl:284)
==2199== by 0x594043A: do_main (mainlib.c:379)
==2199== by 0x108C9D: kinx_call_main (libkinx.h:198)
==2199== by 0x108C9D: main (main.c:18)
==2199== Uninitialised value was created by a stack allocation
==2199== at 0x834E3AA: get_kinx_path (fileutil.c:290)
==2199==
==2199== Conditional jump or move depends on uninitialised value(s)
==2199== at 0x4C34C38: rindex (vg_replace_strmem.c:200)
==2199== by 0x834E453: setup_actual_exe_path (fileutil.c:59)
==2199== by 0x834E453: get_kinx_path (fileutil.c:298)
==2199== by 0x833D685: System_kinxpath (kxsystem.c:1614)
==2199== by 0x58E7F43: ir_exec_impl (ir_exec.inl:27)
==2199== by 0x58EF976: ir_exec (ir_exec.inl:284)
==2199== by 0x594043A: do_main (mainlib.c:379)
==2199== by 0x108C9D: kinx_call_main (libkinx.h:198)
==2199== by 0x108C9D: main (main.c:18)
==2199== Uninitialised value was created by a stack allocation
==2199== at 0x834E3AA: get_kinx_path (fileutil.c:290)
==2199==
==2199== Conditional jump or move depends on uninitialised value(s)
==2199== at 0x834E457: setup_actual_exe_path (fileutil.c:60)
==2199== by 0x834E457: get_kinx_path (fileutil.c:298)
==2199== by 0x833D685: System_kinxpath (kxsystem.c:1614)
==2199== by 0x58E7F43: ir_exec_impl (ir_exec.inl:27)
==2199== by 0x58EF976: ir_exec (ir_exec.inl:284)
==2199== by 0x594043A: do_main (mainlib.c:379)
==2199== by 0x108C9D: kinx_call_main (libkinx.h:198)
==2199== by 0x108C9D: main (main.c:18)
==2199== Uninitialised value was created by a stack allocation
==2199== at 0x834E3AA: get_kinx_path (fileutil.c:290)
==2199==
==2199== Use of uninitialised value of size 8
==2199== at 0x834E459: setup_actual_exe_path (fileutil.c:60)
==2199== by 0x834E459: get_kinx_path (fileutil.c:298)
==2199== by 0x833D685: System_kinxpath (kxsystem.c:1614)
==2199== by 0x58E7F43: ir_exec_impl (ir_exec.inl:27)
==2199== by 0x58EF976: ir_exec (ir_exec.inl:284)
==2199== by 0x594043A: do_main (mainlib.c:379)
==2199== by 0x108C9D: kinx_call_main (libkinx.h:198)
==2199== by 0x108C9D: main (main.c:18)
==2199== Uninitialised value was created by a stack allocation
==2199== at 0x834E3AA: get_kinx_path (fileutil.c:290)
==2199==
==2199== Conditional jump or move depends on uninitialised value(s)
==2199== at 0x834E47E: setup_actual_exe_path (fileutil.c:61)
==2199== by 0x834E47E: get_kinx_path (fileutil.c:298)
==2199== by 0x833D685: System_kinxpath (kxsystem.c:1614)
==2199== by 0x58E7F43: ir_exec_impl (ir_exec.inl:27)
==2199== by 0x58EF976: ir_exec (ir_exec.inl:284)
==2199== by 0x594043A: do_main (mainlib.c:379)
==2199== by 0x108C9D: kinx_call_main (libkinx.h:198)
==2199== by 0x108C9D: main (main.c:18)
==2199== Uninitialised value was created by a stack allocation
==2199== at 0x834E3AA: get_kinx_path (fileutil.c:290)
==2199==
==2199== Use of uninitialised value of size 8
==2199== at 0x834E4B5: strcpy (string_fortified.h:90)
==2199== by 0x834E4B5: setup_actual_exe_path (fileutil.c:62)
==2199== by 0x834E4B5: get_kinx_path (fileutil.c:298)
==2199== by 0x833D685: System_kinxpath (kxsystem.c:1614)
==2199== by 0x58E7F43: ir_exec_impl (ir_exec.inl:27)
==2199== by 0x58EF976: ir_exec (ir_exec.inl:284)
==2199== by 0x594043A: do_main (mainlib.c:379)
==2199== by 0x108C9D: kinx_call_main (libkinx.h:198)
==2199== by 0x108C9D: main (main.c:18)
==2199== Uninitialised value was created by a stack allocation
==2199== at 0x834E3AA: get_kinx_path (fileutil.c:290)
==2199==
==2199== Syscall param stat(file_name) points to uninitialised byte(s)
==2199== at 0x5151845: _xstat (xstat.c:35)
==2199== by 0x834E329: stat (stat.h:451)
==2199== by 0x834E329: file_exists (fileutil.c:277)
==2199== by 0x834E4C3: setup_actual_exe_path (fileutil.c:63)
==2199== by 0x834E4C3: get_kinx_path (fileutil.c:298)
==2199== by 0x833D685: System_kinxpath (kxsystem.c:1614)
==2199== by 0x58E7F43: ir_exec_impl (ir_exec.inl:27)
==2199== by 0x58EF976: ir_exec (ir_exec.inl:284)
==2199== by 0x594043A: do_main (mainlib.c:379)
==2199== by 0x108C9D: kinx_call_main (libkinx.h:198)
==2199== by 0x108C9D: main (main.c:18)
==2199== Address 0x85aead3 is 51 bytes inside data symbol "exe_full_path.4920"
==2199== Uninitialised value was created by a stack allocation
==2199== at 0x834E3AA: get_kinx_path (fileutil.c:290)
==2199==
==2199== Use of uninitialised value of size 8
==2199== at 0x834E690: strcpy (string_fortified.h:90)
==2199== by 0x834E690: setup_actual_exe_path (fileutil.c:64)
==2199== by 0x834E690: get_kinx_path (fileutil.c:298)
==2199== by 0x833D685: System_kinxpath (kxsystem.c:1614)
==2199== by 0x58E7F43: ir_exec_impl (ir_exec.inl:27)
==2199== by 0x58EF976: ir_exec (ir_exec.inl:284)
==2199== by 0x594043A: do_main (mainlib.c:379)
==2199== by 0x108C9D: kinx_call_main (libkinx.h:198)
==2199== by 0x108C9D: main (main.c:18)
==2199== Uninitialised value was created by a stack allocation
==2199== at 0x834E3AA: get_kinx_path (fileutil.c:290)
==2199==
==2199== Syscall param stat(file_name) points to uninitialised byte(s)
==2199== at 0x5151845: _xstat (xstat.c:35)
==2199== by 0x834E329: stat (stat.h:451)
==2199== by 0x834E329: file_exists (fileutil.c:277)
==2199== by 0x834E4D7: setup_actual_exe_path (fileutil.c:67)
==2199== by 0x834E4D7: get_kinx_path (fileutil.c:298)
==2199== by 0x833D685: System_kinxpath (kxsystem.c:1614)
==2199== by 0x58E7F43: ir_exec_impl (ir_exec.inl:27)
==2199== by 0x58EF976: ir_exec (ir_exec.inl:284)
==2199== by 0x594043A: do_main (mainlib.c:379)
==2199== by 0x108C9D: kinx_call_main (libkinx.h:198)
==2199== by 0x108C9D: main (main.c:18)
==2199== Address 0x85aead3 is 51 bytes inside data symbol "exe_full_path.4920"
==2199== Uninitialised value was created by a stack allocation
==2199== at 0x834E3AA: get_kinx_path (fileutil.c:290)
==2199==
==2199== Conditional jump or move depends on uninitialised value(s)
==2199== at 0x4C34C38: rindex (vg_replace_strmem.c:200)
==2199== by 0x834E4EC: get_kinx_path (fileutil.c:299)
==2199== by 0x833D685: System_kinxpath (kxsystem.c:1614)
==2199== by 0x58E7F43: ir_exec_impl (ir_exec.inl:27)
==2199== by 0x58EF976: ir_exec (ir_exec.inl:284)
==2199== by 0x594043A: do_main (mainlib.c:379)
==2199== by 0x108C9D: kinx_call_main (libkinx.h:198)
==2199== by 0x108C9D: main (main.c:18)
==2199== Uninitialised value was created by a stack allocation
==2199== at 0x834E3AA: get_kinx_path (fileutil.c:290)
==2199==
==2199== Conditional jump or move depends on uninitialised value(s)
==2199== at 0x834E4F0: get_kinx_path (fileutil.c:300)
==2199== by 0x833D685: System_kinxpath (kxsystem.c:1614)
==2199== by 0x58E7F43: ir_exec_impl (ir_exec.inl:27)
==2199== by 0x58EF976: ir_exec (ir_exec.inl:284)
==2199== by 0x594043A: do_main (mainlib.c:379)
==2199== by 0x108C9D: kinx_call_main (libkinx.h:198)
==2199== by 0x108C9D: main (main.c:18)
==2199== Uninitialised value was created by a stack allocation
==2199== at 0x834E3AA: get_kinx_path (fileutil.c:290)
==2199==
==2199== Use of uninitialised value of size 8
==2199== at 0x834E4F6: get_kinx_path (fileutil.c:300)
==2199== by 0x833D685: System_kinxpath (kxsystem.c:1614)
==2199== by 0x58E7F43: ir_exec_impl (ir_exec.inl:27)
==2199== by 0x58EF976: ir_exec (ir_exec.inl:284)
==2199== by 0x594043A: do_main (mainlib.c:379)
==2199== by 0x108C9D: kinx_call_main (libkinx.h:198)
==2199== by 0x108C9D: main (main.c:18)
==2199== Uninitialised value was created by a stack allocation
==2199== at 0x834E3AA: get_kinx_path (fileutil.c:290)
==2199==
==2199== Conditional jump or move depends on uninitialised value(s)
==2199== at 0x4C35108: strlen (vg_replace_strmem.c:459)
==2199== by 0x8351214: ks_append (kstr.c:187)
==2199== by 0x833D690: System_kinxpath (kxsystem.c:1615)
==2199== by 0x58E7F43: ir_exec_impl (ir_exec.inl:27)
==2199== by 0x58EF976: ir_exec (ir_exec.inl:284)
==2199== by 0x594043A: do_main (mainlib.c:379)
==2199== by 0x108C9D: kinx_call_main (libkinx.h:198)
==2199== by 0x108C9D: main (main.c:18)
==2199== Uninitialised value was created by a stack allocation
==2199== at 0x834E3AA: get_kinx_path (fileutil.c:290)
==2199==
==2199== Conditional jump or move depends on uninitialised value(s)
==2199== at 0x4C34FD8: strncat (vg_replace_strmem.c:349)
==2199== by 0x83511C4: strncat (string_fortified.h:136)
==2199== by 0x83511C4: ks_append_n (kstr.c:208)
==2199== by 0x83511C4: ks_append_n (kstr.c:195)
==2199== by 0x833D690: System_kinxpath (kxsystem.c:1615)
==2199== by 0x58E7F43: ir_exec_impl (ir_exec.inl:27)
==2199== by 0x58EF976: ir_exec (ir_exec.inl:284)
==2199== by 0x594043A: do_main (mainlib.c:379)
==2199== by 0x108C9D: kinx_call_main (libkinx.h:198)
==2199== by 0x108C9D: main (main.c:18)
==2199== Uninitialised value was created by a stack allocation
==2199== at 0x834E3AA: get_kinx_path (fileutil.c:290)
==2199==
fib(34) = 9227465
==2199==
==2199== HEAP SUMMARY:
==2199== in use at exit: 498,201 bytes in 2,970 blocks
==2199== total heap usage: 37,100 allocs, 34,130 frees, 37,060,116 bytes allocated
==2199==
==2199== LEAK SUMMARY:
==2199== definitely lost: 493,216 bytes in 2,956 blocks
==2199== indirectly lost: 0 bytes in 0 blocks
==2199== possibly lost: 0 bytes in 0 blocks
==2199== still reachable: 4,985 bytes in 14 blocks
==2199== suppressed: 0 bytes in 0 blocks
==2199== Rerun with --leak-check=full to see details of leaked memory
==2199==
==2199== For lists of detected and suppressed errors, rerun with: -s
==2199== ERROR SUMMARY: 301 errors from 18 contexts (suppressed: 0 from 0)
In the following conditions, the bytecode does not be outputted unfortunately.
Then, the code generator will remove the code because it is a constant and it assumed to be propagated.
A constant folding is done first before analyzing AST.
After that, analyzing AST will propagate a constant to variables referencing it.
The problem is that a constant folding is done again after analyzing AST.
If the const variable becomes a constant value in the 2nd constant folding phase, the code generator will omit to generate a code even though it has not been propagated.
In the following code, N
can be removed because a variable which references it will use directly 3
as a constant. On the other hand, R
will be removed but it is a problem because the number 9
has not been correctly propagated yet.
const X = 10;
const Y = X + X;
System.println(Y);
It displays nothing.
const
by var
, orconst Y = 20;
directly, orvar YY = X + X; const Y = YY;
, if you want Y
to be const
and to calculate Y
by X
.about "Here Document" in readme.md.
I think it is a literal of a string, not a here document.
Almost 'Here Document' is separated of the code line, like as follows.
var a = %{HEREDOC}.trim();
This is here documen.
New line is available in this area.
HEREDOC
And I don't think 'Here Document' is necessary...
It was found by a source code review.
Currently the operator[]
in Range
will do toArray()
first, but by this it is impossible to deal with an infinite range.
Kinx でプログラムを組むにあたり、ドキュメントコメントはどういった方針がよいのでしょう?
特に型については是非ともコメントに書いておきたい、という気持ちがあります。
(まずそもそもドキュメントコメントを言語仕様に含めるのかどうかという疑問もあります)
/**
* ブロックコメントを使うスタイル (JS, Java など)
* @param {Array<Integer>} xs - values
* @returns {Integer} sum
*/
function sum(xs) {
return xs.reduce(&(acc, x) => acc + x, 0);
}
%{
docstring (Python など)
Parameters
----------
xs : Array<Integer>
values
Returns
-------
sumValue : Integer
sum
}
function sum(xs) {
return xs.reduce(&(acc, x) => acc + x, 0);
}
# コードに埋めこむスタイル
/* Integer */ function sum(/* Array<Integer> */ xs) {
return xs.reduce(&(acc, x) => acc + x, 0);
}
またはその他。
便宜上配列の型を Array<T>
で表記しましたが、これも Array[A]
(Scala, Nim など) とか [T]
(Swift, Haskell など) とか 'a array
(OCaml など) とか T[]
(TypeScript での別表記) とかいろいろあります。
It should be documented.
Package Manager is important for ecosystem of development.
The following items are postponed to V1.2.0.
See #338 for details.
The remaining tasks to release V1.1.0 are as follows.
Hello, does the kinx language have IDE or CLI compiler for development environment?
Here is the reasons.
Look at this.
class A {
public toString() { return "A"; }
}
System.println({ a: new A() }); // => {"a":A}
A
is invalid as a JSON, and it should be "A"
.
Here is an example to be failed.
function gt(a, b) { return a > b; }
function lt(a, b) { return a < b; }
function ge(a, b) { return a >= b; }
function le(a, b) { return a <= b; }
function lge(a, b) { return a <=> b; } // will be successful.
try { gt("a", "b"); } catch (e) { System.println(e.what()); }
try { lt("a", "b"); } catch (e) { System.println(e.what()); }
try { ge("a", "b"); } catch (e) { System.println(e.what()); }
try { le("a", "b"); } catch (e) { System.println(e.what()); }
try { lge("a", "b"); } catch (e) { System.println(e.what()); } // nothing's displayed.
It is okay when comparing two strings directly.
System.println("a" > "b");
Is your feature request related to a problem? Please describe.
This repository is too big. I want to shrink it.
Describe the solution you'd like
Move files under src/extlib/
to another repository.
Describe alternatives you've considered
No idea.
Additional context
The purpose is to shrink this repository, so I think this should be done for all branches.
And this request is related to #180.
Here are what I should write.
The following code causes a problem of a segmentation fault on Linux.
var t = $env.NO_ENVVAR;
There is no problem on Windows.
Debugger can't recognize Functional
as below.
> v Functional
>>> Error: Variable(F) not found
When using the operator of =~
or !~
, the stack is not used cleanly.
It causes a stack overflow after a lot of operations by those operator like in a loop.
This should be also applied to v1.0.2 as a back port.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.