Skip to content

Commit

Permalink
Merge pull request #602 from Kipper-Lang/524-feature-implement-intern…
Browse files Browse the repository at this point in the history
…al-representation-for-objects-and-object-types-interfaces

Implemented internal representation for objects and object types such as interfaces and classes
  • Loading branch information
Luna-Klatzer authored Jul 11, 2024
2 parents 54c7760 + 1dd3500 commit 9c14786
Show file tree
Hide file tree
Showing 193 changed files with 7,788 additions and 6,526 deletions.
8 changes: 3 additions & 5 deletions .run/kipper run.run.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="kipper run" type="NodeJSConfigurationType"
application-parameters="run -s &quot;&quot;" path-to-js-file="./kipper/cli/bin/run"
working-dir="$PROJECT_DIR$/">
<method v="2"/>
</configuration>
<configuration default="false" name="kipper run" type="NodeJSConfigurationType" application-parameters="run -s &quot;&quot;" path-to-js-file="./kipper/cli/bin/run" working-dir="$PROJECT_DIR$/">
<method v="2" />
</configuration>
</component>
43 changes: 42 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,49 @@ To use development versions of Kipper download the

### Added

- Implemented internal representation for custom types such as objects, interfaces and classes. This change means that
the entire core type system has been reworked and adjusted to also support custom types as well as complex types
(objects, arrays etc.). This does not inheritely add functionality but serves as the stepping stone for the
implementation of all custom types in the future. ([#524](https://github.com/Kipper-Lang/Kipper/issues/524))
- New module:
- `semantics/runtime-built-ins`, which contains runtime built-in functions, variables and types.
- `semantics/runtime-internals`, which contains the runtime internal functions.
- `semantics/types`, which contains the runtime types.
- New classes:
- `InterfaceDeclaration`, which represents an AST interface declaration.
- `ClassDeclaration`, which represents an AST class declaration.
- `BuiltInType`, which represents a built-in type.
- `CustomType`, which represents a user defined type.
- `ScopeTypeDeclaration`, which represents a scope type declaration.
- `UniverseTypeDeclaration`, which represents the universe, where all built-in types, functions and variables are
declared. This serves as the parent of the global scope.
- `CustomType`, which is a class extending from `ProcessedType` and implementing the functionality for a custom type such as a interface or class.
- New errors:
- `TypeCanNotBeUsedForTypeCheckingError`, which is thrown when a type is used for type checking, but is not a valid
type. This is an error indicating an invalid logic that should be fixed.
- New interfaces:
- `InterfaceDeclarationSemantics`, which represents the semantics of an interface declaration.
- `InterfaceDeclarationTypeSemantics`, which represents the type semantics of an interface declaration.
- `ClassDeclarationSemantics`, which represents the semantics of a class declaration.
- `ClassDeclarationTypeSemantics`, which represents the type semantics of a class declaration.
- `TypeDeclaration`, which represents a type declaration. This is an abstract base class for all type declarations.
- `TypeDeclarationSemantics`, which represents the semantics of a type declaration.
- `TypeDeclarationTypeSemantics`, which represents the type semantics of a type declaration.
- `CompilableType`, which represents a type that can be compiled.

### Changed

- Changed type from interface to class:
- `InternalFunction`, which represents an internal function.
- `BuiltInFunction`, which represents a built-in function.
- `InternalFunctionArgument`, which represents an internal function argument.
- `BuiltInVariable`, which represents a built-in variable.
- Renamed:
- Module `analysis` to `semantics`.
- Class `UncheckedType` to `RawType`.
- Class `CheckedType` to `ProcessedType`.
- Class `UndefinedCustomType` to `UndefinedType`.

### Fixed

### Deprecated
Expand All @@ -32,7 +73,7 @@ To use development versions of Kipper download the

### Added

- Implemented Processing for File Scoped Pragmas ([#480](https://github.com/Kipper-Lang/Kipper/issues/480))
- Implemented Processing for File Scoped pragmas ([#480](https://github.com/Kipper-Lang/Kipper/issues/480))
- Added Lambda Expressions, which are anonymous functions that can be used as expressions.
([#572](https://github.com/Kipper-Lang/Kipper/issues/572))
- Implemented Bitwise Operations (`&`, `|`, `^`, `~`, `<<`, `>>`, `>>>`).
Expand Down
4 changes: 0 additions & 4 deletions kipper/cli/src/commands/compile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -150,10 +150,6 @@ export default class Compile extends Command {
defaultOptimisationOptions.optimiseBuiltIns,
},
recover: flags["recover"] ?? preExistingCompileConfig?.recover ?? EvaluatedCompileConfig.defaults.recover,
abortOnFirstError:
flags["abort-on-first-error"] ??
preExistingCompileConfig?.abortOnFirstError ??
EvaluatedCompileConfig.defaults.abortOnFirstError,
} as CompileConfig,
},
};
Expand Down
2 changes: 1 addition & 1 deletion kipper/config/src/evaluated-kipper-config-file.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { EvaluatedConfigValue } from "./abstract";
import { EvaluatedConfigValue } from "./abstract";
import type { EvaluatedConfigFile } from "./abstract";
import type * as semver from "semver";
import type { CompileConfig, KipperCompileTarget } from "@kipper/core";
Expand Down
6 changes: 5 additions & 1 deletion kipper/core/KipperLexer.g4
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ Else : 'else';
// for - loop
For : 'for';

// Enum Variable
// enums
Enum : 'enum';

// function-related
Expand All @@ -77,6 +77,10 @@ Return : 'return';
CallFunc : 'call';
RetIndicator : '->';

// class and interface-related
Class : 'class';
Interface : 'interface';

// boolean constants
True : 'true';
False : 'false';
Expand Down
220 changes: 112 additions & 108 deletions kipper/core/KipperLexer.tokens
Original file line number Diff line number Diff line change
Expand Up @@ -21,67 +21,69 @@ DefFunc=20
Return=21
CallFunc=22
RetIndicator=23
True=24
False=25
Typeof=26
Void=27
Null=28
Undefined=29
Comma=30
SemiColon=31
QuestionMark=32
Colon=33
LeftParen=34
RightParen=35
LeftBracket=36
RightBracket=37
FStringExpEnd=38
LeftBrace=39
RightBrace=40
Plus=41
PlusPlus=42
Minus=43
MinusMinus=44
Star=45
Div=46
Mod=47
PowerTo=48
AndAnd=49
OrOr=50
Not=51
Assign=52
PlusAssign=53
MinusAssign=54
StarAssign=55
DivAssign=56
ModAssign=57
Equal=58
NotEqual=59
Less=60
LessEqual=61
Greater=62
GreaterEqual=63
BitwiseAnd=64
BitwiseOr=65
BitwiseXor=66
BitwiseNot=67
BitwiseZeroFillLeftShift=68
BitwiseSignedRightShift=69
BitwiseZeroFillRightShift=70
Dot=71
Identifier=72
IntegerConstant=73
SingleQuoteStringLiteral=74
DoubleQuoteStringLiteral=75
FloatingConstant=76
Whitespace=77
Newline=78
FStringSingleQuoteStart=79
FStringDoubleQuoteStart=80
FStringSingleQuoteEnd=81
FStringSingleQuoteAtom=82
FStringDoubleQuoteEnd=83
FStringDoubleQuoteAtom=84
Class=24
Interface=25
True=26
False=27
Typeof=28
Void=29
Null=30
Undefined=31
Comma=32
SemiColon=33
QuestionMark=34
Colon=35
LeftParen=36
RightParen=37
LeftBracket=38
RightBracket=39
FStringExpEnd=40
LeftBrace=41
RightBrace=42
Plus=43
PlusPlus=44
Minus=45
MinusMinus=46
Star=47
Div=48
Mod=49
PowerTo=50
AndAnd=51
OrOr=52
Not=53
Assign=54
PlusAssign=55
MinusAssign=56
StarAssign=57
DivAssign=58
ModAssign=59
Equal=60
NotEqual=61
Less=62
LessEqual=63
Greater=64
GreaterEqual=65
BitwiseAnd=66
BitwiseOr=67
BitwiseXor=68
BitwiseNot=69
BitwiseZeroFillLeftShift=70
BitwiseSignedRightShift=71
BitwiseZeroFillRightShift=72
Dot=73
Identifier=74
IntegerConstant=75
SingleQuoteStringLiteral=76
DoubleQuoteStringLiteral=77
FloatingConstant=78
Whitespace=79
Newline=80
FStringSingleQuoteStart=81
FStringDoubleQuoteStart=82
FStringSingleQuoteEnd=83
FStringSingleQuoteAtom=84
FStringDoubleQuoteEnd=85
FStringDoubleQuoteAtom=86
'const'=5
'var'=6
'as'=7
Expand All @@ -101,50 +103,52 @@ FStringDoubleQuoteAtom=84
'return'=21
'call'=22
'->'=23
'true'=24
'false'=25
'typeof'=26
'void'=27
'null'=28
'undefined'=29
','=30
';'=31
'?'=32
':'=33
'('=34
')'=35
'['=36
']'=37
'{'=39
'}'=40
'+'=41
'++'=42
'-'=43
'--'=44
'*'=45
'/'=46
'%'=47
'**'=48
'&&'=49
'||'=50
'!'=51
'='=52
'+='=53
'-='=54
'*='=55
'/='=56
'%='=57
'=='=58
'!='=59
'<'=60
'<='=61
'>'=62
'>='=63
'&'=64
'|'=65
'^'=66
'~'=67
'<<'=68
'>>'=69
'>>>'=70
'.'=71
'class'=24
'interface'=25
'true'=26
'false'=27
'typeof'=28
'void'=29
'null'=30
'undefined'=31
','=32
';'=33
'?'=34
':'=35
'('=36
')'=37
'['=38
']'=39
'{'=41
'}'=42
'+'=43
'++'=44
'-'=45
'--'=46
'*'=47
'/'=48
'%'=49
'**'=50
'&&'=51
'||'=52
'!'=53
'='=54
'+='=55
'-='=56
'*='=57
'/='=58
'%='=59
'=='=60
'!='=61
'<'=62
'<='=63
'>'=64
'>='=65
'&'=66
'|'=67
'^'=68
'~'=69
'<<'=70
'>>'=71
'>>>'=72
'.'=73
Loading

0 comments on commit 9c14786

Please sign in to comment.