Languages connect through concrete symbol and type contracts. Each case includes both complete sources, expected values and the joint build steps. These additional cases have not been newly qualified natively.
Languages connect through concrete symbol and type contracts. Each case includes both complete sources, expected values and the joint build steps. These additional cases have not been newly qualified natively. Open full-size diagram

Bridging: use sources together

Languages connect through concrete symbol and type contracts. Each case includes both complete sources, expected values and the joint build steps. These additional cases have not been newly qualified natively.

B64 calls a C function

B64 declares external c_v8_add with two i64 parameters and an i64 result. C defines the same symbol using int64_t. The joint call produces 20 + 22 = 42. The provider has no main; B64 owns the program entry.

main_call_v8_c.b64

extern fn c_v8_add(a: i64, b: i64): i64;

fn main(): i64 {
    return c_v8_add(20, 22);
}

c_v8_add.c

#include <stdint.h>
int64_t c_v8_add(int64_t a, int64_t b) { return a + b; }
PBXB64.exe main_call_v8_c.b64 c_v8_add.c -o bridge.exe
.\bridge.exe
$LASTEXITCODE

Expected exit code: 42

Download both sources as ZIP

Canonical test case with an expected result; no new native V22 check here. Final execution pending.

BASIC and ASM share a variable and an array

ASM exports asm_imported_counter as dq 41 and an array of three dq values. BRIDGE IMPORT binds BASIC names to those symbols. The tests read 41, write 42 and check array elements. LONG and dq are both eight bytes here; link the sources together.

test_bridge_import_variable_asm.pb

#COMPILE EXE

FUNCTION PBMAIN() AS LONG
    BRIDGE IMPORT imported_counter AS LONG ALIAS "asm_imported_counter"
    IF imported_counter <> 41 THEN FUNCTION = 1: EXIT FUNCTION
    imported_counter = imported_counter + 1
    IF imported_counter <> 42 THEN FUNCTION = 2: EXIT FUNCTION
    BRIDGE IMPORT imported_values(0 TO 2) AS LONG ALIAS "asm_imported_values"
    IF imported_values(0) <> 10 THEN FUNCTION = 3: EXIT FUNCTION
    imported_values(1) = 42
    IF imported_values(1) <> 42 THEN FUNCTION = 4: EXIT FUNCTION
    IF imported_values(2) <> 30 THEN FUNCTION = 5: EXIT FUNCTION
    FUNCTION = 0
END FUNCTION

test_bridge_import_variable_asm.asm

section .data
global asm_imported_counter
asm_imported_counter dq 41
global asm_imported_values
asm_imported_values dq 10, 20, 30
PBXB64.exe test_bridge_import_variable_asm.pb test_bridge_import_variable_asm.asm -o bridge.exe
.\bridge.exe
$LASTEXITCODE

Expected exit code: 0

Download both sources as ZIP

Canonical test case with an expected result; no new native V22 check here. Final execution pending.

ASM reads a variable exported by BASIC

BRIDGE EXPORT exposes alias pb_exported_counter. ASM declares it extern and reads it relative to the instruction address. The second function reads array element 1 at an eight-byte offset. BASIC calls the ASM functions and expects 41 from each.

test_bridge_export_variable_asm.pb

#COMPILE EXE

DECLARE FUNCTION read_exported_counter() COMMON AS LONG
DECLARE FUNCTION read_exported_array() COMMON AS LONG

FUNCTION PBMAIN() AS LONG
    BRIDGE EXPORT exported_counter AS LONG ALIAS "pb_exported_counter"
    exported_counter = 41
    IF exported_counter <> 41 THEN FUNCTION = 1: EXIT FUNCTION
    IF read_exported_counter() <> 41 THEN FUNCTION = 2: EXIT FUNCTION
    BRIDGE EXPORT exported_values(0 TO 2) AS LONG ALIAS "pb_exported_values"
    exported_values(1) = 41
    IF read_exported_array() <> 41 THEN FUNCTION = 3: EXIT FUNCTION
    FUNCTION = 0
END FUNCTION

test_bridge_export_variable_asm.asm

section .text
global read_exported_counter
extern pb_exported_counter

read_exported_counter:
    mov rax, [rel pb_exported_counter]
    ret

global read_exported_array
extern pb_exported_values

read_exported_array:
    mov rax, [rel pb_exported_values + 8]
    ret
