#include "stdafx.h" #include "paxcompilerlib.h" struct TMyPoint { long x; long y; }; int main(int argc, char* argv[]) { HMODULE h_lib = LoadPaxCompilerLib(); if (h_lib != 0) { TMyPoint MyPoint; MyPoint.x = 60; MyPoint.y = 23; DWORD hc = PaxCompiler_Create(); DWORD hl = PaxPascalLanguage_Create(); DWORD hp = PaxProgram_Create(); PaxCompiler_Reset(hc); PaxCompiler_RegisterLanguage(hc, hl); // register host-defined type DWORD H_TMyPoint = PaxCompiler_RegisterRecordType(hc, 0, "TMyPoint"); PaxCompiler_RegisterRecordTypeField(hc, H_TMyPoint, "X", PaxTypeLONG); PaxCompiler_RegisterRecordTypeField(hc, H_TMyPoint, "Y", PaxTypeLONG); // register host-defined variable DWORD H_MyPoint = PaxCompiler_RegisterVariable(hc, 0, "MyPoint", H_TMyPoint); PaxCompiler_AddModule(hc, "1", "Pascal"); PaxCompiler_AddCode(hc, "1", "begin"); PaxCompiler_AddCode(hc, "1", " MyPoint.Y := 8;"); PaxCompiler_AddCode(hc, "1", "end."); if (PaxCompiler_Compile(hc, hp)) { // set address of the variable PaxProgram_SetAddress(hp, H_MyPoint, &MyPoint); PaxProgram_Run(hp); printf("MyPoint.y = %d\n", MyPoint.y); } else { printf("there are errors:\n"); for (int i = 0; i < PaxCompiler_GetErrorCount(hc); i++) { printf(PaxCompiler_GetErrorMessage(hc, i)); } } PaxProgram_Destroy(hp); PaxPascalLanguage_Destroy(hl); PaxCompiler_Destroy(hc); } FreePaxCompilerLib(h_lib); getchar(); return 0; }