Explorer

core

Core built-in module for definy · Public

Snapshot history

Status: Done · Every branch of the project (change the status there)

core.wasm-type-list: Number  // The index of the Wasm GC type of the definy compiler output: a list (tag 3) or a record (tag 4): (struct i32 (ref null values)). A record has the keys and values alternately
core.wasm-type-closure: Number  // The index of the Wasm GC type of the definy compiler output: a function value (tag 5): (struct i32 i32 (ref null values)) with the index in the function table and the captured variables
core.wasm-type-variant: Number  // The index of the Wasm GC type of the definy compiler output: a variant (tag 6): (struct i32 (ref null string) (ref null value)) with the tag string and the payload (null when absent)
core.wasm-type-float: Number  // The index of the Wasm GC type of the definy compiler output: a float (tag 7): (struct i32 f64)
core.wasm-type-closure-function: Number  // The index of the Wasm GC type of the definy compiler output: the function type of compiled functions: (func (param (ref null values) (ref null values)) (result (ref null value))) taking the captured variables and the arguments
core.wasm-runtime-string-from-memory: List<Number>  // Runtime function 1 of the definy compiler (exported as string_from_memory): string_from_memory(length: i32) -> value: a new string of the bytes 0..length of the memory. The memory is only a buffer for the host to pass strings (the values live in the GC heap). Local variable declarations and instructions, without the byte length (wasm.code-entry adds it)
core.wasm-runtime-string-to-memory: List<Number>  // Runtime function 13 of the definy compiler (exported as string_to_memory): string_to_memory(string) -> i32: writes the bytes of the string at 0 of the memory (growing it when needed) and returns the byte length. For the host to read strings. Local variable declarations and instructions, without the byte length (wasm.code-entry adds it)
core.wasm-runtime-value-tag: List<Number>  // Runtime function 14 of the definy compiler (exported as value_tag): value_tag(value) -> i32: the tag of the kind of the value (0 number, 1 boolean, 2 string, 3 list, 4 record, 5 function, 6 variant, 7 float). Local variable declarations and instructions, without the byte length (wasm.code-entry adds it)
core.wasm-runtime-number-value: List<Number>  // Runtime function 15 of the definy compiler (exported as number_value): number_value(number) -> i64. Local variable declarations and instructions, without the byte length (wasm.code-entry adds it)
core.wasm-runtime-float-value: List<Number>  // Runtime function 16 of the definy compiler (exported as float_value): float_value(float) -> f64. Local variable declarations and instructions, without the byte length (wasm.code-entry adds it)
core.wasm-runtime-bool-value: List<Number>  // Runtime function 17 of the definy compiler (exported as bool_value): bool_value(boolean) -> i32 (0 or 1). Local variable declarations and instructions, without the byte length (wasm.code-entry adds it)
core.wasm-runtime-length: List<Number>  // Runtime function 18 of the definy compiler (exported as length): length(value) -> i32: the byte length of a string, or the number of items of a list (twice the number of fields for a record). Local variable declarations and instructions, without the byte length (wasm.code-entry adds it)
core.wasm-runtime-values-of: List<Number>  // Runtime function 19 of the definy compiler (exported as values_of): values_of(value) -> values: the items of a list, the keys and values of a record (alternately), or the captured variables of a function. Local variable declarations and instructions, without the byte length (wasm.code-entry adds it)
core.wasm-runtime-values-length: List<Number>  // Runtime function 20 of the definy compiler (exported as values_length): values_length(values) -> i32. Local variable declarations and instructions, without the byte length (wasm.code-entry adds it)
core.wasm-runtime-values-get: List<Number>  // Runtime function 21 of the definy compiler (exported as values_get): values_get(values, index) -> value. Local variable declarations and instructions, without the byte length (wasm.code-entry adds it)
core.wasm-runtime-values-new: List<Number>  // Runtime function 22 of the definy compiler (exported as values_new): values_new(length) -> values: a new array of values (null). Local variable declarations and instructions, without the byte length (wasm.code-entry adds it)
core.wasm-runtime-values-set: List<Number>  // Runtime function 23 of the definy compiler (exported as values_set): values_set(values, index, value). Local variable declarations and instructions, without the byte length (wasm.code-entry adds it)
core.wasm-runtime-list-new: List<Number>  // Runtime function 24 of the definy compiler (exported as list_new): list_new(values) -> value: a list (tag 3) of the values. Local variable declarations and instructions, without the byte length (wasm.code-entry adds it)
core.wasm-runtime-record-new: List<Number>  // Runtime function 25 of the definy compiler (exported as record_new): record_new(values) -> value: a record (tag 4) of the keys and values (alternately). Local variable declarations and instructions, without the byte length (wasm.code-entry adds it)
core.wasm-runtime-variant-new: List<Number>  // Runtime function 26 of the definy compiler (exported as variant_new): variant_new(tag, payload) -> value: a variant (the payload is null when absent). Local variable declarations and instructions, without the byte length (wasm.code-entry adds it)
core.wasm-runtime-variant-tag: List<Number>  // Runtime function 27 of the definy compiler (exported as variant_tag): variant_tag(variant) -> value: the tag string. Local variable declarations and instructions, without the byte length (wasm.code-entry adds it)
core.wasm-runtime-variant-payload: List<Number>  // Runtime function 28 of the definy compiler (exported as variant_payload): variant_payload(variant) -> value: the payload (null when absent). Local variable declarations and instructions, without the byte length (wasm.code-entry adds it)
core.wasm-runtime-closure-index: List<Number>  // Runtime function 29 of the definy compiler (exported as closure_index): closure_index(function) -> i32: the index of the function in the function table. Local variable declarations and instructions, without the byte length (wasm.code-entry adds it)
core.wasm-runtime-float-new: List<Number>  // Runtime function 30 of the definy compiler (exported as float_new): float_new(f64) -> value: a new float (tag 7). Local variable declarations and instructions, without the byte length (wasm.code-entry adds it)
core.wasm-runtime-closure-new: List<Number>  // Runtime function 31 of the definy compiler (exported as closure_new): closure_new(index, captured) -> value: a function value of the function table index and the captured variables. Local variable declarations and instructions, without the byte length (wasm.code-entry adds it)
core.wasm-runtime-function-types: List<Number>  // The type indices of the evaluate function (0), the runtime functions 1-31 and the string initialization function (32) for the function section
core.wasm-runtime-types: List<Number>  // The payload of the type section of the definy compiler output: the value types (core.wasm-type-value to core.wasm-type-float, the struct and array types of Wasm GC), then the function types (core.wasm-type-closure-function first)
core.wasm-runtime-exports: List<Number>  // The payload of the export section of the definy compiler output: evaluate (and main), memory (a buffer to pass strings), table and the runtime functions for the host to make and read values (src/stage1_compiler.ts)
core.wasm-runtime-functions: List<Number>  // The code section entries of the runtime functions 1-31 of the definy compiler, emitted by core.compile-to-wasm after the evaluate function. Their function indices and types must agree with core.wasm-runtime-function-types and core.compile-expr-instructions
core.wasm-runtime-box-number: List<Number>  // Runtime function 2 of the definy compiler (exported as box_number): box_number(n: i64) -> value: a new number (tag 0). Local variable declarations and instructions, without the byte length (wasm.code-entry adds it)
core.wasm-runtime-box-bool: List<Number>  // Runtime function 3 of the definy compiler (exported as box_bool): box_bool(b: i32) -> value: the boolean true (global 0) or false (global 1). Local variable declarations and instructions, without the byte length (wasm.code-entry adds it)
core.wasm-runtime-string-eq: List<Number>  // Runtime function 4 of the definy compiler: string_eq(a, b) -> i32: whether the bytes of the two strings are the same (does not compare the bytes of the same string). Local variable declarations and instructions, without the byte length (wasm.code-entry adds it)
core.wasm-runtime-values-equal: List<Number>  // Runtime function 5 of the definy compiler: values_equal(a, b) -> i32: compares values by their contents (same as core.value-equals). Lists, records and variants are compared deeply, records by keys regardless of the order of the fields. Functions are equal only when they are the same value. Floats (tag 7) use the IEEE 754 comparison (f64.eq), so NaN is not equal to itself. Local variable declarations and instructions, without the byte length (wasm.code-entry adds it)
core.wasm-runtime-record-get: List<Number>  // Runtime function 6 of the definy compiler: record_get(record, key) -> value: the value of the field of the key. unreachable when absent. Local variable declarations and instructions, without the byte length (wasm.code-entry adds it)
core.wasm-runtime-list-concat: List<Number>  // Runtime function 7 of the definy compiler: list_concat(a, b) -> value: a new list of the items of a followed by the items of b (a or b itself when the other is empty). Local variable declarations and instructions, without the byte length (wasm.code-entry adds it)
core.wasm-runtime-list-append: List<Number>  // Runtime function 8 of the definy compiler: list_append(list, item) -> value: a new list with item added at the end. Local variable declarations and instructions, without the byte length (wasm.code-entry adds it)
core.wasm-runtime-string-concat: List<Number>  // Runtime function 9 of the definy compiler: string_concat(a, b) -> value: a new string of the bytes of a followed by the bytes of b. Local variable declarations and instructions, without the byte length (wasm.code-entry adds it)
core.wasm-runtime-string-slice: List<Number>  // Runtime function 10 of the definy compiler: string_slice(string, start, end) -> value: the bytes from start to end. start and end are clamped to 0..=length, and the result is empty when end < start. Local variable declarations and instructions, without the byte length (wasm.code-entry adds it)
core.wasm-runtime-string-to-bytes: List<Number>  // Runtime function 11 of the definy compiler: string_to_bytes(string) -> value: the list of the bytes (numbers) of the string. Local variable declarations and instructions, without the byte length (wasm.code-entry adds it)
core.wasm-runtime-list-get: List<Number>  // Runtime function 12 of the definy compiler: list_get(list, index) -> value: an option, some(item) within the range, none outside (including negative indices). The tags "none" and "some" are the globals 4 and 5 (core.compile-to-wasm puts them first in the string table). Local variable declarations and instructions, without the byte length (wasm.code-entry adds it)
core.compile-env-lookup: Fn(env: List<Record{variable_id: Number, local: Number}>, variable_id: Number, index: Number) -> Number  // Local index bound to the variable id in the compile environment (searched from the front), or -1
core.compile-string-bytes: Fn(bytes: List<Number>, index: Number, local: Number) -> List<Number>  // Instructions that store the bytes from index on into the string box held by the local
core.compile-string-bytes-range: Fn(bytes: List<Number>, lo: Number, hi: Number, local: Number) -> List<Number>  // i32.const instructions of the bytes lo..hi (for array.new_fixed of a string)
core.compile-string-literal: Fn(value: String, local: Number, strings: List<Record{value: String, address: Number}>) -> List<Number>  // Instructions that push the string value: global.get of the string table entry (core.compile-string-table), or a new string from array.new_fixed of the bytes when it is not in the table
core.compile-string-address: Fn(strings: List<Record{value: String, address: Number}>, value: String, index: Number) -> Number  // The address of the string box of value in the data segment (from index of the string table), or -1 if it is not there
core.compile-add-string: Fn(strings: List<String>, value: String) -> List<String>  // Adds value to the list of distinct strings unless it is already there
core.compile-add-record-keys: Fn(strings: List<String>, items: List<Record{key: String, value: @core.expression}>, index: Number) -> List<String>  // Adds the keys of record items, from index, to the list of distinct strings
core.compile-add-arm-tags: Fn(strings: List<String>, arms: List<@core.match-arm>, index: Number) -> List<String>  // Adds the tags of match arms other than _, from index, to the list of distinct strings
core.compile-add-pattern-strings: Fn(strings: List<String>, pattern: @core.pattern) -> List<String>  // Adds the variant tags and string literals of the pattern to strings
core.compile-collect-strings: Fn(expr: @core.expression, strings: List<String>) -> List<String>  // Adds the string literals, record keys, variant tags and match arm tags in expr to the list of distinct strings (they are put in the data segment)
core.compile-collect-strings-range: Fn(items: List<@core.expression>, lo: Number, hi: Number, strings: List<String>) -> List<String>  // core.compile-collect-strings of the expressions items from lo to hi. Splits the range in half so the recursion depth is O(log n)
core.compile-collect-part-strings: Fn(
    parts: List<Record{id: String, expression: @core.expression}>,
    index: Number,
    strings: List<String>
  ) -> List<String>  // (en) core.compile-collect-strings of the expressions of parts, from index (ja) parts の index 以降のパーツの式の core.compile-collect-strings
