コード例 #1
0
ファイル: SemaDataStmt.cpp プロジェクト: carlobertolli/flang
bool DataStmtEngine::CheckVar(VarExpr *E) {
  auto VD = E->getVarDecl();
  if(VD->isArgument() || VD->isParameter() ||
     VD->isFunctionResult()) {
    Diags.Report(E->getLocation(), diag::err_data_stmt_invalid_var)
      << (VD->isParameter()? 0 : VD->isArgument()? 1 : 2)
      << VD->getIdentifier() << E->getSourceRange();
    getValueOnError();
    return true;
  }
  if(VD->isUnusedSymbol())
    const_cast<VarDecl*>(VD)->MarkUsedAsVariable(E->getLocation());
  return false;
}
コード例 #2
0
ファイル: cmdline.hpp プロジェクト: jinoos/qt-screenshot
inline bool
QtArgCmdLine::isFlag( const QString & str ) const
{
	if( !isArgument( str ) )
		if( str.startsWith( m_delimiter ) )
			return true;

	return false;
}
コード例 #3
0
CharacterValueTy CharacterExprEmitter::VisitVarExpr(const VarExpr *E) {
  auto VD = E->getVarDecl();
  if(CGF.IsInlinedArgument(VD))
    return CGF.GetInlinedArgumentValue(VD).asCharacter();
  if(VD->isArgument())
    return CGF.GetCharacterArg(VD);
  else if(VD->isParameter())
    return EmitExpr(VD->getInit());
  else if(VD->isFunctionResult())
    return CGF.ExtractCharacterValue(CGF.GetRetVarPtr());
  return CGF.GetCharacterValueFromPtr(CGF.GetVarPtr(VD), VD->getType());
}
コード例 #4
0
bool Sema::CheckEquivalenceObject(SourceLocation Loc, Expr *E, VarDecl *& Object) {
  if(auto Var = dyn_cast<VarExpr>(E)) {
    auto VD = Var->getVarDecl();
    if(VD->isArgument() || VD->isParameter()) {
      Diags.Report(Loc, diag::err_spec_requires_local_var)
        << E->getSourceRange();
      Diags.Report(VD->getLocation(), diag::note_previous_definition_kind)
          << VD->getIdentifier() << (VD->isArgument()? 0 : 1)
          << getTokenRange(VD->getLocation());
      return true;
    }
    if(VD->isUnusedSymbol())
      const_cast<VarDecl*>(VD)->MarkUsedAsVariable(E->getLocation());
    Object = const_cast<VarDecl*>(VD);
  }  else {
    Diags.Report(Loc, diag::err_spec_requires_var_or_arr_el)
      << E->getSourceRange();
    return true;
  }
  return false;
}
コード例 #5
0
Decl *Sema::ActOnExternalEntityDecl(ASTContext &C, QualType T,
                                    SourceLocation IDLoc, const IdentifierInfo *IDInfo) {
  SourceLocation TypeLoc;
  VarDecl *ArgumentExternal = nullptr;
  if (auto Prev = LookupIdentifier(IDInfo)) {
    auto Quals = getDeclQualifiers(Prev);
    if(Quals.hasAttributeSpec(Qualifiers::AS_external)) {
      Diags.Report(IDLoc, diag::err_duplicate_attr_spec)
        << DeclSpec::getSpecifierName(Qualifiers::AS_external);
      return Prev;
    }

    // apply EXTERNAL to an unused symbol or an argument.
    auto VD = dyn_cast<VarDecl>(Prev);
    if(VD && (VD->isUnusedSymbol() || VD->isArgument()) ) {
      T = VD->getType();
      TypeLoc = VD->getLocation();
      CurContext->removeDecl(VD);
      if(VD->isArgument())
        ArgumentExternal = VD;
    } else {
      DiagnoseRedefinition(IDLoc, IDInfo, Prev);
      return nullptr;
    }
  }
  if(T.isNull())
    T = C.VoidTy;

  DeclarationNameInfo DeclName(IDInfo,IDLoc);
  auto Decl = FunctionDecl::Create(C, ArgumentExternal? FunctionDecl::ExternalArgument :
                                                        FunctionDecl::External,
                                   CurContext, DeclName, T);
  SetFunctionType(Decl, T, TypeLoc, SourceRange()); //FIXME: proper loc, and range
  CurContext->addDecl(Decl);
  if(ArgumentExternal)
    ArgumentExternal->setType(C.getFunctionType(Decl));
  return Decl;
}
コード例 #6
0
bool Helper::handleGetOpenX( bool url )
    {
    if( !readArguments( 4 ))
        return false;
    QString startDir = getArgument();
    QString filter = getArgument().replace("/", "\\/"); // TODO: not used
    int selectFilter = getArgument().toInt();
    QString title = getArgument();
    bool multiple = isArgument( "MULTIPLE" );
    long wid = getArgumentParent();
    if( !allArgumentsUsed())
        return false;

    if (title.isEmpty())
        title = i18n("Open");

    if (url) {
        QList<QUrl> result;
        if (multiple)
            result = QFileDialog::getOpenFileUrls(nullptr, title, startDir);
        else
            result << QFileDialog::getOpenFileUrl(nullptr, title, startDir);
        result.removeAll(QUrl());
        if (!result.isEmpty()) {
            outputLine(QStringLiteral("0")); // filter is not implemented, so always 0 (All Files)
            for (const QUrl &url : result)
                outputLine(url.url());
            return true;
        }

    } else {
        QStringList result;
        if (multiple)
            result = QFileDialog::getOpenFileNames(nullptr, title, startDir);
        else
            result << QFileDialog::getOpenFileName(nullptr, title, startDir);
        result.removeAll(QString());
        if (!result.isEmpty()) {
            outputLine(QStringLiteral("0"));
            for (const QString &str : result)
                outputLine(str);
            return true;
        }
    }

    return false;
    }
