void MainWindow::openUrl(const QString &text)
{
	if (text.isEmpty())
	{
		m_windowsManager->triggerAction(ActionsManager::NewTabAction);

		return;
	}
	else
	{
		InputInterpreter *interpreter(new InputInterpreter(this));

		connect(interpreter, SIGNAL(requestedOpenBookmark(BookmarksItem*,WindowsManager::OpenHints)), m_windowsManager, SLOT(open(BookmarksItem*,WindowsManager::OpenHints)));
		connect(interpreter, SIGNAL(requestedOpenUrl(QUrl,WindowsManager::OpenHints)), m_windowsManager, SLOT(open(QUrl,WindowsManager::OpenHints)));
		connect(interpreter, SIGNAL(requestedSearch(QString,QString,WindowsManager::OpenHints)), m_windowsManager, SLOT(search(QString,QString,WindowsManager::OpenHints)));

		interpreter->interpret(text, ((!m_workspace->getActiveWindow() || Utils::isUrlEmpty(m_workspace->getActiveWindow()->getUrl())) ? WindowsManager::CurrentTabOpen : WindowsManager::NewTabOpen));
	}
}
Exemple #2
0
static void executeCreateQuery(
	const String & query,
	Context & context,
	const String & database,
	const String & file_name,
	ThreadPool & pool,
	bool has_force_restore_data_flag)
{
	ParserCreateQuery parser;
	ASTPtr ast = parseQuery(parser, query.data(), query.data() + query.size(), "in file " + file_name);

	ASTCreateQuery & ast_create_query = typeid_cast<ASTCreateQuery &>(*ast);
	ast_create_query.attach = true;
	ast_create_query.database = database;

	InterpreterCreateQuery interpreter(ast, context);
	interpreter.setDatabaseLoadingThreadpool(pool);
	interpreter.setForceRestoreData(has_force_restore_data_flag);
	interpreter.execute();
}
Exemple #3
0
/* Filter hook procedure, called whenever a new filter is created. This
   performs preflight checks (checking for DCTDecode filter and calling
   mischook). */
Bool ps_filter_preflight(FILELIST *filter)
{
  OBJECT *ocompress_jpeg = &get_core_context_interp()->mischookparams->CompressJPEG;

  HQASSERT(filter, "No filter in hook") ;

  /* part of the EP2000 preflight checks. Must be handled here rather than in
   * DCTDecode specific code in case an external JPEG input plugin is in use.
   */
  if ( oType(*ocompress_jpeg) != ONULL &&
       HqMemCmp(theICList(filter), theINLen(filter),
                NAME_AND_LENGTH("DCTDecode")) == 0 ) {
    if ( ! push( ocompress_jpeg, & executionstack ) )
      return FALSE ;
    if ( ! interpreter( 1 , NULL ))
      return FALSE ;
  }

  return TRUE ;
}
Exemple #4
0
/*	Compile the source code using the constructed Abstract Syntax Tree 
	Arguments are the root nodes of -
	1) Global declaration AST,
	2) Function definitions AST
	3) main() function definition AST
	*/
void compile(Tnode *gdeclroot,Tnode *fdefroot,Tnode *mainroot)
{
	error = 0;
	
	locpos = -1;
	labelcnt = 0;
	globalInstall(gdeclroot);
	
	if(fdefroot != NULL)
	{
		funcSemanticCheck(fdefroot);
		checkFuncDecl(fdefroot->LINE);
		funcSemanticCheck(mainroot);
	}
	
	printf("\nRUN - \n");
	if(error == 0)
	{
		module = INTERPRET;
		Gallocate();
		funcroot = fdefroot;
		mroot = mainroot;
		
		struct Lsymbol *Ltable;
		Ltable = NULL;
		interpreter(mainroot,&Ltable);
		
		get = 0;
		fre = 0;
		
		regcnt = -1;
		module = CODEGEN;
		fp = fopen("SIM_Simulator/SIMcode","w");
		funcCodeGen(fdefroot);
		funcCodeGen(mainroot);
		callToMain();
		
		fclose(fp);
	}
}
Exemple #5
0
Interpreter Interpreter::fromElement(XERCESC_NS::DOMElement* scxml, const std::string& baseURL) {
	URL absUrl = normalizeURL(baseURL);

	std::shared_ptr<InterpreterImpl> interpreterImpl(new InterpreterImpl());
	Interpreter interpreter(interpreterImpl);

	// *copy* the given XERCESC_NS::DOM to get rid of event listeners
	XERCESC_NS::DOMImplementation* implementation = XERCESC_NS::DOMImplementationRegistry::getDOMImplementation(X("core"));
	interpreterImpl->_document = implementation->createDocument();

	// we need to import the parent - to support xpath test150
	XERCESC_NS::DOMNode* newNode = interpreterImpl->_document->importNode(scxml, true);
//    interpreterImpl->_document->adoptNode(newNode);
	interpreterImpl->_document->appendChild(newNode);

//    std::cerr << *(interpreterImpl->_document);

	interpreterImpl->_baseURL = absUrl;

	InterpreterImpl::addInstance(interpreterImpl);
	return interpreter;
}
void input_controler (INPUT_DESC *input, int status)
{
	char command[256];
					
	if ((move_active == 1) &&
	    (input->mouse_button == GLUT_LEFT_BUTTON) &&
	    (input->mouse_state == GLUT_DOWN))
	{
		sprintf (command, "move %s to %d, %d;", input->name, input->wxd, input->wyd);
		interpreter (command);
		
	}
	
	if ((move_active == 1) &&
	    (input->mouse_button == GLUT_LEFT_BUTTON) &&
	    (input->mouse_state == GLUT_DOWN))
	{
		
	}
	
	input->mouse_button = -1;
}
Exemple #7
0
Interpreter Interpreter::fromURL(const std::string& url) {
	URL absUrl = normalizeURL(url);

	std::shared_ptr<InterpreterImpl> interpreterImpl(new InterpreterImpl());
	Interpreter interpreter(interpreterImpl);

	std::unique_ptr<XERCESC_NS::XercesDOMParser> parser(new XERCESC_NS::XercesDOMParser());
	parser->setValidationScheme(XERCESC_NS::XercesDOMParser::Val_Always);
	parser->setDoNamespaces(true);

	// we do not have a real schema anyway
	parser->useScanner(XERCESC_NS::XMLUni::fgWFXMLScanner);

	std::unique_ptr<XERCESC_NS::ErrorHandler> errHandler(new XERCESC_NS::HandlerBase());
	parser->setErrorHandler(errHandler.get());


	try {
		std::string tmp = absUrl;
		parser->parse(tmp.c_str());
		interpreterImpl->_document = parser->adoptDocument();
		interpreterImpl->_baseURL = absUrl;
		InterpreterImpl::addInstance(interpreterImpl);
	}

	catch (const XERCESC_NS::SAXParseException& toCatch) {
		LOGD(USCXML_ERROR) << X(toCatch.getMessage());
	} catch (const XERCESC_NS::RuntimeException& toCatch) {
		LOGD(USCXML_ERROR) << X(toCatch.getMessage());
	} catch (const XERCESC_NS::XMLException& toCatch) {
		LOGD(USCXML_ERROR) << X(toCatch.getMessage());
	} catch (const XERCESC_NS::DOMException& toCatch) {
		LOGD(USCXML_ERROR) << X(toCatch.getMessage());
	}

	return interpreter;

}
Exemple #8
0
	bool run_test(std::string const &test_name,
				  std::string const &source,
				  ValuePredicate const &check_result,
				  std::ostream &out)
	{
		source_range const source_range((source.data()), source.data() + source.size());
		auto const program = compile_unit(source_range);
		run::default_garbage_collector gc;
		run::interpreter interpreter(gc, nullptr);
		run::value result;
		auto const duration = measure_running_duration([&result, &program, &interpreter, &gc]()
		{
			result = interpreter.call(
				intermediate::function_ref(program, program.functions().front()), {});
			gc.sweep(run::sweep_mode::full);
		});
		out << test_name << " \t";
		bool const is_success = check_result(result);
		out << (is_success ? "succeeded" : "failed") << " in \t";
		print_running_duration(out, duration);
		out << '\n';
		return is_success;
	}
