MCPcopy Create free account
hub / github.com/Moddable-OpenSource/moddable / main

Function main

examples/js/repl/mac/repl.c:85–139  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

83}
84
85int main(int argc, char* argv[])
86{
87 static txMachine root;
88 int error = 0;
89 txMachine* machine = &root;
90 txPreparation* preparation = xsPreparation();
91 struct termios tio;
92
93 tcgetattr(STDIN_FILENO, &gTIO);
94 tio = gTIO;
95 tio.c_lflag &= ~(ICANON | ECHO);
96 tcsetattr(STDIN_FILENO, TCSANOW, &tio);
97
98 atexit(restoreTerminal);
99
100 c_memset(machine, 0, sizeof(txMachine));
101 machine->preparation = preparation;
102 machine->keyArray = preparation->keys;
103 machine->keyCount = (txID)preparation->keyCount + (txID)preparation->creation.initialKeyCount;
104 machine->keyIndex = (txID)preparation->keyCount;
105 machine->nameModulo = preparation->nameModulo;
106 machine->nameTable = preparation->names;
107 machine->symbolModulo = preparation->symbolModulo;
108 machine->symbolTable = preparation->symbols;
109
110 machine->stack = &preparation->stack[0];
111 machine->stackBottom = &preparation->stack[0];
112 machine->stackTop = &preparation->stack[preparation->stackCount];
113
114 machine->firstHeap = &preparation->heap[0];
115 machine->freeHeap = &preparation->heap[preparation->heapCount - 1];
116 machine->aliasCount = (txID)preparation->aliasCount;
117
118 machine = fxCloneMachine(&preparation->creation, machine, "tool", NULL);
119
120#ifdef mxInstrument
121 fxDescribeInstrumentation(machine, 0, NULL, NULL);
122#endif
123 xsBeginHost(machine);
124 {
125 xsVars(2);
126#ifdef mxInstrument
127 fxSampleInstrumentation(the, 0, NULL);
128#endif
129 {
130 xsTry {
131 xsResult = xsAwaitImport("main", XS_IMPORT_NAMESPACE);
132 }
133 xsCatch {
134 xsStringValue message = xsToString(xsException);
135 fprintf(stderr, "### %s\n", message);
136 error = 1;
137 }
138 }
139 }
140 xsEndHost(the);
141 xsDeleteMachine(machine);
142 return error;

Callers

nothing calls this directly

Calls 3

fxCloneMachineFunction · 0.85
fxSampleInstrumentationFunction · 0.85

Tested by

no test coverage detected