Beispiel #1
0
    std::shared_ptr<context> create_context(std::shared_ptr<context> share_context)
    {
        if (!current_context_impl)
        {
            current_context_impl = std::make_shared<desktop_gl_impl::context>();
        }

        if (share_context != nullptr && share_context->impl() != current_context_impl)
        {
            log_context_error(context_error("cannot share between contexts with different implementations."));
            return nullptr;
        }

        std::shared_ptr<context> ctx = std::make_shared<context>(current_context_impl, share_context);
        all_contexts.insert(ctx);
        return ctx;
    }
Beispiel #2
0
static void word_check_next_char (parser *p)
{
#if LDEBUG
    if (p->ch) fprintf(stderr, "word_check_next_char: ch = '%c'\n", p->ch);
    else fprintf(stderr, "word_check_next_char: ch = NUL\n");
#endif

    if (p->ch == '(') {
	/* series (lag) or function */
	if (p->sym == UVEC) {
	    if (p->idnum > 0 && p->idnum == p->lh.v) {
		p->flags |= P_AUTOREG;
	    }
	    p->sym = LAG;
	} else if (p->sym == MVAR && model_data_matrix(p->idnum)) {
	    /* old-style "$coeff(x1)" etc. */
	    p->sym = DMSTR;
	} else if (!func1_symb(p->sym) && 
		   !func2_symb(p->sym) &&
		   !func3_symb(p->sym) &&
		   !funcn_symb(p->sym) && 
		   p->sym != UFUN && 
		   p->sym != RFUN) {
	    p->err = E_PARSE;
	} 
    } else if (p->ch == '[') {
	if (p->sym == UMAT) {
	    /* slice of user matrix */
	    p->sym = MSL;
	} else if ((p->sym == MVAR || p->sym == DVAR) && 
		   could_be_matrix(p->idnum)) {
	    /* slice of $ matrix */
	    p->sym = DMSL;
	} else if (p->sym == UVEC) {
	    /* observation from series */
	    p->sym = OBS;
	} else if (p->sym == DVAR && dollar_series(p->idnum)) {
	    /* observation from "dollar" series */
	    p->sym = DOBS;
	} else if (p->sym == ULIST) {
	    /* element of list */
	    p->sym = LISTELEM;
	} else if (p->sym == MVAR && model_data_list(p->idnum)) {
	    /* element of accessor list */
	    p->sym = MLISTELEM;
	} else if (p->sym == BUNDLE) {
	    /* object from bundle */
	    p->sym = BOBJ;
	} else {
	    p->err = E_PARSE;
	} 
    } else if (p->ch == '.' && *p->point == '$') {
	if (p->sym == UOBJ) {
	    /* name of saved object followed by dollar variable? */
	    p->sym = OVAR;
	} else if (p->sym == STR) {
	    /* maybe quoted name of saved object followed by 
	       dollar variable? */
	    p->sym = OVAR;
	} else {
	    p->err = E_PARSE;
	}	    
    } else if (p->ch == '.' && isalpha(*p->point)) {
	if (p->sym == ULIST) {
	    p->sym = LISTVAR;
	} else if (p->sym == BUNDLE) {
	    p->sym = BMEMB;
	} else {
	    p->err = E_PARSE;
	}
    } else if (p->ch == '+' && *p->point == '+') {
	maybe_treat_as_postfix(p);
    } else if (p->ch == '-' && *p->point == '-') {
	maybe_treat_as_postfix(p);
    }	

    if (p->err) {
	context_error(p->ch, p);
    } 
}