Skip to content

Commit

Permalink
Merge pull request #259 from /issues/232/packagemanager
Browse files Browse the repository at this point in the history
#232: 1st merge for Package Manager.
  • Loading branch information
Kray-G committed Mar 31, 2021
2 parents 5cda6d0 + 642a9f4 commit 7d7ca22
Show file tree
Hide file tree
Showing 31 changed files with 744 additions and 118 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -54,3 +54,4 @@ TEMP*
/*.so*
/TEST.md
/*.deb
/lib/package
5 changes: 4 additions & 1 deletion ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,20 @@
* New Features
* Supported SAT solver by picosat.
* Supported SemanticVersion class.
* Improvements
* Improvements/Enhancements
* Supported putting a comma at the end of an argument's list for both declaration and calling.
* Supported the operator of `==` and `!=` in Boolean class.
* Supported `String#isIntegerString`.
* Shared an implementation of conversion for a string, an integer, and a double.
* Improved type analysis for the language server.
* SpecTest: Made a space wider of Test case number.
* #255: Improved the `operator[]` in `Range`.
* Bug Fixed
* #235: Crash when using `_` outside a function.
* #236: Can't specify the class as a return type of function.
* #237: Comparing between variables having a string is failed.
* #256: Comparison operator will be failed with an integer on LHS and a variable(double) on RHS.
* #257: Fails a destructuring assignment when declaration with const.

## V1.0.0 (Official Release) - 2021/03/16
This is a 1st official release version.
Expand Down
2 changes: 2 additions & 0 deletions ChangeLog_v1.0.x.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
* #235: Crash when using `_` outside a function.
* #236: Can't specify the class as a return type of function.
* #237: Comparing between variables having a string is failed.
* #256: Comparison operator will be failed with an integer on LHS and a variable(double) on RHS.
* #257: Fails a destructuring assignment when declaration with const.

## V1.0.0 (Official Release) - 2021/03/16

Expand Down
2 changes: 1 addition & 1 deletion build/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ all: timex kinx $(SOFILES) main_kxcmd
install:
mkdir -p /usr/bin/kinxlib/include
mkdir -p /usr/bin/kinxlib/docs/licenses
mkdir -p /usr/bin/kinxlib/exec/3rdparty
mkdir -p /usr/bin/kinxlib/package
cp -f ./kinx /usr/bin/kinx
cp -f ./kxrepl /usr/bin/kxrepl
cp -f ./kxtest /usr/bin/kxtest
Expand Down
3 changes: 2 additions & 1 deletion build/template/install.nsi
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,11 @@ Section
File /r /x ".gitignore" "lib\webview"

SetOutPath "$INSTDIR\docs"
File /r /x "typesetting" "docs\licenses"
File /r "docs\licenses"

# Uninstaller
WriteUninstaller "$INSTDIR\Uninstall.exe"
CreateDirectory "$INSTDIR\bin\lib\package"

# Shortcut to start menu
CreateDirectory "$SMPROGRAMS\Kinx"
Expand Down
95 changes: 90 additions & 5 deletions docs/spec/lib/basic/range.md
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ out of range (9)
out of range (10)
```

### Example 5. Range for Switch-Case (2)
### Example 6. Range for Switch-Case (2)

#### Code

Expand Down Expand Up @@ -224,7 +224,7 @@ okay 1 (ae)
out of range (af)
```

### Example 6. Range for String
### Example 7. Range for String

Range for String means to return a part of string between the start and the end of `Range`.
It is like `String#subString()` but note that `String#subString()` requires a length.
Expand All @@ -246,7 +246,7 @@ cdefghijklmnopqrstuvwxy
cdefghijklmnopqrstuvwxy
```

### Example 7. Range for Array
### Example 8. Range for Array

Range for Array means to return a part of array between the start and the end of `Range`.
It is like `Array#subArray()` but note that `Array#subArray()` requires a length.
Expand All @@ -268,7 +268,7 @@ System.println(ary.subArray(2, 10)); // [2, 3, 4, 5, 6, 7, 8, 9, 10, 11]
[2, 3, 4, 5, 6, 7, 8, 9, 10, 11]
```

### Example 8. Range for Binary
### Example 9. Range for Binary

Range for Binary means to return a part of binary between the start and the end of `Range`.
It is like `Binary#subBinary()` but note that `Binary#subBinary()` requires a length.
Expand All @@ -290,7 +290,7 @@ System.println(bin.subBinary(2, 10)); // <0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x
<0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b>
```

### Example 9. Range for Range
### Example 10. Range for Range

Range for Range means to return parts between the start and the end by `Range` at the index.

Expand All @@ -308,3 +308,88 @@ System.println(range[2...12]); // [2, 3, 4, 5, 6, 7, 8, 9, 10, 11]
[2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]
[2, 3, 4, 5, 6, 7, 8, 9, 10, 11]
```

### Example 11. Infinite Range (Range Index)

Range for Range means to return parts between the start and the end by `Range` at the index.

#### Code

```javascript
var range = 0..;
System.println(range[2..12]); // [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]
System.println(range[2...12]); // [2, 3, 4, 5, 6, 7, 8, 9, 10, 11]
```

#### Result

```
[2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]
[2, 3, 4, 5, 6, 7, 8, 9, 10, 11]
```

### Example 12. Infinite Range (Integer Index)

Range for Range means to return parts between the start and the end by `Range` at the index.

#### Code

```javascript
var range = 1..;
System.println(range[2]); // 3
System.println(range[22]); // 23
System.println(range[1050]); // 1051
```

#### Result

```
3
23
1051
```

### Example 13. Range for Range (Infinite Range Index 1)

Range for Range means to return parts between the start and the end by `Range` at the index.

#### Code

```javascript
System.println((1..10)[2..]); // 3..10
System.println((1...10)[2..]); // 3...10
System.println((100..)[2..]); // 102..
```

#### Result

```
Range(3, 10, false)
Range(3, 10, true)
Range(102, null, false)
```

### Example 14. Range for Range (Infinite Range Index 2)

Range for Range means to return parts between the start and the end by `Range` at the index.

#### Code

```javascript
var range = (1...10)[2..];
for (e in range) {
System.println(e);
}
```

#### Result

```
3
4
5
6
7
8
9
```
63 changes: 61 additions & 2 deletions docs/spec/others/bugfixes.md
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ for (ypix in 0...24) {
: ......------------------------::::::::::;;;;+==x& &x=+;;;::::::-------.
```

### Example 3. Comparing between variables of a string.
### Example 3. Comparing between variables of a string

This bug's was caused by missing implementation.

Expand Down Expand Up @@ -127,7 +127,7 @@ Successful
Successful
```

### Example 4. Can't specify a return type of function.
### Example 4. Can't specify a return type of function

This bug's was caused by lack of consideration of a part of type propagation.

Expand Down Expand Up @@ -155,3 +155,62 @@ f().xxx();
```
Successful
```

### Example 5. Comparison Failure & Crash

This bug's was caused by lack of the code which moves to the next opcode.

* Issue: [#256](https://github.com/Kray-G/kinx/issues/256)
* Fixed: [bf1b5ba926db08a69a5c6786d7557f9f6d7e420f](https://github.com/Kray-G/kinx/commit/bf1b5ba926db08a69a5c6786d7557f9f6d7e420f)

#### Code

```javascript
function test1(a) { return 10 >= a; }
function test2(a) { return -1 <= a; }
function test3(a) { return 100 < a; }

System.println(test1(10.5));
System.println(test2(10.5));
System.println(test3(10.5));
```

#### Result

```
0
1
0
```

### Example 6. Fails a Destructuring Assignment in Const

This bug's was caused by an incorrect bytecode.

* Issue: [#257](https://github.com/Kray-G/kinx/issues/257)
* Fixed: [43d82765b577221c820575b7f5e7323cc0171be1](https://github.com/Kray-G/kinx/commit/43d82765b577221c820575b7f5e7323cc0171be1)

#### Code

```javascript
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(',');
}
test1("1,2,3,4,5,6,7,8,9");
test2("1,2,3,4,5,6,7,8,9");
test3("1,2,3,4,5,6,7,8,9");

System.println("Successful");
```

#### Result

```
Successful
```
55 changes: 55 additions & 0 deletions examples/sat2.kx
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
using SatisfiablitySolver;

var vs = new VersionSatisfiablity();

var X = vs.addProduct("X")
.addVersion("0.0.1", true);
var A = vs.addProduct("A")
.addVersion("0.0.1")
.addVersion("0.0.2");
var B = vs.addProduct("B")
.addVersion("0.0.1")
.addVersion("0.0.2");
var Z = vs.addProduct("Z")
.addVersion("0.0.1")
.addVersion("0.0.2");

function msg(a) {
if (a.not) {
return ("%1% is NOT v%2%" % a.value.name % a.value.version).format();
} else {
return ("%1% is v%2%" % a.value.name % a.value.version).format();
}
}
function error(item) {
switch (item.length()) {
when 1:
System.println("- ", msg(item[0]));
when 2:
item[0].not = !item[0].not; // (!A || B) means (A => B)
System.println("- ", msg(item[0]), " => ", msg(item[1]));
else:
System.println("- ", item.map { => msg(_1) }.join(', or\n '));
}
}

function tryit() {
var count = 0;
for (var e in vs) {
System.println("%d: " % ++count, e.toJsonString(true));
}
if (count == 0) {
System.println("Unsatisfiable - Conflict here");
vs.getConflict().each { => error(_1) };
}
}

A("0.0.1").dependsOn(Z("0.0.1"));
A("0.0.2").dependsOn(Z("0.0.2"));

B("0.0.1").dependsOn(Z("0.0.1"));
B("0.0.2").dependsOn(Z("0.0.2"));

X("0.0.1").dependsOn(A("0.0.2"));
X("0.0.1").dependsOn(B("0.0.1"));
tryit();
2 changes: 1 addition & 1 deletion include/ir.h
Original file line number Diff line number Diff line change
Expand Up @@ -883,7 +883,7 @@ typedef struct kx_options_ {
int output_location:1;
int src_stdin:1;
int utf8inout:1;
int native_verbose:1;
int verbose:1;
int with_native:1; /* dump with native */
int exception_detail_info:1;
int debug_mode:1;
Expand Down
3 changes: 2 additions & 1 deletion include/kinx.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,9 @@ typedef struct kx_lexinfo_ {
int is_trim;
kx_lexinner_t inner;
kx_yyin_t in;
int tempbuf[16];
const char *pkgkey;
const int *restart;
int tempbuf[16];
} kx_lexinfo_t;
kvec_init_t(kx_lexinfo_t);