コード例 #7
0
ファイル: CCeilPIdent.cpp プロジェクト: colinw7/CCeil
void
ClParserIdentifier::
debugPrint() const
{
  if      (isFunction())
    fprintf(stderr, " fn");
  else if (isStructPart())
    fprintf(stderr, " str");
  else if (isVariable())
    fprintf(stderr, " var");
  else if (isArgument())
    fprintf(stderr, " arg");
  else
    fprintf(stderr, " ??");

  fprintf(stderr, " %s ", name_.c_str());
}
コード例 #8
0
bool Helper::handleOpen()
    {
    if( !readArguments( 1 ))
        return false;
    QUrl url = QUrl::fromUserInput(getArgument());
    QString mime;
    if( isArgument( "MIMETYPE" ))
        mime = getArgument();
    if( !allArgumentsUsed())
        return false;
    //KApplication::updateUserTimestamp( 0 ); // TODO
    // try to handle the case when the server has broken mimetypes and e.g. claims something is application/octet-stream
    QMimeType mimeType = QMimeDatabase().mimeTypeForName(mime);
    if (!mime.isEmpty() && mimeType.isValid() && KMimeTypeTrader::self()->preferredService(mimeType.name()))
        return KRun::runUrl( url, mime, NULL ); // TODO parent
    else
        {
        (void) new KRun( url, NULL ); // TODO parent
    //    QObject::connect( run, SIGNAL( finished()), &app, SLOT( openDone()));
    //    QObject::connect( run, SIGNAL( error()), &app, SLOT( openDone()));
        return true; // TODO check for errors?
        }
    }
