-
-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
6b7db32
commit b45874c
Showing
10 changed files
with
184 additions
and
0 deletions.
There are no files selected for viewing
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import { TirInterfaceImpl } from "./TirInterfaceImpl"; | ||
import { TirType } from "./TirType"; | ||
import { TirTypeParam } from "./TirTypeParam"; | ||
|
||
export class TirAliasType | ||
{ | ||
constructor( | ||
readonly name: string, | ||
readonly tyArgs: TirTypeParam[], | ||
readonly aliased: TirType, | ||
readonly impls: TirInterfaceImpl[] | ||
) {} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import { TirInterfaceType } from "./TirInterfaceType"; | ||
import { TirCustomType } from "./TirType"; | ||
|
||
|
||
export class TirInterfaceImpl | ||
{ | ||
constructor( | ||
readonly targetType: TirCustomType, | ||
readonly interf: TirInterfaceType | ||
) {} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import { TirType } from "./TirType"; | ||
import { TirTypeParam } from "./TirTypeParam"; | ||
|
||
export class TirInterfaceType | ||
{ | ||
constructor( | ||
// anonymos interface for custom type methods | ||
readonly name: string | undefined, | ||
readonly typeParams: TirTypeParam[], | ||
readonly methods: TirInterfaceMethod[] | ||
) { | ||
for( const method of methods ) | ||
{ | ||
method.parentInterface = this; | ||
} | ||
} | ||
} | ||
|
||
export class TirInterfaceMethod | ||
{ | ||
constructor( | ||
public parentInterface: TirInterfaceType, | ||
readonly name: string, | ||
readonly params: TirType[], | ||
readonly returnType: TirType | ||
) {} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
import { TirType } from "./TirType"; | ||
|
||
export type TirNativeType | ||
= TirVoidT | ||
| TirBoolT | ||
| TirNumT | ||
| TirBytesT | ||
| TirOptT<TirType> | ||
| TirListT<TirType> | ||
| TirLinearMapT<TirType,TirType> | ||
| TirFuncT | ||
; | ||
|
||
export function isTirNativeType( t: any ): t is TirNativeType | ||
{ | ||
return ( | ||
t instanceof TirVoidT | ||
|| t instanceof TirBoolT | ||
|| t instanceof TirNumT | ||
|| t instanceof TirBytesT | ||
|| t instanceof TirOptT | ||
|| t instanceof TirListT | ||
|| t instanceof TirLinearMapT | ||
|| t instanceof TirFuncT | ||
); | ||
} | ||
|
||
export class TirVoidT {} | ||
export class TirBoolT {} | ||
export class TirNumT {} | ||
export class TirBytesT {} | ||
|
||
export class TirOptT<T extends TirType> | ||
{ | ||
constructor( | ||
readonly typeArg: T | ||
) {} | ||
} | ||
|
||
export class TirListT<T extends TirType> | ||
{ | ||
constructor( | ||
readonly typeArg: T | ||
) {} | ||
} | ||
|
||
export class TirLinearMapT<K extends TirType,V extends TirType> | ||
{ | ||
constructor( | ||
readonly keyTypeArg: K, | ||
readonly valTypeArg: V | ||
) {} | ||
} | ||
|
||
export class TirFuncT | ||
{ | ||
constructor( | ||
// readonly genericTyArgsName: TirTypeParam[], | ||
readonly argTypes: TirType[], | ||
readonly returnType: TirType | ||
) {} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import { TirInterfaceImpl } from "./TirInterfaceImpl"; | ||
import { TirType } from "./TirType"; | ||
|
||
export class TirStructType | ||
{ | ||
constructor( | ||
readonly name: string, | ||
readonly constructors: TirStructConstr[], | ||
readonly impls: TirInterfaceImpl[] | ||
) {} | ||
} | ||
|
||
export class TirStructConstr | ||
{ | ||
constructor( | ||
readonly name: string, | ||
readonly fields: TirStructField[] | ||
) {} | ||
} | ||
|
||
export class TirStructField | ||
{ | ||
constructor( | ||
readonly name: string, | ||
readonly type: TirType | ||
) {} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import { isObject } from "@harmoniclabs/obj-utils"; | ||
import { isTirNativeType, TirNativeType } from "./TirNativeType"; | ||
import { TirTypeParam } from "./TirTypeParam"; | ||
import { TirAliasType } from "./TirAliasType"; | ||
import { TirStructType } from "./TirStructType"; | ||
// import { TirInterfaceType } from "./TirInterfaceType"; | ||
|
||
|
||
export type TirCustomType | ||
= TirAliasType | ||
| TirStructType | ||
; | ||
|
||
export function isTirCustomType( thing: any ): thing is TirCustomType | ||
{ | ||
return isObject( thing ) && ( | ||
thing instanceof TirAliasType | ||
|| thing instanceof TirStructType | ||
); | ||
} | ||
|
||
export type TirType | ||
= TirNativeType | ||
| TirTypeParam | ||
| TirCustomType | ||
// | TirInterfaceType | ||
; | ||
|
||
export function isTirType( thing: any ): thing is TirType | ||
{ | ||
return isObject( thing ) && ( | ||
isTirNativeType( thing ) | ||
|| thing instanceof TirTypeParam | ||
|| isTirCustomType( thing ) | ||
// || thing instanceof TirInterfaceType | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
|
||
export class TirTypeParam | ||
{ | ||
constructor( | ||
readonly name: string | ||
) {} | ||
} |