Expand Down
1 change: 1 addition & 0 deletions include/kxastobject.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ extern kx_object_t *kx_gen_str_object_pos(name_t name);
extern const char *kx_gen_constant_string(const char *name);
extern const char *kx_check_the_name(kx_object_t *obj);
extern kx_object_t *kx_gen_stmtlist(kx_object_t *lhs, kx_object_t *rhs);
extern kx_object_t *kx_gen_exprlist(kx_object_t *lhs, kx_object_t *rhs);
extern kx_object_t *kx_gen_range_object(kx_object_t *start, kx_object_t *end, int include_end);
extern kx_object_t *kx_gen_case_when_object(kx_object_t *decl, kx_object_t *expr, kx_object_t *modifier);
extern kx_object_t *kx_gen_forin_object(kx_object_t *var, kx_object_t *range, kx_object_t *stmt, int is_decl);
Expand Down
17 changes: 17 additions & 0 deletions include/parser.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,27 @@

#include <stdint.h>
#include <kinx.h>
#include <khash.h>

typedef struct package_t_ {
const char *vers;
struct package_t_ *next;
} package_t;
KHASH_MAP_INIT_STR(package, package_t *)

typedef struct name_t_ {
const char *name;
int line;
int pos1;
int pos2;
} name_t;

typedef struct arytype_t_ {
int type;
int depth;
const char *name; /* class name */
} arytype_t;

typedef struct named_stmt_ {
const char *name; /* class name */
kx_object_t *stmt;
Expand All @@ -25,4 +34,12 @@ typedef struct named_stmt_ {
#include <parser.tab.h>
#endif /* KX_PARSER */

extern int kx_trace_fmt(kx_context_t *ctx, int nested, const char *fmt, ...);
#define kx_trace(ctx, nested, ...) do {\
if (ctx->options.verbose) { \
kx_trace_fmt(ctx, nested, __VA_ARGS__);\
} \
} while (0); \
/**/

#endif /* KX_PARSER_H */
Loading

0 comments on commit 7d7ca22

Please sign in to comment.