示例#1
0
文件: protoREGEX.c 项目: da4089/NEWT0
newtRef protoREGEX_match(newtRefArg rcvr, newtRefArg str)
{
	newtRefVar  preg;
	newtRefVar  r;

	if (NewtRefIsNIL(rcvr))
		return kNewtRefUnbind;

	NcSetSlot(rcvr, NSSYM(_matchs), kNewtRefNIL);
	preg = NcGetSlot(rcvr, NSSYM(_preg));

	if (NewtRefIsNIL(preg))
	{
		protoREGEX_compile(rcvr);
		preg = NcGetSlot(rcvr, NSSYM(_preg));

		if (NewtRefIsNIL(preg))
			return kNewtRefNIL;
	}

	r = protoREGEX_regexec(preg, str);

	NcSetSlot(rcvr, NSSYM(_matchs), r);

	return r;
}
示例#2
0
文件: NewtFns.c 项目: pablomarx/NEWT0
newtRef NcFullLookupFrame(newtRefArg start, newtRefArg name)
{
    newtRefVar	current;
    newtRefVar	left = start;

	if (! NewtRefIsFrame(start))
		return kNewtRefUnbind;

    while (NewtRefIsNotNIL(left))
    {
        current = left;

        while (NewtRefIsNotNIL(current))
        {
			current = NcResolveMagicPointer(current);

			if (NewtRefIsMagicPointer(current))
				return kNewtRefUnbind;

            if (NewtHasSlot(current, name))
                return current;
    
            current = NcGetSlot(current, NSSYM0(_proto));
        }

        left = NcGetSlot(left, NSSYM0(_parent));
    }

    return kNewtRefUnbind;
}
示例#3
0
文件: protoREGEX.c 项目: da4089/NEWT0
newtRef protoREGEX_compile(newtRefArg rcvr)
{
	newtRefVar	preg;

	if (NewtRefIsNIL(rcvr))
		return kNewtRefUnbind;

	preg = protoREGEX_regcomp(NcGetSlot(rcvr, NSSYM(pattern)), NcGetSlot(rcvr, NSSYM(option)));

	return NcSetSlot(rcvr, NSSYM(_preg), preg);
}
示例#4
0
文件: NewtFns.c 项目: pablomarx/NEWT0
newtRef NcLexicalLookup(newtRefArg start, newtRef name)
{
    newtRefVar	current = start;

    while (NewtRefIsNotNIL(current))
    {
		current = NcResolveMagicPointer(current);

		if (NewtRefIsMagicPointer(current))
			return kNewtRefUnbind;

        if (NewtHasSlot(current, name))
            return NcGetSlot(current, name);

        current = NcGetSlot(current, NSSYM0(_nextArgFrame));
    }

    return kNewtRefUnbind;
}
示例#5
0
文件: NewtFns.c 项目: pablomarx/NEWT0
newtRef NcProtoLookup(newtRefArg start, newtRefArg name)
{
    newtRefVar	current;

	current = NcProtoLookupFrame(start, name);

	if (current != kNewtRefUnbind)
		return NcGetSlot(current, name);
	else
		return kNewtRefUnbind;
}
示例#6
0
文件: NewtEnv.c 项目: morgant/NEWT0
newtRef NcResolveNamedMP(newtRefArg r)
{
	newtRefVar	sym;

	if (! NewtRefIsNamedMP(r))
		return r;

	sym = NewtMPToSymbol(r);

	if (NewtHasSlot(NAMED_MPS, sym))
		return NcGetSlot(NAMED_MPS, sym);
	else
		return r;
}
示例#7
0
文件: protoREGEX.c 项目: da4089/NEWT0
newtRef protoREGEX_cleanup(newtRefArg rcvr)
{
	newtRefVar  preg;

	if (NewtRefIsNIL(rcvr))
		return kNewtRefUnbind;

	NcSetSlot(rcvr, NSSYM(_matchs), kNewtRefNIL);
	preg = NcGetSlot(rcvr, NSSYM(_preg));

	if (NewtRefIsNotNIL(preg))
	{
		protoREGEX_regfree(preg);
		NcSetSlot(rcvr, NSSYM(_preg), kNewtRefNIL);
	}

	return kNewtRefNIL;
}
示例#8
0
文件: NewtEnv.c 项目: morgant/NEWT0
newtRef NsGetGlobalVar(newtRefArg rcvr, newtRefArg r)
{
    return NcGetSlot(GLOBALS, r);
}
示例#9
0
文件: NewtEnv.c 项目: morgant/NEWT0
newtRef NsGetGlobalFn(newtRefArg rcvr, newtRefArg r)
{
    return NcGetSlot(GLOBAL_FNS, r);
}