-
Notifications
You must be signed in to change notification settings - Fork 13
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
Showing
5 changed files
with
92 additions
and
2 deletions.
There are no files selected for viewing
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
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
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,76 @@ | ||
'use strict' | ||
import { UserRuntimeZero, Constructor, mkBase } from './UserRuntimeZero.mjs' | ||
import { LVal } from '../Lval.mjs'; | ||
import { assertIsNTuple, assertIsRecord, assertIsString, assertIsUnit, assertNormalState } from '../Asserts.mjs' | ||
import { Record } from "../Record.mjs"; | ||
import { lub } from '../options.mjs'; | ||
import { __unit } from '../UnitVal.mjs'; | ||
import { TroupeType } from '../TroupeTypes.mjs'; | ||
|
||
export function BuiltinTypeInformation<TBase extends Constructor<UserRuntimeZero>>(Base: TBase) { | ||
return class extends Base { | ||
// returns a string containing the type information | ||
getType = mkBase((larg) => { | ||
let _t = "unknown" // 2024-03-18; todo: add proper type | ||
switch (larg.val._troupeType) { | ||
case TroupeType.UNIT: | ||
_t = "unit"; | ||
break; | ||
case TroupeType.BOOLEAN: | ||
_t = "boolean"; | ||
break; | ||
case TroupeType.NUMBER: | ||
_t = "number"; | ||
break; | ||
|
||
case TroupeType.STRING: | ||
_t = "string"; | ||
break; | ||
case TroupeType.PROCESS_ID: | ||
_t = "process_id"; | ||
break; | ||
case TroupeType.LEVEL: | ||
_t = "level"; | ||
break; | ||
case TroupeType.AUTHORITY: | ||
_t = "authority"; | ||
break; | ||
case TroupeType.CLOSURE: | ||
_t = "function"; | ||
break; | ||
case TroupeType.TUPLE: | ||
_t = "tuple"; | ||
break; | ||
case TroupeType.LIST: | ||
_t = "list"; | ||
break; | ||
case TroupeType.RECORD: | ||
_t = "record"; | ||
break; | ||
case TroupeType.LOCALOBJECT: | ||
_t = "localobject"; | ||
break; | ||
default: | ||
switch (typeof larg.val) { | ||
case 'string': | ||
_t = "string"; | ||
break; | ||
case 'number': | ||
_t = "number"; | ||
break; | ||
case 'boolean': | ||
_t = "boolean" | ||
break; | ||
} | ||
} | ||
return this.runtime.ret ( | ||
new LVal ( _t | ||
, lub (larg.tlev, this.runtime.$t.pc) | ||
, this.runtime.$t.pc) | ||
) | ||
|
||
|
||
|
||
}) | ||
} | ||
} |
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,2 @@ | ||
2024-03-18T10:10:03.645Z [RTM] [32minfo[39m: Skipping network creation. Observe that all external IO operations will yield a runtime error. | ||
>>> Main thread finished with value: ["string"@{}%{}, "function"@{}%{}, "number"@{}%{}, "unit"@{}%{}, "record"@{}%{}]@{}%{} |
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,9 @@ | ||
(* we want a simple function | ||
getType x that returns | ||
the information about the type | ||
*) | ||
import lists | ||
let val ls = [ "hello", fn x => x + 1, 2, () , {x = 2}] | ||
in map getType ls | ||
end | ||
|