Exemple #1
0
bool term_is_observable_after(Term* term, Term* location)
{
    // Check if "term" can be observed after the "location".
    //
    // Typically, "location" uses "term" as an input, and we're trying to decide
    // whether the call at "location" can move/consume the value.

    if (term_is_observable_for_special_reasons(term))
        return true;

    for (int i=0; i < user_count(term); i++) {
        Term* user = term_user(term, i);

        if (user->function == FUNCS.upvalue)
            return true;

        if (terms_are_in_different_switch_conditions(location, user))
            continue;

        if (term_accesses_input_from_inside_loop(user, term)) {

            bool userOnlyAccessesOnFirstIteration = is_input_placeholder(user)
                && user->numInputs() == 2
                && user->input(1) != term;

            if (!userOnlyAccessesOnFirstIteration)
                return true;
        }

        if (is_located_after(user, location))
            return true;
    }
 
    return false;
}
Exemple #2
0
bool term_used_by_nonlocal(Term* term)
{
    for (int i=0; i < user_count(term); i++) {
        Term* user = term_user(term, i);

        if (user->function == FUNCS.upvalue)
            return true;
    }
    return false;
}
Exemple #3
0
int main(int argc, char **argv)
{
	int n, len = 1024;
	char *cp = UNSPEC_EOL;
	int inet = 0;
	int logging = 0;

	while ((n = getopt(argc, argv, "ail")) != -1) {
		switch (n) {
		case 'a':
			cp = AX25_EOL;
			len = 128;
			break;
		case 'i':
			cp = INET_EOL;
			inet = 1;
			break;
		case 'l':
			logging = 1;
			break;

		default:
			fprintf(stderr, "usage: nodeusers [-a] [-i] [-l]\r\n");
			return 1;
                }
        }
	if (logging)
		openlog("nodeusers", LOG_PID, LOG_DAEMON);
	signal(SIGPIPE, pipe_handler);
	NodeIo = axio_init(STDIN_FILENO, STDOUT_FILENO, len, cp);
	if (NodeIo == NULL) {
		fprintf(stderr, "nodeusers: axio_init failes\r\n");
		return 1;
	}
	if (inet && axio_getline(NodeIo) == NULL) {
		if (logging)
			syslog(LOG_ERR, "axio_getline: %m");
		axio_printf(NodeIo,"\n");
		axio_end(NodeIo);
		return 1;
	}
	n = user_count();
	axio_printf(NodeIo,"\n%s (%s), %d user%s.\n",
		VERSION, COMPILING, n, n == 1 ? "" : "s");
	user_list(0, NULL);
	if (n > 0)
		axio_printf(NodeIo,"\n");
	if (axio_flush(NodeIo) == -1 && logging)
		syslog(LOG_ERR, "axio_flush: %m");
	axio_end(NodeIo);
	usleep(500000L);
	closelog();
	return 0;
}
Exemple #4
0
bool term_is_observable(Term* term)
{
    if (term_is_observable_for_special_reasons(term))
        return true;

    if (user_count(term) == 0)
        return false;

    // Future: Some more smarts here

    return true;
}
Exemple #5
0
bool loop_produces_output_value(Term* forTerm)
{
    ca_assert(forTerm->function == FUNCS.for_func);
    return user_count(forTerm) > 0;
}