core.compile-string-table: Fn(strings: List<String>, index: Number, address: Number) -> List<Record{value: String, address: Number}>  // The string table [{value, address}]: address is the global index of the string (from address, one by one)
core.compile-string-data: Fn(strings: List<String>, index: Number) -> List<Number>  // The bytes of the strings of the string table, concatenated (the passive data segment 0 that core.compile-string-init reads)
core.match-arm-bodies: Fn(arms: List<@core.match-arm>, index: Number) -> List<@core.expression>  // Bodies of the match arms from index on
core.match-arm-bodies-range: Fn(arms: List<@core.match-arm>, lo: Number, hi: Number) -> List<@core.expression>  // match-arm-bodies over the index range [lo, hi). Splits the range in half so that the recursion depth is O(log n).
core.record-item-values: Fn(items: List<Record{key: String, value: @core.expression}>, index: Number) -> List<@core.expression>  // Values of the record fields from index on
core.record-item-values-range: Fn(items: List<Record{key: String, value: @core.expression}>, lo: Number, hi: Number) -> List<@core.expression>  // record-item-values over the index range [lo, hi). Splits the range in half so that the recursion depth is O(log n).
core.call-argument-values: Fn(arguments: List<Record{name: String, value: @core.expression}>, index: Number) -> List<@core.expression>  // Values of the call arguments from index on
core.call-argument-values-range: Fn(arguments: List<Record{name: String, value: @core.expression}>, lo: Number, hi: Number) -> List<@core.expression>  // call-argument-values over the index range [lo, hi). Splits the range in half so that the recursion depth is O(log n).
core.expression-children: Fn(expr: @core.expression) -> List<@core.expression>  // Direct sub-expressions in evaluation order (the order core.compile-expr-instructions numbers functions in)
core.is-function-expression: Fn(expr: @core.expression) -> Boolean  // Whether the expression is a function
core.is-type-expression: Fn(expr: @core.expression) -> Boolean  // Whether the expression is a type expression (type_number, type_list, type_union ...)
core.call-argument: Fn(arguments: List<Record{name: String, value: @core.expression}>, name: String) -> @core.expression  // The value of the argument with the name in a call, or an unfilled hole
core.call-argument-from: Fn(arguments: List<Record{name: String, value: @core.expression}>, name: String, index: Number) -> @core.expression  // core.call-argument searching from the index
core.call-argument-fn-base: Fn(
    arguments: List<Record{name: String, value: @core.expression}>,
    name: String,
    base: Number,
    index: Number
  ) -> Number  // (en) The index of the first function in the argument with the name, counting functions of the earlier arguments from base (core.collect-functions order) (ja) 名前が一致する引数の中の最初の関数の番号. base に前の引数の関数の数を足す (core.collect-functions の順)