Exemple #9
0
void xeq( void )
{
	cell * volatile savedlc = ((cell *) (intptr_t) *(lc+1)) + D_BODY - 1;
	int sig;
	sig = setjmp( rexeq );

	switch( sig ) {
	/* here's where to have different actions for different aborts */
	case 0 : /* first time through */
		break;
	case 1 : put_c_string( "\nSoftware abort\n" );
		break;
	case 2 : put_c_string( "\nUndefined instruction\n" );
		break;
	case 3 : put_c_string( "\nSoftware interrupt\n" );
		break;
	case 4 : put_c_string( "\nMemory access error\n" );
		break;
	case 6 : put_c_string( "\nUncaught IRQ\n" );
		break;
	case 7 : put_c_string( "\nUncaught FIQ\n" );
		break;
	case 8 : put_c_string( "\nInterrupted\n" );
		break;
	default:
		put_c_string( "\nUnknown condition\n" );
		break;
	}
	
	if( sig ) primitive_io_abort();	/* reset input after restart */
	
	sp = stack + STACK_DIM;
	rsp = rstack + RSTACK_DIM;
 	lc = savedlc;
	fussy();		/* returns if fast interpreter requested */
	interpreter();					/* Never returns */
}
Exemple #10
0
int main(void)
{
  printf("libc running\n");
  /* inst p1[]={quit, emit, emit, emit, dup, dup, FIXNUM(42), lit}; */
  /* inst p2[]={quit, emit, truefalse, 'f', blit ,'t', blit, FIXNUM(0), lit}; */
  /* inst p3[]={quit, emit, truefalse, FIXNUM('f'), lit, FIXNUM('t'), lit, FIXNUM(1), lit}; */
  /* inst twostar[]={qend,emit,emit,dup,FIXNUM(42),lit}; */
  /* inst onestar[]={qend,emit,FIXNUM(42),lit}; */
  /* inst p4[]={quit,CALL(ifquot),CALL(twostar), lit, CALL(onestar), lit, FIXNUM(0),lit}; */
  /* inst loop[]={recurse,CALL(ifquot),  qend,sub,one,emit,dup,qstart,  qend,quit,drop,qstart,   eql,'0',blit,dup}; */
  /* inst p5[]={CALL(loop),'5',blit}; */
  /* interpreter((inst*)TBEGIN(p2)); */
  /* interpreter((inst*)TBEGIN(p3)); */
  /* interpreter((inst*)TBEGIN(p4)); */
  /* interpreter(&p1[sizeof(p1)/sizeof(inst)-1]); */
  /* interpreter((inst*)TBEGIN(p5)); */
#if !STOP_ON_ERROR
  while (1) {
#endif
    interpreter(START_WORD_OFFSET);
#if !STOP_ON_ERROR
  }
#endif
}
Exemple #11
0
Interpreter Interpreter::fromDocument(XERCESC_NS::DOMDocument* dom, const std::string& baseURL, bool copy) {
	URL absUrl = normalizeURL(baseURL);

	std::shared_ptr<InterpreterImpl> interpreterImpl(new InterpreterImpl());
	Interpreter interpreter(interpreterImpl);

	if (copy) {
		// *copy* the given XERCESC_NS::DOM to get rid of event listeners
		XERCESC_NS::DOMImplementation* implementation = XERCESC_NS::DOMImplementationRegistry::getDOMImplementation(X("core"));
		interpreterImpl->_document = implementation->createDocument();

		// we need to import the parent - to support xpath test150
		XERCESC_NS::DOMNode* newNode = interpreterImpl->_document->importNode(dom->getDocumentElement(), true);
		interpreterImpl->_document->appendChild(newNode);

	} else {
		interpreterImpl->_document = dom;
	}

	interpreterImpl->_baseURL = absUrl;

	InterpreterImpl::addInstance(interpreterImpl);
	return interpreter;
}
Exemple #12
0
QVector<QObject *>* QSAEditor::interfaceObjects( const QSObject &o ) const
{
    return interpreter()->wrapperClass()->objectVector( &o );
}
Exemple #13
0
QSEnv *QSAEditor::env() const
{
    return interpreter()->env();
}
Foam::SwakScriptableInjection<CloudType>::SwakScriptableInjection
(
    const dictionary& dict,
    CloudType& owner
#ifdef FOAM_INJECT_CONSTRUCTOR_HAS_MODELNAME
    ,const word& modelName
#endif
)
:
    InjectionModel<CloudType>(
        dict, owner, typeName
#ifdef FOAM_INJECT_CONSTRUCTOR_HAS_MODELNAME
    ,modelName
#endif
    ),
    interpreter_(
        generalInterpreterWrapper::New(
            owner.mesh(),
            this->coeffDict()
        )
    ),
    parameterStructName_(
        this->coeffDict().lookup("parameterStructName")
    ),
    resultStructName_(
        this->coeffDict().lookup("resultStructName")
    ),
    injectByEvent_(
        readBool(
            this->coeffDict().lookup("injectByEvent")
        )
    ),
    isActive_(false),
    plannedDuration_(1e10)
{
    interpreter().readCode(
        this->coeffDict(),
        "initInjector",
        initInjectorCode_
    );
    if(injectByEvent_) {
        interpreter().readCode(
            this->coeffDict(),
            "doStartInjection",
            doStartInjectionCode_
        );
        interpreter().readCode(
            this->coeffDict(),
            "doStopInjection",
            doStopInjectionCode_
        );
    } else {
        interpreter().readCode(
            this->coeffDict(),
            "injectionDuration",
            injectionDurationCode_
        );
        interpreter().readCode(
            this->coeffDict(),
            "startOfInjectionTime",
            startOfInjectionTimeCode_
        );
    }

    interpreter().readCode(
        this->coeffDict(),
        "parcelsToInject",
        parcelsToInjectCode_
    );
    interpreter().readCode(
        this->coeffDict(),
        "volumeToInject",
        volumeToInjectCode_
    );

    interpreter().readCode(
        this->coeffDict(),
        "prepareParcelData",
        prepareParcelDataCode_
    );
    interpreter().readCode(
        this->coeffDict(),
        "particleProperties",
        particlePropertiesCode_
    );

    Info << "Executing initialization code for "
        << this->owner().name() << endl;
    interpreter().executeCode(
        initInjectorCode_,
        true // set global variables if necessary
    );
}
Exemple #15
0
/**
 * Main function for the cqpserver app.
 */