コード例 #9
0
ファイル: semantic.cpp プロジェクト: ombt/ombt
// remove existential quantifier by using skolem functions. all skolem
// functions must be unique. remember that the skolem function is dependent
// on any universal variables that are in scope.
//
int
Semantic::skolemize(List<Symbol> &localscope)
{
	// check if expression or predicate
	if (isExpression())
	{
		// get expression
		Expression *pe = (Expression *)prep;

		// what type is it
		if (pe->type == Expression::Universal)
		{
			// store universal variable
			localscope.insertAtEnd(Symbol(pe->name, 
				Symbol::UniversalVariable));

			// follow right leg, left leg is null
			MustBeTrue(pe->left == NULL && pe->right != NULL);
			if (pe->right->skolemize(localscope) != OK)
				return(NOTOK);

			// remove universal variable
			Symbol tmp;
			localscope.removeAtEnd(tmp);
		}
		else if (pe->type == Expression::Existential)
		{
			// store existential variable
			String uname = uniqueName(String("_SK"));
			localscope.insertAtEnd(Symbol(pe->name, uname,
				Symbol::ExistentialVariable));

			// follow right leg, left leg is null
			MustBeTrue(pe->left == NULL && pe->right != NULL);
			if (pe->right->skolemize(localscope) != OK)
				return(NOTOK);

			// remove existential variable
			Symbol tmp;
			localscope.removeAtEnd(tmp);
		}
		else
		{
			// follow down other expression operators
			if (pe->left != NULL && 
			    pe->left->skolemize(localscope) != OK)
				return(NOTOK);
			if (pe->right != NULL && 
			    pe->right->skolemize(localscope) != OK)
				return(NOTOK);
		}
		
	}
	else if (isPredicate())
	{
		// get predicate
		Predicate *pp = (Predicate *)prep;

		// check for functions
		if (pp->type == Predicate::Function)
		{
			// cycle thru arguments
			ListIterator<Semantic * > pargsIter(*pp->pargs);
			for ( ; !pargsIter.done(); pargsIter++)
			{
				Semantic *parg = pargsIter();
				if (parg != NULL && 
				    parg->skolemize(localscope) != OK)
					return(NOTOK);
			}
		}
	}
	else if (isArgument())
	{
		// check type of argument
		Argument *pa = (Argument *)prep;
		switch (pa->type)
		{
		case Argument::Variable:
		{
			// check if an existential variable
			Symbol qvarsym(pa->name);
			if(localscope.retrieve(qvarsym) != OK)
				break;
			if (qvarsym.getType() != Symbol::ExistentialVariable)
				break;

			// we have an existential variable
			String skolemName(qvarsym.getUniqueName());

			// need to replace this variable with a 
			// skolem function which is dependent on all
			// universal variables in scope at this time.
			//
			List<Semantic * > *pargs = new List<Semantic * >;
			MustBeTrue(pargs != NULL);
			ListIterator<Symbol> scopeIter(localscope);
			int nargs;
			for (nargs = 0; !scopeIter.done(); scopeIter++)
			{
				// get symbol
				Symbol uvar = scopeIter();

				// check if we found the current 
				// symbol. this marks the end of 
				// dependent variables for the 
				// skolem function. all other
				// existential variables are skipped.
				//
				if (uvar.getType() == 
					Symbol::ExistentialVariable)
				{
					if (uvar == Symbol(pa->name))
						break;
					else
						continue;
				}

				// we have a universal variable in
				// scope
				//
				Semantic *parg = new Semantic(
					Argument::Variable, uvar.getName());
				MustBeTrue(parg != NULL);
				pargs->insertAtEnd(parg);
				nargs++;
			}
			if (nargs == 0)
			{
				// skolem constant
				pa->type = Argument::Constant;
				pa->name = skolemName;
				pa->pargs = NULL;
				pa->argnum = 0;

				// delete unused argument list
				delete pargs;
			}
			else
			{
				// skolem function
				pa->type = Argument::Function;
				pa->name = skolemName;
				pa->pargs = pargs;
				pa->argnum = nargs;
			}
			break;
		}

		case Argument::Function:
		{
			// we have a function, scan its arguments
			ListIterator<Semantic *> pargsIter(*pa->pargs);
			for ( ; !pargsIter.done(); pargsIter++)
			{
				Semantic *parg = pargsIter();
				if (parg != NULL && 
				    parg->skolemize(localscope) != OK)
					return(NOTOK);
			}
			break;
		}
		}
	}
	else
	{
		MustBeTrue(0);
	}

	// all done
	return(OK);
}
コード例 #10
0
ファイル: semantic.cpp プロジェクト: ombt/ombt
// rename all variable names to unique names.
int
Semantic::renameVariables(List<Symbol> &localscope)
{
	// check of predicate or expression
	if (isExpression())
	{
		// get expression record
		Expression *pe = (Expression *)prep;

		// check if we have quantifier
		int popscope = 0;
		if (pe->type == Expression::Universal)
		{
			// we have a quantifier, rename variable
			popscope = 1;
			String uname = uniqueName(String("_Q"));
			localscope.insertAtFront(
				Symbol(pe->name, uname, 
				Symbol::UniversalVariable));

			// change name in semantic record
			pe->name = uname;
		}
		else if (pe->type == Expression::Existential)
		{
			// we have a quantifier, rename variable
			popscope = 1;
			String uname = uniqueName(String("_Q"));
			localscope.insertAtFront(
				Symbol(pe->name, uname, 
				Symbol::ExistentialVariable));

			// change name in semantic record
			pe->name = uname;
		}

		// follow left and right branches
		if (pe->left != NULL && 
		    pe->left->renameVariables(localscope) != OK) 
			return(NOTOK);
		if (pe->right != NULL && 
		    pe->right->renameVariables(localscope) != OK)
			return(NOTOK);

		// pop scope variable if required
		if (popscope)
		{
			Symbol tmp;
			MustBeTrue(localscope.removeAtFront(tmp) == OK);
		}
	}
	else if (isPredicate())
	{
		// get predicate record
		Predicate *pp = (Predicate *)prep;

		// check if a function
		if (pp->type == Predicate::Function)
		{
			// we have a function, scan argument list
			ListIterator<Semantic *> pargsIter(*pp->pargs);
			for ( ; !pargsIter.done(); pargsIter++)
			{
				Semantic *parg = pargsIter();
				if (parg != NULL && 
				    parg->renameVariables(localscope) != OK)
					return(NOTOK);
			}
		}
	}
	else if (isArgument())
	{
		// check if a variable, function or anything else
		Argument *pa = (Argument *)prep;
		if (pa->type == Argument::Variable)
		{
			// find variable in scope
			Symbol usym(pa->name);
			if (localscope.retrieve(usym) == OK)
			{
				pa->name = usym.getUniqueName();
				MustBeTrue(pa->name != String(""));
			}
		}
		else if (pa->type == Argument::Function)
		{
			// we have a function, scan argument list
			ListIterator<Semantic *> pargsIter(*pa->pargs);
			for ( ; !pargsIter.done(); pargsIter++)
			{
				Semantic *parg = pargsIter();
				if (parg != NULL && 
				    parg->renameVariables(localscope) != OK)
					return(NOTOK);
			}
		}
	}
	else
	{
		MustBeTrue(0);
	}

	// all done
	return(OK);
}
コード例 #11
0
ファイル: locations.hpp プロジェクト: sebkirche/strongtalk
 bool isStackLoc(int i) const			{ return isArgument(i) || isStackTmp(i); }
