Skip to content

Commit 8a17891

Browse files
authored
Merge pull request #724 from Kipper-Lang/dev-next
v0.13.0-alpha.2
2 parents 3e6cb4b + f81044b commit 8a17891

22 files changed

+385
-145
lines changed

CITATION.cff

+4-4
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ authors:
2121
identifiers:
2222
- type: url
2323
value: >-
24-
https://github.com/Kipper-Lang/Kipper/releases/tag/v0.13.0-alpha.1
25-
description: The GitHub release URL of tag 0.13.0-alpha.1
24+
https://github.com/Kipper-Lang/Kipper/releases/tag/v0.13.0-alpha.2
25+
description: The GitHub release URL of tag 0.13.0-alpha.2
2626
repository-code: 'https://github.com/Kipper-Lang/Kipper/'
2727
url: 'https://kipper-lang.org'
2828
abstract: >-
@@ -39,6 +39,6 @@ keywords:
3939
- oop-programming
4040
- type-safety
4141
license: GPL-3.0-or-later
42-
license-url: 'https://github.com/Kipper-Lang/Kipper/blob/v0.13.0-alpha.1/LICENSE'
43-
version: 0.13.0-alpha.1
42+
license-url: 'https://github.com/Kipper-Lang/Kipper/blob/v0.13.0-alpha.2/LICENSE'
43+
version: 0.13.0-alpha.2
4444
date-released: '2025-02-26'

kipper/cli/README.md

+6-6
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ $ npm install -g @kipper/cli
4444
$ kipper COMMAND
4545
running command...
4646
$ kipper (--version)
47-
@kipper/cli/0.13.0-alpha.1 linux-x64 node-v23.4.0
47+
@kipper/cli/0.13.0-alpha.2 linux-x64 node-v23.4.0
4848
$ kipper --help [COMMAND]
4949
USAGE
5050
$ kipper COMMAND
@@ -111,7 +111,7 @@ EXAMPLES
111111
kipper compile -t ts ./path/to/file.kip -o build/ -e utf16le --warnings --log-timestamp
112112
```
113113

114-
_See code: [src/commands/compile.ts](https://github.com/Kipper-Lang/Kipper/blob/v0.13.0-alpha.1/kipper/cli/src/commands/compile.ts)_
114+
_See code: [src/commands/compile.ts](https://github.com/Kipper-Lang/Kipper/blob/v0.13.0-alpha.2/kipper/cli/src/commands/compile.ts)_
115115

116116
## `kipper help [COMMAND]`
117117

@@ -128,7 +128,7 @@ OPTIONS
128128
--all see all commands in CLI
129129
```
130130