int
main(int argc, char *argv[])
{
  int cmd;

  which_app = cqpserver;

  /* TODO: shouldn't these come AFTER initialize_cqp(), as that function may overwrite these values with defaults?
   * or maybe I've missed some subtlety here....*/
  silent = 1; 
  paging = autoshow = auto_save = 0;

  if (!initialize_cqp(argc, argv)) {
   Rprintf( "CQPserver: ERROR Couldn't initialise CQP engine.\n");
    rcqp_receive_error(1);
  }
  cqiserver_welcome();

  if (localhost) {
    add_host_to_list("127.0.0.1"); /* in -L mode, connections from localhost are automatically accepted  */
  }

  if (0 < accept_connection(server_port)) {
    if (server_log)
     Rprintf("CQPserver: Connected. Waiting for CONNECT request.\n");
  }
  else {
   Rprintf( "CQPserver: ERROR Connection failed.\n");
    rcqp_receive_error(1);
  }

  /* establish CQi connection: wait for CONNECT request */
  cmd = cqi_read_command();
  if (cmd != CQI_CTRL_CONNECT) {
    if (server_log)
     Rprintf("CQPserver: Connection refused.\n");
    cqiserver_wrong_command_error(cmd);
  }
  user = cqi_read_string();
  passwd = cqi_read_string();
  if (server_log)
   Rprintf("CQPserver: CONNECT  user = '******'  passwd = '%s'  pid = %d\n", user, passwd, (int)getpid());

  /* check password here (always required !!) */
  if (!authenticate_user(user, passwd)) {
   Rprintf("CQPserver: Wrong username or password. Connection refused.\n"); /* TODO shouldn't this be to stderr as it is not conditional on server_log? */
    cqi_command(CQI_ERROR_CONNECT_REFUSED);
  }
  else {
    cqi_command(CQI_STATUS_CONNECT_OK);

    /* re-randomize for query lock key generation */
    cl_randomize();

    /* check which corpora the user is granted access to */
    {
      CorpusList *cl = FirstCorpusFromList();
      while (cl != NULL) {
        if (!check_grant(user, cl->name))
          dropcorpus(cl);
        cl = NextCorpusFromList(cl);
      }
    }

    /* start command interpreter loop */
    interpreter();

    if (server_log)
     Rprintf("CQPserver: User '%s' has logged off.\n", user);
  }

  /* connection terminated; clean up and exit */
 Rprintf("CQPserver: Exit. (pid = %d)\n", (int)getpid());

  /* TODO should we check cqp_error_status as in the main cqp app? */
  return 0;
}
Exemple #16
0
	const Options& options() { return interpreter().options(); }
