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

Function fxInitializeRegExp

xs/sources/xsRegExp.c:147–171  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

145#endif
146
147void fxInitializeRegExp(txMachine* the)
148{
149#if mxRegExp
150 txSlot* instance = fxToInstance(the, mxThis);
151 txSlot* regexp = instance->next;
152 txSlot* key = regexp->next;
153 txString pattern;
154 txString modifier;
155
156 if (mxArgv(0)->kind == XS_UNDEFINED_KIND)
157 *mxArgv(0) = mxEmptyString;
158 else
159 fxToString(the, mxArgv(0));
160 if (mxArgv(1)->kind == XS_UNDEFINED_KIND)
161 *mxArgv(1) = mxEmptyString;
162 else
163 fxToString(the, mxArgv(1));
164 key->kind = (mxArgv(0)->kind == XS_STRING_X_KIND) ? XS_KEY_X_KIND : XS_KEY_KIND;
165 pattern = key->value.key.string = mxArgv(0)->value.string;
166 modifier = mxArgv(1)->value.string;
167 if (!fxCompileRegExp(the, pattern, modifier, &regexp->value.regexp.code, &regexp->value.regexp.data, the->nameBuffer, sizeof(the->nameBuffer)))
168 mxSyntaxError("invalid regular expression: %s", the->nameBuffer);
169 *mxResult = *mxThis;
170#endif
171}
172
173txBoolean fxIsRegExp(txMachine* the, txSlot* slot)
174{

Callers

nothing calls this directly

Calls 3

fxToInstanceFunction · 0.85
fxToStringFunction · 0.85
fxCompileRegExpFunction · 0.85

Tested by

no test coverage detected