core.builtin-parameters: Fn(name: String) -> List<String>  // Parameter names of the compiler built-in with the name, in order
core.builtin-function-type: Fn(name: String) -> Union{#none, #some(@core.type-ast)}  // The function type of a compiler built-in whose arguments and result have fixed types (the float operations). The type checker checks calls of these by this type
core.call-argument-names-match: Fn(
    parameters: List<String>,
    arguments: List<Record{name: String, value: @core.expression}>,
    index: Number
  ) -> Boolean  // (en) Whether the arguments of a call have exactly the parameter names in order (ja) 呼び出しの引数名が引数名の一覧と順番どおり一致するか
core.bytes-less-than: Fn(left: List<Number>, right: List<Number>, index: Number) -> Boolean  // Whether the byte list left comes before right in lexicographic order (from index)
core.string-less-than: Fn(left: String, right: String) -> Boolean  // Whether left comes before right in the lexicographic order of UTF-8 bytes
core.call-argument-find: Fn(arguments: List<Record{name: String, value: @core.expression}>, name: String, index: Number) -> Union{#none, #some(@core.expression)}  // The value of the argument named name, or none
core.call-argument-rank: Fn(
    arguments: List<Record{name: String, value: @core.expression}>,
    name: String,
    index: Number,
    acc: Number
  ) -> Number  // (en) The number of arguments whose names come before name. The argument is stored at this position at run time (ja) 名前が name より前 (`core.string-less-than`) の引数の数. 実行時は引数をこの位置に並べる
core.parameter-name-rank: Fn(
    parameters: List<Record{parameter_id: Number, parameter_name: String}>,
    name: String,
    index: Number,
    acc: Number
  ) -> Number  // (en) The number of parameters whose names come before name (ja) 名前が name より前の引数の数
core.parameter-name-duplicated: Fn(
    parameters: List<Record{parameter_id: Number, parameter_name: String}>,
    name: String,
    index: Number,
    count: Number
  ) -> Boolean  // (en) Whether two or more parameters (from index, counting count already) are named name (ja) 名前が name の引数が (index 番目以降と, 数えた count を合わせて) 2 つ以上あるか
core.parameter-with-rank: Fn(
    parameters: List<Record{parameter_id: Number, parameter_name: String}>,
    rank: Number,
    index: Number
  ) -> Union{#none, #some(Number)}  // (en) The ID of the parameter at position rank in the order of names (ja) 名前の順で rank 番目の引数の ID
core.function-parameter-ids-by-name: Fn(parameters: List<Record{parameter_id: Number, parameter_name: String}>, rank: Number) -> List<Number>  // The parameter IDs in the order of their names from rank. Arguments are passed in this order at run time
core.function-type-parameter-find: Fn(parameters: List<Record{name: String, type: @core.type-ast}>, name: String, index: Number) -> Union{#none, #some(@core.type-ast)}  // The type of the parameter named name in a function type, or none
core.count-functions-in-list: Fn(items: List<@core.expression>, count: Number) -> Number  // Number of function expressions (including nested ones) in the first count items
core.count-functions-in-range: Fn(items: List<@core.expression>, lo: Number, hi: Number) -> Number  // Number of function expressions in items[lo..hi). Splits the range in half so that the recursion depth is O(log n)
core.count-functions-in-values-range: Fn(items: List<Record{key: String, value: @core.expression}>, lo: Number, hi: Number) -> Number  // Number of function expressions in the value fields of record items[lo..hi)
core.count-functions: Fn(expr: @core.expression) -> Number  // The number of the function expressions in expr (expr itself included), counted by core.count-functions-acc without making lists of the children
core.collect-functions-in-list: Fn(items: List<@core.expression>, index: Number) -> List<@core.expression>  // Function expressions in the items from index on, in pre-order
core.collect-functions-in-list-range: Fn(items: List<@core.expression>, lo: Number, hi: Number) -> List<@core.expression>  // collect-functions-in-list over the index range [lo, hi). Splits the range in half so that the recursion depth is O(log n).
core.collect-functions: Fn(expr: @core.expression) -> List<@core.expression>  // Function expressions in the expression in pre-order. The position is the function's index in the function table
core.number-list-contains: Fn(list: List<Number>, value: Number, index: Number) -> Boolean  // Whether the list contains the number from index on
core.unique-numbers: Fn(list: List<Number>, index: Number, result: List<Number>) -> List<Number>  // The numbers from index on appended to result without duplicates, keeping the first occurrence order
core.function-parameter-ids: Fn(parameters: List<Record{parameter_id: Number, parameter_name: String}>, index: Number) -> List<Number>  // Ids of the function parameters from index on
core.function-parameter-ids-range: Fn(parameters: List<Record{parameter_id: Number, parameter_name: String}>, lo: Number, hi: Number) -> List<Number>  // function-parameter-ids over the index range [lo, hi). Splits the range in half so that the recursion depth is O(log n).
core.free-variables-in-list: Fn(items: List<@core.expression>, index: Number, bound: List<Number>) -> List<Number>  // Free variables of the items from index on (may contain duplicates)
core.free-variables-in-list-range: Fn(items: List<@core.expression>, lo: Number, hi: Number, bound: List<Number>) -> List<Number>  // free-variables-in-list over the index range [lo, hi). Splits the range in half so that the recursion depth is O(log n).
core.free-variables-in-arms: Fn(arms: List<@core.match-arm>, index: Number, bound: List<Number>) -> List<Number>  // Free variables of the match arm bodies from index on. Each arm's own variable is bound in its body
core.free-variables-in-arms-range: Fn(arms: List<@core.match-arm>, lo: Number, hi: Number, bound: List<Number>) -> List<Number>  // free-variables-in-arms over the index range [lo, hi). Splits the range in half so that the recursion depth is O(log n).
core.free-variables: Fn(expr: @core.expression, bound: List<Number>) -> List<Number>  // Variables used in the expression but not bound in it or in bound (may contain duplicates)
core.compile-captures: Fn(
    variables: List<Number>,
    index: Number,
    env: List<Record{variable_id: Number, local: Number}>,
    env_local: Number
  ) -> List<Number>  // (en) Instructions that store the captured variables from index on into the closure environment array held by env_local (0 for a variable not in env) (ja) env_local が指すクロージャの環境の配列に, index 以降の捕捉する変数を書く命令列 (env に無い変数は 0)
core.compile-captures-range: Fn(
    variables: List<Number>,
    lo: Number,
    hi: Number,
    env: List<Record{variable_id: Number, local: Number}>,
    env_local: Number
  ) -> List<Number>  // (en) Instructions that push the captured variables lo..hi (local.get, or ref.null when not bound) for array.new_fixed (ja) 捕捉した変数 lo..hi を積む命令列 (local.get, 束縛されていなければ ref.null)。array.new_fixed で配列にする
core.compile-load-slots: Fn(count: Number, index: Number, pointer_local: Number, first_local: Number) -> List<Number>  // Instructions that copy the i32 slots from index up to count of the array held by pointer_local into consecutive locals
core.compile-load-slots-range: Fn(count: Number, lo: Number, hi: Number, pointer_local: Number, first_local: Number) -> List<Number>  // Instructions that copy the items lo..hi of the array of values in the local pointer_local (the arguments or the captured variables) to the locals from first_local
core.compile-slot-env: Fn(variables: List<Number>, index: Number, first_local: Number) -> List<Record{variable_id: Number, local: Number}>  // Compile environment entries that bind the variables from index on to consecutive locals
core.compile-slot-env-range: Fn(variables: List<Number>, lo: Number, hi: Number, first_local: Number) -> List<Record{variable_id: Number, local: Number}>  // compile-slot-env over the index range [lo, hi). Splits the range in half so that the recursion depth is O(log n).

201–300 (of 499) Previous 100 Next 100