RegisterFile* CallFrame::registerFile()
{
    return &interpreter()->registerFile();
}
Exemple #18
0
void Befunge::interpret(std::istream& in, std::ostream& out)
{
    interpreter(in, out);
}
Exemple #19
0
int evalBody(Tnode *root,struct Lsymbol **Lhead)
{
	int t;
	struct Gsymbol *gnode;
	struct Lsymbol *lnode;
	
	if(root == NULL)
		return;
	
	switch(root->NODETYPE)
	{
		case CONTINUE		:	evalBody(root->Ptr1,Lhead);
								return evalBody(root->Ptr2,Lhead);
		
		case FUNCCALL		:	gnode = Glookup(root->NAME);
								Arghead = gnode->ARGLIST;
								
								struct Lsymbol *Ltable;
								Ltable = NULL;
								
								if(Arghead != NULL)
									funcParamInstall(root->Ptr1,Lhead,&Ltable);
								
								tempnode = searchFunc(root->NAME,funcroot);
								return interpreter(tempnode,&Ltable);
		
		case IDADDR			:	lnode = Llookup(root->NAME,Lhead);
								gnode = Glookup(root->NAME);
								
								if(lnode != NULL)
									binding = lnode->BINDING;
								else binding = gnode->BINDING;
								
								return *binding;
		
		case RET			:	return evalBody(root->Ptr1,Lhead);
		
		case ITERATIVE		:	while(evalBody(root->Ptr1,Lhead))
									evalBody(root->Ptr2,Lhead);
								return;
		
		case CONDITIONAL	:	if(evalBody(root->Ptr1,Lhead))
									evalBody(root->Ptr2,Lhead);
								else
									evalBody(root->Ptr3,Lhead);
								return;
		
		case ASSIGN			:	lnode = Llookup(root->NAME,Lhead);
								gnode = Glookup(root->NAME);
								
								if(lnode != NULL)
									*lnode->BINDING = evalBody(root->Ptr1,Lhead);
								else *gnode->BINDING = evalBody(root->Ptr1,Lhead);
								
								return;
		
		case ARRAYASSIGN	:	gnode = Glookup(root->NAME);
								gnode->BINDING[evalBody(root->Ptr1,Lhead)] = evalBody(root->Ptr2,Lhead);
								return;
		
		case RD				:	scanf("%d",&var);
								lnode = Llookup(root->NAME,Lhead);
								gnode = Glookup(root->NAME);
								
								if(lnode != NULL)
									*lnode->BINDING = var;
								else *gnode->BINDING = var;
								return;
		
		case ARRAYRD		:	scanf("%d",&var);
								gnode = Glookup(root->NAME);
								gnode->BINDING[evalBody(root->Ptr1,Lhead)] = var;
								return;
		
		case WRIT			:	printf("%d\n",evalBody(root->Ptr1,Lhead));
								return;
		
		case ADD			:	return evalBody(root->Ptr1,Lhead) + evalBody(root->Ptr2,Lhead);
		
		case SUB			:	return evalBody(root->Ptr1,Lhead) - evalBody(root->Ptr2,Lhead);
		
		case MUL			:	return evalBody(root->Ptr1,Lhead) * evalBody(root->Ptr2,Lhead);
		
		case DIV			:	return evalBody(root->Ptr1,Lhead) / evalBody(root->Ptr2,Lhead);
		
		case MOD			:	return evalBody(root->Ptr1,Lhead) % evalBody(root->Ptr2,Lhead);
		
		case GT				:	return evalBody(root->Ptr1,Lhead) > evalBody(root->Ptr2,Lhead);
		
		case LT				:	return evalBody(root->Ptr1,Lhead) < evalBody(root->Ptr2,Lhead);
		
		case GTE			:	return evalBody(root->Ptr1,Lhead) >= evalBody(root->Ptr2,Lhead);
		
		case LTE			:	return evalBody(root->Ptr1,Lhead) <= evalBody(root->Ptr2,Lhead);
		
		case EQ				:	return evalBody(root->Ptr1,Lhead) == evalBody(root->Ptr2,Lhead);
		
		case NE				:	return evalBody(root->Ptr1,Lhead) != evalBody(root->Ptr2,Lhead);
		
		case And			:	return evalBody(root->Ptr1,Lhead) && evalBody(root->Ptr2,Lhead);
		
		case Or				:	return evalBody(root->Ptr1,Lhead) || evalBody(root->Ptr2,Lhead);
		
		case Not			:	return !evalBody(root->Ptr1,Lhead);
		
		case True			:	return 1;
		
		case False			:	return 0;
		
		case IDFR			:	lnode = Llookup(root->NAME,Lhead);
								gnode = Glookup(root->NAME);
								
								if(lnode != NULL)
									return *lnode->BINDING;
								else return *gnode->BINDING;
		
		case ARRAYIDFR		:	gnode = Glookup(root->NAME);
								return gnode->BINDING[evalBody(root->Ptr1,Lhead)];
		
		case NUM			:	return root->VALUE;
		
		default				:	printf("How did flag get this value!");
	}
}
Exemple #20
0
void Befunge::interpret(std::istream& in)
{
    interpreter(in, std::cout);
}
Exemple #21
0
void Befunge::interpret()
{
    interpreter(std::cin, std::cout);
}
Exemple #22
0
 void MachineCode::init(STATE) {
   // Seed the instructions table
   interpreter(0, 0, 0);
 }