コード例 #12
0
ファイル: parameter.hpp プロジェクト: abduld/cena
 ParameterNode(const int &row, const int &col, const int &endrow,
               const int &endcol, const string &raw)
     : Node(row, col, endrow, endcol, raw) {
   isArgument(true);
 }
コード例 #13
0
ファイル: cmdline.hpp プロジェクト: jinoos/qt-screenshot
inline void
QtArgCmdLine::parse( bool parseAfterIgnoreRest )
{
	checkArgumentsCorrectness();

	QString lastArgNameOrFlag;

	while( !m_context.atEnd() )
	{
		const QString & arg = m_context.next();
		QString name, nameWithoutDelims;

		{
			QString value;

			splitArgumentAndValue( arg, name, value );

			nameWithoutDelims = removeDelimiters( name );

			if( !value.isNull() )
				m_context.prepend( value );
		}

		// Argument.

		if( isArgument( arg ) )
		{
			if( nameWithoutDelims.isEmpty() )
			{
				if( !parseAfterIgnoreRest )
					return;
				else
					continue;
			}

			QtArgIface * argument = findArgument( nameWithoutDelims );
			lastArgNameOrFlag = name;

			if( argument != NULL )
			{
				argument->process( m_context );
				argument->visit( m_context );
				argument->checkConstraint();
			}
			else
				throw QtArgUnknownArgumentEx(
					QString::fromLatin1( "Unknown argument: %1" )
						.arg( name ) );
		}

		// Flag.

		else if( isFlag( arg ) )
		{
			for( int i = 0, i_max = nameWithoutDelims.length() - 1;
				i <= i_max; ++i )
			{
				QtArgIface * argument = findArgument( nameWithoutDelims[ i ] );
				lastArgNameOrFlag = QString( m_delimiter )
					+ nameWithoutDelims[ i ];

				if( i != i_max )
				{
					QStringList dummyArgsList( nameWithoutDelims
						.right( nameWithoutDelims.length() - i - 1 ) );
					QtArgCmdLineContext dummyContext( dummyArgsList );

					if( argument->process( dummyContext ) )
					{
						argument->visit( m_context );
						argument->checkConstraint();

						break;
					}
				}
				else
					argument->process( m_context );

				argument->visit( m_context );
				argument->checkConstraint();
			}
		}

		// Something unexpected.

		else
			throw QtArgUnexpectedOptionEx(
				QString::fromLatin1( "Unexpected option: %1. "
					"Argument \"%2\" doesn't expect any values." )
						.arg( name ).arg( lastArgNameOrFlag ) );
	}

	checkMandatoryArguments();
}