PBXB64.exe test_bridge_export_variable_asm.pb test_bridge_export_variable_asm.asm -o bridge.exe
.\bridge.exe
$LASTEXITCODE

Expected exit code: 0

Download both sources as ZIP

Canonical test case with an expected result; no new native V22 check here. Final execution pending.

PILOT and BASIC: two aliases to the same variable

The BASIC provider defines GLOBAL pilot_bridge_number AS QUAD = 40 and a STRING. V: binds numeric #variables and $strings to these GLOBAL names. After writing 42 or from-pilot, the second alias must see the new value. This is a typed live binding, not a simple copy.

pilot_pb_bridge.pil

R: V: creates live two-way bindings to PB GLOBAL variables.
V: #NUMBER|pilot_bridge_number|QUAD
V: #NUMBER_ALIAS|pilot_bridge_number|QUAD
V: $TEXT|pilot_bridge_text|STRING
V: $TEXT_ALIAS|pilot_bridge_text|STRING
C: #CHECK = #NUMBER - 40
N: T: "number-imported"
T: $TEXT
C: #NUMBER = 42
C: $TEXT = "from-pilot"
T: $TEXT_ALIAS
C: #CHECK = #NUMBER_ALIAS - 42
N: T: "number-exported"
E:

pilot_pb_bridge_globals.pb

GLOBAL pilot_bridge_number AS QUAD = 40
GLOBAL pilot_bridge_text AS STRING

SUB PilotBridgeGlobalsAnchor()
END SUB
PBXB64.exe pilot_pb_bridge_globals.pb -c -o provider.obj
PBXB64.exe pilot_pb_bridge.pil provider.obj -o bridge.exe
.\bridge.exe
$LASTEXITCODE

Expected exit code: 0

Download both sources as ZIP

Canonical test case with an expected result; no new native V22 check here. Final execution pending.

A numeric COBOL value in BASIC

COBOL provides GLOBAL SHARED-COUNT as PIC S9(9), initially 41. BASIC binds the name through the concrete numeric bridge contract, reads it and writes 42. This case covers numeric mapping, not arbitrary PIC-X strings or record layouts.

bridge_pb_import_numeric.pb

#COMPILE EXE
#DIM ALL

FUNCTION PBMAIN() AS LONG
    BRIDGE IMPORT shared_count AS QUAD ALIAS "SHARED-COUNT"
    PRINT shared_count
    shared_count = 42
    PRINT shared_count
    FUNCTION = 0
END FUNCTION

bridge_cobol_export_numeric.cbl

       IDENTIFICATION DIVISION.
       PROGRAM-ID. COBOLEXPORTNUMERIC.
       DATA DIVISION.
       WORKING-STORAGE SECTION.
       01 SHARED-COUNT PIC S9(9) VALUE 41 GLOBAL.
       PROCEDURE DIVISION.
           STOP RUN.
PBXB64.exe bridge_pb_import_numeric.pb bridge_cobol_export_numeric.cbl -o bridge.exe
.\bridge.exe
$LASTEXITCODE

Expected exit code: 0

Output contract: ' 41\n 42\n'

Download both sources as ZIP

Canonical test case with an expected result; no new native V22 check here. Final execution pending.

SPR: VIP. binds QUAD and STRING

The BASIC provider defines a QUAD initially 40 and a STRING. VIP. binds $$NUM and $$TXT to these GLOBAL names. CAL. increases the number to 42; VAS. sets the text to bridged. The canonical runner compiles BASIC to an object first, then links SPR with that object.

vip_pb_global_bridge.spr

' VIP. binds exact $$XXX SPR variables to PB GLOBAL AS QUAD and STRING.
VIP.$$NUM|spr_vip_num|QUAD
VIP.$$TXT|spr_vip_txt|STRING
CAL.$$NUM=$$NUM+2
VAS.$$TXT=bridged
PRT.$$NUM
PRT.$$TXT
END.

vip_pb_globals.pb

GLOBAL spr_vip_num AS QUAD = 40
GLOBAL spr_vip_txt AS STRING

SUB VipPbGlobalsAnchor()
END SUB
PBXB64.exe vip_pb_globals.pb -c -o provider.obj
PBXB64.exe vip_pb_global_bridge.spr provider.obj -o bridge.exe
.\bridge.exe
$LASTEXITCODE

Expected exit code: 0

Output contract: '42\nbridged'

Download both sources as ZIP

Canonical test case with an expected result; no new native V22 check here. Final execution pending.