Exemple #23
0
void QSAEditor::completeQMetaObject( const QMetaObject *meta,
					 const QString &,
					 QVector<CompletionEntry> &res,
					 int flags,
					 QSObject &obj )
{
    QMap<QString, bool> propMap;
    bool includeSuperClass = (flags & IncludeSuperClass) == IncludeSuperClass;

    // properties
    const QMetaObject *m = meta;
    int num = m->propertyCount();

    for ( int j = 0; j < num; ++j ) {
        const QMetaProperty mp = m->property( j );
        if ( propMap.find( QString::fromLatin1(mp.name()) ) != propMap.end() )
            continue;
        CompletionEntry c;
        propMap[QLatin1String(mp.name())] = false;
        c.type = QLatin1String("property");
        c.text = mp.name();
        c.prefix = QString();
        c.postfix2 = mp.typeName();
        QuickInterpreter::cleanType( c.postfix2 );
        if ( !c.postfix2.isEmpty() )
            c.postfix2.prepend( QLatin1String(" : ") );
        res.append( c );
    }

    if ( includeSuperClass && obj.isValid() && !obj.isUndefined() ) {
        QStringList vars = interpreter()->variablesOf( obj, true );
        QStringList::iterator it;
        for ( it = vars.begin(); it != vars.end(); ++it ) {
            CompletionEntry c;
            c.type = QLatin1String("variable");
            c.text = *it;
            c.prefix = QString();
            c.postfix2 = QString();
            res << c;
        }
    }

    // functions
    QList<Property> lst;
    QList<Property>::Iterator pit;
    getSlots( meta, lst, includeSuperClass, false, false );
    for ( pit  = lst.begin(); pit != lst.end(); ++pit ) {
        CompletionEntry c;
        c.type = QLatin1String("function");
        c.text = (*pit).name;
        c.postfix = QLatin1String("()");
        c.postfix2 = (*pit).type;
        if ( !c.postfix2.isEmpty() )
            c.postfix2.prepend( QString::fromLatin1(" : ") );
        res << c;
    }
    if ( includeSuperClass && obj.isValid() && !obj.isUndefined() ) {
        QStringList funcs = interpreter()->functionsOf( obj, true, true, true );
        QStringList::Iterator it;
        for ( it = funcs.begin(); it != funcs.end(); ++it ) {
            CompletionEntry c;
            c.type = QLatin1String("function");
            c.text = *it;
            c.prefix = QString();
            c.postfix2 = QString();
            res << c;
        }
    }

    // enum values

    m = meta;
    for (int k=0; k<m->enumeratorCount(); ++k) {
        QMetaEnum me = m->enumerator(k);
        for (int l=0; l<me.keyCount(); ++l) {
            CompletionEntry c;
            c.type = QLatin1String("enum");
            c.text = QLatin1String(me.key(l));
            c.prefix = QString();
            c.postfix2 = QLatin1String(me.name());

            if (!c.postfix2.isEmpty())
                c.postfix2.prepend( QString::fromLatin1(" : ") );
            res << c;
        }
    }

    if ( includeSuperClass && obj.isValid() && !obj.isUndefined() ) {
        QStringList classes = interpreter()->classesOf( obj );
        QStringList::Iterator it;
        for ( it = classes.begin(); it != classes.end(); ++it ) {
            CompletionEntry c;
            c.type = QLatin1String("class");
            c.text = *it;
            c.prefix = QString();
            c.postfix2 = QString();
            res << c;
        }
    }
}
Exemple #24
0
Tcl_Interp* dfsch_tcl_interpreter(dfsch_object_t* obj){
  return interpreter(obj)->interpreter;
}
Exemple #25
0
MainWindow::MainWindow(Manager *man, QWidget *parent) : QMainWindow(parent), manager(man), nbElementsAffichablesPile(1)
{

    pile = manager->getPile();

    QXmlStreamReader xmlReader3;
    QFile filePile3("parametres.xml");
    filePile3.open(QFile::ReadOnly);
    xmlReader3.setDevice(&filePile3);



    xmlReader3.readNext();
    QString valeur;


    while(!xmlReader3.atEnd() && !xmlReader3.hasError()) {

            QXmlStreamReader::TokenType token = xmlReader3.readNext();

            if(token == QXmlStreamReader::StartDocument) {
                    continue;
            }

            if(token == QXmlStreamReader::StartElement) {

                    if(xmlReader3.name() == "clavierVisible") {
                            xmlReader3.readElementText();
                    }

                    if(xmlReader3.name() == "valeur") {
                         valeur= xmlReader3.readElementText();
                         if(valeur=="1")
                             clavierVisible=true;
                         else
                             clavierVisible=false;
                    }

                    if(xmlReader3.name() == "nbElementsVisiblesPile") {
                           xmlReader3.readElementText();
                    }

                    if(xmlReader3.name() == "valeur") {

                        valeur = xmlReader3.readElementText();
                        nbElementsAffichablesPile = valeur.toInt();

                    }
            }
    }

    //paramètres d'affichage
    QMenu *menuAfficher = menuBar()->addMenu("&Afficher");
    actionAfficherClavier = new QAction("&Afficher le clavier", this);
    actionAfficherClavier->setCheckable(true);
    actionAfficherClavier->setChecked(true);

    QAction* actionNbElementsPile = new QAction("&Modifier le nombre d'élements affichables dans la pile", this);

    menuAfficher->addAction(actionAfficherClavier);
    menuAfficher->addAction(actionNbElementsPile);

    QObject::connect(actionAfficherClavier, SIGNAL(toggled(bool)), this, SLOT(afficherClavier(bool)));
    QObject::connect(actionNbElementsPile, SIGNAL(triggered(bool)), this, SLOT(modifierNbElementsAffichesPile()));


    // Général
    QHBoxLayout *mainLayout= new QHBoxLayout();
    tabWidget = new QTabWidget();
    QVBoxLayout *verticalLayout = new QVBoxLayout();
    layoutClavier = new QGridLayout;

    //Vue de la pile (gauche)
    QListView *vuePile = new QListView();
    vuePile->setGeometry(0,0,100,300);

    //Vue de l'historique de commandes (droite)
    QTextEdit *vueHistoriqueCommandes = new QTextEdit();
    inputLine = new QLineEdit();

    //Clavier numérique
    QSignalMapper *signalMapper = new QSignalMapper(this);

    QPushButton *bouton1= new QPushButton();
    bouton1->setText("1");
    connect(bouton1, SIGNAL(clicked()), signalMapper, SLOT(map()));
    signalMapper->setMapping(bouton1, "1");

    QPushButton *bouton2= new QPushButton();
    bouton2->setText("2");
    connect(bouton2, SIGNAL(clicked()), signalMapper, SLOT(map()));
    signalMapper->setMapping(bouton2, "2");

    QPushButton *bouton3= new QPushButton();
    bouton3->setText("3");
    connect(bouton3, SIGNAL(clicked()), signalMapper, SLOT(map()));
    signalMapper->setMapping(bouton3, "3");

    QPushButton *bouton4= new QPushButton();
    bouton4->setText("4");
    connect(bouton4, SIGNAL(clicked()), signalMapper, SLOT(map()));
    signalMapper->setMapping(bouton4, "4");

    QPushButton *bouton5= new QPushButton();
    bouton5->setText("5");
    connect(bouton5, SIGNAL(clicked()), signalMapper, SLOT(map()));
    signalMapper->setMapping(bouton5, "5");

    QPushButton *bouton6= new QPushButton();
    bouton6->setText("6");
    connect(bouton6, SIGNAL(clicked()), signalMapper, SLOT(map()));
    signalMapper->setMapping(bouton6, "6");

    QPushButton *bouton7= new QPushButton();
    bouton7->setText("7");
    connect(bouton7, SIGNAL(clicked()), signalMapper, SLOT(map()));
    signalMapper->setMapping(bouton7, "7");

    QPushButton *bouton8= new QPushButton();
    bouton8->setText("8");
    connect(bouton8, SIGNAL(clicked()), signalMapper, SLOT(map()));
    signalMapper->setMapping(bouton8, "8");

    QPushButton *bouton9= new QPushButton();
    bouton9->setText("9");
    connect(bouton9, SIGNAL(clicked()), signalMapper, SLOT(map()));
    signalMapper->setMapping(bouton9, "9");

    QPushButton *boutonEspace= new QPushButton();
    boutonEspace->setText("");
    connect(boutonEspace, SIGNAL(clicked()), signalMapper, SLOT(map()));
    signalMapper->setMapping(boutonEspace, " ");

    QPushButton *boutonAddition= new QPushButton();
    boutonAddition->setText("+");
    connect(boutonAddition, SIGNAL(clicked()), signalMapper, SLOT(map()));
    signalMapper->setMapping(boutonAddition, "+");

    QPushButton *boutonSoustraction= new QPushButton();
    boutonSoustraction->setText("-");
    connect(boutonSoustraction, SIGNAL(clicked()), signalMapper, SLOT(map()));
    signalMapper->setMapping(boutonSoustraction, "-");

    QPushButton *boutonMulitplication= new QPushButton();
    boutonMulitplication->setText("*");
    connect(boutonMulitplication, SIGNAL(clicked()), signalMapper, SLOT(map()));
    signalMapper->setMapping(boutonMulitplication, "*");

    QPushButton *boutonDivision= new QPushButton();
    boutonDivision->setText("/");
    connect(boutonDivision, SIGNAL(clicked()), signalMapper, SLOT(map()));
    signalMapper->setMapping(boutonDivision, "/");


    connect(signalMapper, SIGNAL(mapped(QString)), this, SLOT(appendInputKeyboard(QString)));


    QPushButton *boutonEntree= new QPushButton();
    boutonEntree->setText("Entrée");
    connect(boutonEntree, SIGNAL(clicked()), this, SLOT(returnPressedStr()));

    QVBoxLayout *layoutOperateurs = new QVBoxLayout();
    layoutOperateurs->addWidget(boutonAddition);
    layoutOperateurs->addWidget(boutonSoustraction);
    layoutOperateurs->addWidget(boutonMulitplication);
    layoutOperateurs->addWidget(boutonDivision);
    layoutOperateurs->addWidget(boutonEntree);



    //Crée un layout contenant le clavier numérique

    layoutClavier->addWidget(bouton1, 0,0);
    layoutClavier->addWidget(bouton2, 0,1);
    layoutClavier->addWidget(bouton3, 0,2);
    layoutClavier->addWidget(bouton4, 1,0);
    layoutClavier->addWidget(bouton5, 1,1);
    layoutClavier->addWidget(bouton6, 1,2);
    layoutClavier->addWidget(bouton7, 2,0);
    layoutClavier->addWidget(bouton8, 2,1);
    layoutClavier->addWidget(bouton9, 2,2);
    layoutClavier->addWidget(boutonEspace,3,0,1,3);
    layoutClavier->addLayout(layoutOperateurs, 0,3,4,1);

    conteneurClavier = new QWidget();
    conteneurClavier->setLayout(layoutClavier);

    //Crée un layout avec l'historique de commandes, la zone d'entrée et le clavier
    verticalLayout->addWidget(vueHistoriqueCommandes);
    verticalLayout->addWidget(inputLine);
    verticalLayout->addWidget(conteneurClavier);

    //Assemble les layouts
    mainLayout->addWidget(vuePile);
    mainLayout->addLayout(verticalLayout);


    QWidget* tab1 = new QWidget();
    tab1->setLayout(mainLayout);
    tabWidget->addTab(tab1, "Principal");

    QObject::connect(inputLine, SIGNAL(textChanged(QString)), this, SLOT(interpreter(QString))) ;
    QObject::connect(inputLine,SIGNAL(returnPressed()), this, SLOT(returnPressedStr()));

    pile->setView(vuePile);









    //---------------------------------TAB2--------------------------------------------


    QHBoxLayout *layoutProgramme = new QHBoxLayout();
    QVBoxLayout *layoutEditionProgramme = new QVBoxLayout();
    QHBoxLayout *layoutBoutonsProgramme = new QHBoxLayout();

    listeProgrammes = new QListView();

    zoneProgramme = new QTextEdit();
    zoneIdentifiant = new QLineEdit();
    boutonValider = new QPushButton("Ajouter");
    boutonEffacer = new QPushButton("Effacer");
    boutonModifier = new QPushButton("Modifier");
    boutonSupprimer = new QPushButton("Supprimer");
    boutonSupprimer->setEnabled(false);
    boutonModifier->setEnabled(false);



   layoutBoutonsProgramme->addWidget(boutonValider);
   layoutBoutonsProgramme->addWidget(boutonEffacer);
   layoutBoutonsProgramme->addWidget(boutonModifier);
   layoutBoutonsProgramme->addWidget(boutonSupprimer);


   layoutEditionProgramme->addWidget(zoneProgramme);
   layoutEditionProgramme->addWidget(zoneIdentifiant);
   layoutEditionProgramme->addLayout(layoutBoutonsProgramme);

   layoutProgramme->addLayout(layoutEditionProgramme);
   layoutProgramme->addWidget(listeProgrammes);

   QWidget* tab2 = new QWidget();

   tab2->setLayout(layoutProgramme);

   tabWidget->addTab(tab2, "Programmes");



   QXmlStreamReader xmlReader;
   QFile fileProgramme("programmes.xml");
   fileProgramme.open(QFile::ReadOnly);
   xmlReader.setDevice(&fileProgramme);



   xmlReader.readNext();
   QString strIdentifiant;
   QString str;
   while(!xmlReader.atEnd() && !xmlReader.hasError()) {

           QXmlStreamReader::TokenType token = xmlReader.readNext();

           if(token == QXmlStreamReader::StartDocument) {
                   continue;
           }

           if(token == QXmlStreamReader::StartElement) {

                   if(xmlReader.name() == "identifiant") {
                           strIdentifiant= xmlReader.readElementText();
                   }

                   if(xmlReader.name() == "string") {
                        str= xmlReader.readElementText();
                        manager->insererProgramme(strIdentifiant, str);
                   }
           }
   }

   QStringList* listeProgrammesStr = manager->getListProgrammes();

   modeleProgrammes = new QStringListModel(*listeProgrammesStr, this);

   listeProgrammes->setEditTriggers(QAbstractItemView::NoEditTriggers);
   listeProgrammes->setModel(modeleProgrammes);



   fileProgramme.close();

   QObject::connect(boutonValider, SIGNAL(clicked(bool)), this, SLOT(ajouterProgramme()));
   QObject::connect(listeProgrammes, SIGNAL(doubleClicked(QModelIndex)), this, SLOT(afficherProgrammeListe(QModelIndex)));
   QObject::connect(boutonEffacer, SIGNAL(clicked(bool)), this, SLOT(effacerChampsProgramme()));
   QObject::connect(boutonSupprimer, SIGNAL(clicked(bool)), this, SLOT(supprimerProgramme()));
   QObject::connect(boutonModifier, SIGNAL(clicked(bool)), this, SLOT(modifierProgramme()));




   //---------------------------------TAB3--------------------------------------------


   QHBoxLayout *layoutVariable = new QHBoxLayout();
   QVBoxLayout *layoutEditionVariable = new QVBoxLayout();
   QHBoxLayout *layoutBoutonsVariable = new QHBoxLayout();

   listeVariables = new QListView();

   zoneVariable = new QTextEdit();
   zoneIdentifiantVariable = new QLineEdit();
   boutonValiderVariable = new QPushButton("Ajouter");
   boutonEffacerVariable = new QPushButton("Effacer");
   boutonModifierVariable = new QPushButton("Modifier");
   boutonSupprimerVariable = new QPushButton("Supprimer");
   boutonSupprimerVariable->setEnabled(false);
   boutonModifierVariable->setEnabled(false);



  layoutBoutonsVariable->addWidget(boutonValiderVariable);
  layoutBoutonsVariable->addWidget(boutonEffacerVariable);
  layoutBoutonsVariable->addWidget(boutonModifierVariable);
  layoutBoutonsVariable->addWidget(boutonSupprimerVariable);


  layoutEditionVariable->addWidget(zoneVariable);
  layoutEditionVariable->addWidget(zoneIdentifiantVariable);
  layoutEditionVariable->addLayout(layoutBoutonsVariable);

  layoutVariable->addLayout(layoutEditionVariable);
  layoutVariable->addWidget(listeVariables);

  QWidget* tab3 = new QWidget();

  tab3->setLayout(layoutVariable);

  tabWidget->addTab(tab3, "Variables");



  QXmlStreamReader xmlReader2;
  QFile fileVariable("variables.xml");
  fileVariable.open(QFile::ReadOnly);
  xmlReader2.setDevice(&fileVariable);



  xmlReader2.readNext();

  while(!xmlReader2.atEnd() && !xmlReader2.hasError()) {

          QXmlStreamReader::TokenType token = xmlReader2.readNext();

          if(token == QXmlStreamReader::StartDocument) {
                  continue;
          }

          if(token == QXmlStreamReader::StartElement) {

                  if(xmlReader2.name() == "identifiant") {
                          strIdentifiant= xmlReader2.readElementText();
                  }

                  if(xmlReader2.name() == "string") {
                       str= xmlReader2.readElementText();
                       manager->insererVariable(strIdentifiant, str);
                  }
          }
  }

  QStringList* listeVariablesStr = manager->getListVariables();

  modeleVariables = new QStringListModel(*listeVariablesStr, this);

  listeVariables->setEditTriggers(QAbstractItemView::NoEditTriggers);
  listeVariables->setModel(modeleVariables);



  fileVariable.close();

  QObject::connect(boutonValiderVariable, SIGNAL(clicked(bool)), this, SLOT(ajouterVariable()));
  QObject::connect(listeVariables, SIGNAL(doubleClicked(QModelIndex)), this, SLOT(afficherVariableListe(QModelIndex)));
  QObject::connect(boutonEffacerVariable, SIGNAL(clicked(bool)), this, SLOT(effacerChampsVariable()));
  QObject::connect(boutonSupprimerVariable, SIGNAL(clicked(bool)), this, SLOT(supprimerVariable()));
  QObject::connect(boutonModifierVariable, SIGNAL(clicked(bool)), this, SLOT(modifierVariable()));

  QObject::connect(tabWidget, SIGNAL(currentChanged(int)), this, SLOT(updateTab(int)));


   setCentralWidget(tabWidget);


}
// Task odbioru i analizy znakow z konsoli
void vConsoleRxTask (void *pvparameters) {


    char special=0;
    char i = 0;

    char command_buffer[CMD_MAX_LEN];
    char *ptr_cmd_buf = command_buffer;
    char onechar;

    //utworz kolejke znakow
    RxQueue = xQueueCreate(100, sizeof( portCHAR ) );


    for (;;)
    {

        //vTaskDelay(10 / portTICK_RATE_MS);
        while(xQueueReceive(RxQueue,&onechar,portMAX_DELAY))
        {

            // sprawdzamy wstepnie czy to znak specjalny (wszelkie strzalki, delete)
            if (onechar == 0x5b ||onechar == 0x1b) {
                special = 1;
            }
            //sprawdz czy to byla strzalka w gore
            else if (special && onechar == 0x41 )
            {
                //skasuj wyswietlona z historii komende i przygotuj dla poprzedniej
                clean_term(ptr_cmd_buf);
                //wczytaj poprzednia komende
                przewinwtyl(com_cmd_hist, ptr_cmd_buf);

                //wyswietla te komnde na rs
                print_console(ptr_cmd_buf);

                //print_char(0, user.prom(&user));
                i= (char)strlen(ptr_cmd_buf);

                // deaktywacja sekwencji sterujacej
                special = 0;

            }

            //przyjmuj tylko znaki z przedzialu a-z 0-9 spacja, enter, backspace,itd.
            //uwaga na strzalki, wysylaja po 2 znaki: A+costam oraz B+costam
            else if(( (onechar >= 'a' && onechar <= 'z') ||
                      (onechar >= 'A' && onechar <= 'Z') ||
                      (onechar >= '0' && onechar <= '9') ||
                      onechar == ' ' || onechar == '.'   ||
                      onechar == '-' || onechar == '_'   ||
                      onechar == '+' || onechar == '?' ||
                      onechar == '@' )&&(!special)  )
            {
                //echo dla wpisanego znaku
                usart_put_char(onechar);

                //zabezpieczenie przed przekroczeniem tablicy
                if(i < CMD_MAX_LEN)
                {
                    *(ptr_cmd_buf + i) = onechar;
                    i++;
                }
            }

            //sprawdz czy to byl backspace
            else if (onechar == BS) //backspace
            {
                //sprawdz czy index jest jeszcze w dopuszczlnym obszarze,
                //z lewej i z prawej strony
                if(i > 0 && i < CMD_MAX_LEN)
                {
                    usart_put_char(BS);

                    //wyczysc ostatni znak
                    *(ptr_cmd_buf + i) = 0x0;
                    //przesun o 1 do tylu aktualny indeks bufora
                    i--;

                }
            }
            //jesli jakikolwiek inny klawisz ze znakow specjalnych
            else if(special)	special = 0;

            //sprawdz czy to byl enter lub koniec transmisji
            else if (onechar == EOT || onechar ==LF ||
                     onechar ==CR_CM || onechar==ETB)
            {
                //usart_put_string("\r\n");
                //usart_put_char((char*)LF);
                //usart_put_char((char*)CMD_PRMT);
                //zakoncz c-stringa znakiem konca= '\0'
                *(ptr_cmd_buf + i) = '\0';

                //skopiuj te komende do kolejki przyjetych komend
                //add_to_history_cmd(com_cmd_hist, ptr_cmd_buf);
                //interpretacja komend
                interpreter(ptr_cmd_buf, i, NULL,ptr_cmd_buf);


                //przygotuj indeks pod nastepna komende na poczatek bufora
                i= 0;

                //byl ENTER, wiec ustaw ze nie kasuje nic STRZALKA W GORE wypisujaca z historii
                was_hist = 0;
            }
        }
    }


}
/*!
  \internal
*/
QSWrapperFactory::~QSWrapperFactory()
{
    if( interpreter() )
	interpreter()->removeWrapperFactory( this );
    delete d;
}
Exemple #28
0
JSStack* CallFrame::stack()
{
    return &interpreter()->stack();
}
Exemple #29
0
bool AutoScheduleTransformer::autotune(AstTranslationUnit& translationUnit, std::ostream* report) {
    const QueryExecutionStrategy& strategy = ScheduledExecution;
    bool verbose = Global::config().has("verbose");

    // start with status message
    if (verbose) {
        std::cout << "\n";
    }
    if (verbose) {
        std::cout << "----------------- Auto-Scheduling Started -----------------\n";
    }

    // step 1 - translate to RAM program
    if (verbose) {
        std::cout << "[ Converting to RAM Program ...                           ]\n";
    }
    std::unique_ptr<RamStatement> stmt = RamTranslator().translateProgram(translationUnit);

    // check whether there is something to tune
    if (!stmt) {
        if (verbose) {
            std::cout << "[                                     No Rules in Program ]\n";
            std::cout << "---------------- Auto-Scheduling Completed ----------------\n";
        }
        return false;
    }

    if (verbose) {
        std::cout << "[                                                    Done ]\n";
    }

    // step 2 - run in interpreted mode, collect decisions
    if (verbose) {
        std::cout << "[ Profiling RAM Program ...                               ]\n";
    }

    Profiler::Data data;
    Profiler profiler(strategy, data);

    // create a copy of the symbol table
    souffle::SymbolTable table = translationUnit.getSymbolTable();

    // create interpreter instance
    RamGuidedInterpreter interpreter(profiler);

    if (report && verbose) {
        SplitStream splitStream(report, &std::cout);
        interpreter.setReportTarget(splitStream);
    } else if (report) {
        interpreter.setReportTarget(*report);
    } else if (verbose) {
        interpreter.setReportTarget(std::cout);
    }

    // run interpreter
    interpreter.execute(table, *stmt);

    if (verbose) {
        std::cout << "[                                                    Done ]\n";
    }

    if (verbose) {
        std::cout << "Data:\n";
        for (const auto& cur : data) {
            std::cout << "Clause @ " << cur.first << "\n";
            for (const ExecutionSummary& instance : cur.second) {
                std::cout << "\t" << instance.order << " in " << instance.time << "ms\n";
            }
        }
    }

    // step 3 - process collected data ..
    if (verbose) {
        std::cout << "[ Selecting most significant schedules ...                ]\n";
    }

    std::map<AstSrcLocation, const AstClause*> clauses;
    visitDepthFirst(*translationUnit.getProgram(),
            [&](const AstClause& clause) { clauses[clause.getSrcLoc()] = &clause; });

    std::map<const AstClause*, long> longestTime;
    std::map<const AstClause*, Order> bestOrders;

    // extract best order for each clause
    for (const auto& cur : data) {
        const AstClause* clause = clauses[cur.first];
        assert(clause && "Unknown clause discovered!");
        for (const ExecutionSummary& instance : cur.second) {
            if (longestTime[clause] < instance.time) {
                longestTime[clause] = instance.time;
                bestOrders[clause] = instance.order;
            }
        }
    }

    if (verbose) {
        for (const auto& cur : bestOrders) {
            std::cout << *cur.first << "\n Best Order: " << cur.second
                      << "\n Time: " << longestTime[cur.first] << "\n\n";
        }
    }

    if (verbose) {
        std::cout << "[                                                    Done ]\n";
    }

    // step 4 - apply transformations
    if (verbose) {
        std::cout << "[ Re-scheduling rules ...                                 ]\n";
    }

    bool changed = false;
    for (const auto& cur : bestOrders) {
        AstClause* clause = const_cast<AstClause*>(cur.first);
        bool orderChanged = false;
        const std::vector<unsigned>& newOrder = cur.second.getOrder();

        // Check whether best order is different to the original order
        for (unsigned int i = 0; i < clause->getAtoms().size(); i++) {
            if (newOrder[i] != i) {
                orderChanged = true;
                break;
            }
        }
        if (orderChanged) {
            clause->reorderAtoms(newOrder);
            changed = true;
        }
    }

    if (verbose) {
        std::cout << "[                                                    Done ]\n";
    }

    // end with status message
    if (verbose) {
        std::cout << "---------------- Auto-Scheduling Completed -----------------\n";
    }

    return changed;
}
Exemple #30
0
void dfsch_tcl_destroy_interpreter(dfsch_object_t* obj){
  interpreter_t* i = interpreter(obj);

  i->active = 0;
  Tcl_DeleteInterp(i->interpreter);
}