131-
_See code: [src/commands/help.ts](https://github.com/Kipper-Lang/Kipper/blob/v0.13.0-alpha.1/kipper/cli/src/commands/help.ts)_
131+
_See code: [src/commands/help.ts](https://github.com/Kipper-Lang/Kipper/blob/v0.13.0-alpha.2/kipper/cli/src/commands/help.ts)_
132132

133133
## `kipper new [LOCATION]`
134134

@@ -145,7 +145,7 @@ OPTIONS
145145
-d, --default Use the default settings for the new project. Skips the setup wizard.
146146
```
147147

148-
_See code: [src/commands/new.ts](https://github.com/Kipper-Lang/Kipper/blob/v0.13.0-alpha.1/kipper/cli/src/commands/new.ts)_
148+
_See code: [src/commands/new.ts](https://github.com/Kipper-Lang/Kipper/blob/v0.13.0-alpha.2/kipper/cli/src/commands/new.ts)_
149149

150150
## `kipper run [FILE]`
151151

@@ -190,7 +190,7 @@ EXAMPLES
190190
kipper run -t ts -o build/ -e utf8 -s "print('Hello, World!');" --warnings --log-timestamp
191191
```
192192

193-
_See code: [src/commands/run.ts](https://github.com/Kipper-Lang/Kipper/blob/v0.13.0-alpha.1/kipper/cli/src/commands/run.ts)_
193+
_See code: [src/commands/run.ts](https://github.com/Kipper-Lang/Kipper/blob/v0.13.0-alpha.2/kipper/cli/src/commands/run.ts)_
194194

195195
## `kipper version`
196196

@@ -201,7 +201,7 @@ USAGE
201201
$ kipper version
202202
```
203203

204-
_See code: [src/commands/version.ts](https://github.com/Kipper-Lang/Kipper/blob/v0.13.0-alpha.1/kipper/cli/src/commands/version.ts)_
204+
_See code: [src/commands/version.ts](https://github.com/Kipper-Lang/Kipper/blob/v0.13.0-alpha.2/kipper/cli/src/commands/version.ts)_
205205
<!-- commandsstop -->
206206

207207
## Contributing to Kipper

kipper/cli/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@kipper/cli",
33
"description": "The Kipper Command Line Interface (CLI).",
4-
"version": "0.13.0-alpha.1",
4+
"version": "0.13.0-alpha.2",
55
"author": "Luna-Klatzer @Luna-Klatzer",
66
"bin": {
77
"kipper": "./bin/run",

kipper/cli/src/index.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ export * from "./output/compile";
1313
// eslint-disable-next-line no-unused-vars
1414
export const name = "@kipper/cli";
1515
// eslint-disable-next-line no-unused-vars
16-
export const version = "0.13.0-alpha.1";
16+
export const version = "0.13.0-alpha.2";
1717
// eslint-disable-next-line no-unused-vars
1818
export const author = "Luna Klatzer";
1919
// eslint-disable-next-line no-unused-vars

kipper/config/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@kipper/config",
33
"description": "The config file support package adding support for kip-config.json/kipper-config.json 🦊",
4-
"version": "0.13.0-alpha.1",
4+
"version": "0.13.0-alpha.2",
55
"author": "Luna-Klatzer @Luna-Klatzer",
66
"dependencies": {
77
"is-plain-object": "5.0.0",

kipper/config/src/index.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ export * from "./evaluated-kipper-config-file";
1212
// eslint-disable-next-line no-unused-vars
1313
export const name = "@kipper/config";
1414
// eslint-disable-next-line no-unused-vars
15-
export const version = "0.13.0-alpha.1";
15+
export const version = "0.13.0-alpha.2";
1616
// eslint-disable-next-line no-unused-vars
1717
export const author = "Luna Klatzer";
1818
// eslint-disable-next-line no-unused-vars

kipper/core/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@kipper/core",
33
"description": "The core implementation of the Kipper compiler 🦊",
4-
"version": "0.13.0-alpha.1",
4+
"version": "0.13.0-alpha.2",
55
"author": "Luna-Klatzer @Luna-Klatzer",
66
"dependencies": {
77
"antlr4ts": "^0.5.0-alpha.4",

kipper/core/src/index.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ export * as utils from "./tools";
1717
// eslint-disable-next-line no-unused-vars
1818
export const name = "@kipper/core";
1919
// eslint-disable-next-line no-unused-vars
20-
export const version = "0.13.0-alpha.1";
20+
export const version = "0.13.0-alpha.2";
2121
// eslint-disable-next-line no-unused-vars
2222
export const author = "Luna Klatzer";
2323
// eslint-disable-next-line no-unused-vars

kipper/index.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ export * from "@kipper/target-ts";
1313
// eslint-disable-next-line no-unused-vars
1414
export const name = "kipper";
1515
// eslint-disable-next-line no-unused-vars
16-
export const version = "0.13.0-alpha.1";
16+
export const version = "0.13.0-alpha.2";
1717
// eslint-disable-next-line no-unused-vars
1818
export const author = "Luna Klatzer";
1919
// eslint-disable-next-line no-unused-vars

kipper/target-js/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@kipper/target-js",
33
"description": "The JavaScript target for the Kipper compiler 🦊",
4-
"version": "0.13.0-alpha.1",
4+
"version": "0.13.0-alpha.2",
55
"author": "Luna-Klatzer @Luna-Klatzer",
66
"dependencies": {
77
"@kipper/core": "workspace:~",

kipper/target-js/src/built-in-generator.ts

+5-2
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,9 @@ export class JavaScriptTargetBuiltInGenerator extends KipperTargetBuiltInGenerat
134134

135135
return genJSFunction(
136136
signature,
137-
`{ if (${typeIdentifier}.acceptsVal(${valIdentifier})) { return ${valIdentifier} }` + `return null; }`,
137+
`{ if ('acceptsVal' in ${typeIdentifier} && ${typeIdentifier}.acceptsVal(${valIdentifier})) { return ${valIdentifier} }` +
138+
`try { if (${valIdentifier} instanceof ${typeIdentifier}) { return ${valIdentifier} } } catch (_) {}` +
139+
`return null; }`,
138140
);
139141
}
140142

@@ -148,7 +150,8 @@ export class JavaScriptTargetBuiltInGenerator extends KipperTargetBuiltInGenerat
148150
return genJSFunction(
149151
signature,
150152
`{ const valType = ${valType};` +
151-
`if (${typeIdentifier}.accepts(valType)) { return ${valIdentifier} }` +
153+
`if ('acceptsVal' in ${typeIdentifier} && ${typeIdentifier}.acceptsVal(${valIdentifier})) { return ${valIdentifier} }` +
154+
`try { if (${valIdentifier} instanceof ${typeIdentifier}) { return ${valIdentifier} } } catch (_) {}` +
152155
`throw new ${typeErr}(\`Invalid force cast from '\${${valType}.name}' to '\${${typeIdentifier}.name}'.\`); }`,
153156
);
154157
}

kipper/target-js/src/index.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ export * from "./runtime/";
1414
// eslint-disable-next-line no-unused-vars
1515
export const name = "@kipper/target-js";
1616
// eslint-disable-next-line no-unused-vars
17-
export const version = "0.13.0-alpha.1";
17+
export const version = "0.13.0-alpha.2";
1818
// eslint-disable-next-line no-unused-vars
1919
export const author = "Luna Klatzer";
2020
// eslint-disable-next-line no-unused-vars

kipper/target-js/src/runtime/create-kipper.ts

+57-28
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,9 @@ export const createKipper = (args: CreateKipperOptions = {}): string =>
3939
if (type.baseType === null) { return false; }
4040
return this.isInHierarchyOfType(type.baseType);
4141
}
42-
accepts(obj) {
43-
if (this === obj) return true;
44-
return obj instanceof KipperType && (this.customComparer ? this.customComparer(this, obj) : true);
42+
accepts(objT) {
43+
if (this === objT) return true;
44+
return objT instanceof KipperType && (this.customComparer ? this.customComparer(this, objT) : true);
4545
}
4646
acceptsVal(obj) {
4747
return this.accepts(__tmpKip.typeOf(obj));
@@ -51,12 +51,12 @@ export const createKipper = (args: CreateKipperOptions = {}): string =>
5151
constructor(name, fields, methods, genericArgs, baseType = null, customComparer = null) {
5252
super(name, fields, methods, baseType, customComparer); this.genericArgs = genericArgs;
5353
}
54-
accepts(obj) {
55-
if (this === obj) return true;
56-
if (!(obj instanceof KipperGenericType) || this.genericArgs.length !== obj.genericArgs.length) return false;
57-
const foreignGenericArgs = Object.entries(obj.genericArgs);
58-
return this.name === obj.name &&
59-
(this.customComparer ? this.customComparer(this, obj) : true) &&
54+
accepts(objT) {
55+
if (this === objT) return true;
56+
if (!(objT instanceof KipperGenericType) || this.genericArgs.length !== objT.genericArgs.length) return false;
57+
const foreignGenericArgs = Object.entries(objT.genericArgs);
58+
return this.name === objT.name &&
59+
(this.customComparer ? this.customComparer(this, objT) : true) &&
6060
Object.entries(this.genericArgs).every((arg, i) => {
6161
if (Array.isArray(arg)) {
6262
if (!Array.isArray(foreignGenericArgs[i]) || arg.length !== foreignGenericArgs[i].length) { return false; }
@@ -67,6 +67,32 @@ export const createKipper = (args: CreateKipperOptions = {}): string =>
6767
}
6868
changeGenericTypeArguments(genericArgs) { return new KipperGenericType(this.name, this.fields, this.methods, genericArgs, this.baseType) }
6969
};
70+
class KipperInterfaceType extends KipperType {
71+
constructor(name, fields, methods, baseType = null, customComparer = null) {
72+
super(name, fields, methods, baseType, customComparer);
73+
}
74+
accepts(objT) {
75+
if (this === objT) return true;
76+
if (!(objT instanceof KipperInterfaceType)) return false;
77+
return this.isSubsetOfOrEqual(objT) &&
78+
(this.customComparer ? this.customComparer(this, objT) : true);
79+
}
80+
acceptsVal(obj) {
81+
const objT = __tmpKip.typeOf(obj);
82+
if (objT !== __tmpKip.builtIn.obj && !(obj instanceof Object)) return false;
83+
return __tmpKip.matches(obj, this);
84+
}
85+
isSubsetOfOrEqual(objT) {
86+
return this.fields.every((field) => {
87+
const fieldInObjT = objT.fields.find((f) => f.name === field.name);
88+
return fieldInObjT && field.type.accepts(fieldInObjT.type);
89+
}) && this.methods.every((method) => {
90+
const methodInObjT = objT.methods.find((m) => m.name === method.name);
91+
return methodInObjT && method.returnType.accepts(methodInObjT.returnType) && method.parameters.length === methodInObjT.parameters.length &&
92+
method.parameters.every((param, i) => param.type.accepts(methodInObjT.parameters[i].type));
93+
});
94+
}
95+
}
7096
const __type_any = new KipperType('any', undefined, undefined);
7197
const __type_null = new KipperType('null', undefined, undefined, undefined, (a, b) => a.name === b.name);
7298
const __type_undefined = new KipperType('undefined', undefined, undefined, undefined, (a, b) => a.name === b.name);
@@ -77,15 +103,15 @@ export const createKipper = (args: CreateKipperOptions = {}): string =>
77103
const __type_Array = new KipperGenericType('Array', undefined, undefined, {T: __type_any}, undefined, (a, b) => a.name === b.name);
78104
const __type_Func = new KipperGenericType('Func', undefined, undefined, {T: [], R: __type_any}, undefined, (a, b) => a.name === b.name);
79105
__tmpKip.builtIn = {
80-
any: __type_any,
81-
null: __type_null,
82-
undefined: __type_undefined,
83-
str: __type_str,
84-
num: __type_num,
85-
bool: __type_bool,
86-
obj: __type_obj,
87-
Array: __type_Array,
88-
Func: __type_Func,
106+
any: __type_any,
107+
null: __type_null,
108+
undefined: __type_undefined,
109+
str: __type_str,
110+
num: __type_num,
111+
bool: __type_bool,
112+
obj: __type_obj,
113+
Array: __type_Array,
114+
Func: __type_Func,
89115
};
90116
__tmpKip.KipperError = KipperError;
91117
__tmpKip.TypeError = (class KipperTypeError extends KipperError { constructor(msg) { super(msg); this.name = 'KipTypeError'; } });
@@ -96,29 +122,32 @@ export const createKipper = (args: CreateKipperOptions = {}): string =>
96122
__tmpKip.Method = class KipperMethod { constructor(name, returnType, parameters) { this.name = name; this.returnType = returnType; this.parameters = parameters; } };
97123
__tmpKip.Type = KipperType;
98124
__tmpKip.assignTypeMeta = (value, typeMeta) => Object.assign(value, { __kipType: typeMeta });
125+
__tmpKip.getTypeMeta = (value) => value.__kipType;
99126
__tmpKip.newArrayT = (type) => __tmpKip.builtIn.Array.changeGenericTypeArguments({ T: type });
127+
__tmpKip.newFuncT = (params, returnType) => __tmpKip.builtIn.Func.changeGenericTypeArguments({ T: params, R: returnType });
128+
__tmpKip.newIntfT = (name, fields, methods, baseType = __tmpKip.builtIn.obj, customComparer = null) => new KipperInterfaceType(name, fields, methods, baseType, customComparer);
100129
__tmpKip.typeOf = (value) => {
101130
const prim = typeof value;
102131
switch (prim) {
103-
case 'undefined': return __kipper.builtIn.undefined;
104-
case 'string': return __kipper.builtIn.str;
105-
case 'number': return __kipper.builtIn.num;
106-
case 'boolean': return __kipper.builtIn.bool;
132+
case 'undefined': return __tmpKip.builtIn.undefined;
133+
case 'string': return __tmpKip.builtIn.str;
134+
case 'number': return __tmpKip.builtIn.num;
135+
case 'boolean': return __tmpKip.builtIn.bool;
107136
case 'function': {
108-
return '__kipType' in value ? value.__kipType : __kipper.builtIn.Func;
137+
return '__kipType' in value ? value.__kipType : __tmpKip.builtIn.Func;
109138
}
110139
case 'symbol':
111140
case 'bigint':
112141
case 'object': {
113-
if (value === null) return __kipper.builtIn.null;
142+
if (value === null) return __tmpKip.builtIn.null;
114143
if (Array.isArray(value)) {
115-
return '__kipType' in value ? value.__kipType : __kipper.builtIn.Array;
144+
return '__kipType' in value ? value.__kipType : __tmpKip.builtIn.Array;
116145
}
117146
const prot = Object.getPrototypeOf(value);
118147
if (prot && prot.constructor !== Object) {
119148
return prot.constructor;
120149
}
121-
return __kipper.builtIn.obj;
150+
return __tmpKip.builtIn.obj;
122151
}
123152
}
124153
};
@@ -134,15 +163,15 @@ export const createKipper = (args: CreateKipperOptions = {}): string =>
134163
return false;
135164
}
136165
const fieldValue = value[fieldName];
137-
const isSameType = __kipper.typeOf(fieldValue) === field.type;
166+
const isSameType = __tmpKip.typeOf(fieldValue) === field.type;
138167
if (primTypes.includes(field.type.name) && !isSameType) {
139168
return false;
140169
}
141170
if (genTypes.includes(fieldType.name)) {
142171
throw new KipperNotImplementedError("Matches does not yet support the 'Array' and 'Func' types");
143172
}
144173
if (!primTypes.includes(fieldType.name)) {
145-
if (!__kipper.matches(fieldValue, fieldType)) {
174+
if (!__tmpKip.matches(fieldValue, fieldType)) {
146175
return false;
147176
}
148177
}

kipper/target-js/src/runtime/runtime-types.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ export class RuntimeTypesGenerator {
6262
"const ",
6363
identifier,
6464
" = ",
65-
`new ${TargetJS.getBuiltInIdentifier("Type")}`,
65+
TargetJS.getBuiltInIdentifier("newIntfT"),
6666
"(",
6767
`"${interfaceName}"`,
6868
",",

kipper/target-ts/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@kipper/target-ts",
33
"description": "The TypeScript target for the Kipper compiler 🦊",
4-
"version": "0.13.0-alpha.1",
4+
"version": "0.13.0-alpha.2",
55
"author": "Luna-Klatzer @Luna-Klatzer",
66
"dependencies": {
77
"@kipper/target-js": "workspace:~",

kipper/target-ts/src/index.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ export * from "./tools";
1313
// eslint-disable-next-line no-unused-vars
1414
export const name = "@kipper/target-ts";
1515
// eslint-disable-next-line no-unused-vars
16-
export const version = "0.13.0-alpha.1";
16+
export const version = "0.13.0-alpha.2";
1717
// eslint-disable-next-line no-unused-vars
1818
export const author = "Luna Klatzer";
1919
// eslint-disable-next-line no-unused-vars

kipper/web/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@kipper/web",
33
"description": "The standalone web-module for the Kipper compiler 🦊",
4-
"version": "0.13.0-alpha.1",
4+
"version": "0.13.0-alpha.2",
55
"author": "Luna-Klatzer @Luna-Klatzer",
66
"devDependencies": {
77
"@kipper/target-js": "workspace:~",

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "kipper",
33
"description": "The Kipper programming language and compiler 🦊",
4-
"version": "0.13.0-alpha.1",
4+
"version": "0.13.0-alpha.2",
55
"author": "Luna-Klatzer @Luna-Klatzer",
66
"dependencies": {
77
"@kipper/cli": "workspace:~",

0 commit comments

Comments
 (0)