Exemplo n.º 1
0
String ForLoop::code() const
{
	String ret;
	ret += "for (" + (isStatement(Initialiser) ? asStatement(Initialiser)->code() : "");
	ret += "; " + (isStatement(Condition) ? asStatement(Condition)->code() : "");
	ret += "; " + (isStatement(Ticker) ? asStatement(Ticker)->code() : "");
	ret += ")\n" + (isStatement(Body) ? asStatement(Body)->codeAsStatement() : "");
	return ret;
}
Exemplo n.º 2
0
std::string Pragma::toStr(const clang::SourceManager& sm) const {
	std::ostringstream ss;
	ss << "(" << utils::location(getStartLocation(), sm) 
		<< ", " << utils::location(getEndLocation(), sm) << "),\n\t";
	
	ss << (isStatement() ? "Stmt -> " : "Decl -> ") << "(";

	if(isStatement() && getStatement()) {
		
		ss << utils::location(getStatement()->getLocStart(), sm) << ", " <<
			  utils::location(getStatement()->getLocEnd(), sm);
	}
	else if(isDecl() && getDecl())
		ss << utils::location(getDecl()->getLocStart(), sm) << ", " <<
			  utils::location(getDecl()->getLocEnd(), sm);
	ss << ")";
	return ss.str();
}
Exemplo n.º 3
0
// statement_list
//     : statement
//     | statement_list statement
//     ;
int isStatementList()
{
	int key;
	if (key = isStatement())
	{
		isStatementList();
	}
	return key;
}
NS_INTERFACE_MAP_END

////////////////////////////////////////////////////////////////////////////////
//// nsIXPCScriptable

#define XPC_MAP_CLASSNAME StatementJSHelper
#define XPC_MAP_QUOTED_CLASSNAME "StatementJSHelper"
#define XPC_MAP_WANT_GETPROPERTY
#define XPC_MAP_WANT_RESOLVE
#define XPC_MAP_FLAGS nsIXPCScriptable::ALLOW_PROP_MODS_DURING_RESOLVE
#include "xpc_map_end.h"

NS_IMETHODIMP
StatementJSHelper::GetProperty(nsIXPConnectWrappedNative *aWrapper,
                               JSContext *aCtx,
                               JSObject *aScopeObj,
                               jsid aId,
                               JS::Value *_result,
                               bool *_retval)
{
  if (!JSID_IS_STRING(aId))
    return NS_OK;

  JS::Rooted<JSObject*> scope(aCtx, aScopeObj);
  JS::Rooted<jsid> id(aCtx, aId);

#ifdef DEBUG
  {
    nsCOMPtr<mozIStorageStatement> isStatement(
                                     do_QueryInterface(aWrapper->Native()));
    NS_ASSERTION(isStatement, "How is this not a statement?!");
  }
#endif

  Statement *stmt = static_cast<Statement *>(
    static_cast<mozIStorageStatement *>(aWrapper->Native())
  );

  JSFlatString *str = JSID_TO_FLAT_STRING(id);
  if (::JS_FlatStringEqualsAscii(str, "row"))
    return getRow(stmt, aCtx, scope, _result);

  if (::JS_FlatStringEqualsAscii(str, "params"))
    return getParams(stmt, aCtx, scope, _result);

  return NS_OK;
}
Exemplo n.º 5
0
static Stack readStatement(FILE *f)
{
  Stack s;

  for(;;)
  {
    if(feof(f))
      return NULL;

    if((s = readActionRecord(f)) == NULL)
      return NULL;

    if(stack == NULL && isStatement(s))
      /* supposedly, we've got a complete statement. */
      return s;
    else
      push(s);
  }
}
Exemplo n.º 6
0
void CompilationEngine::compileStatements()
{
    /*  statements: statement*
        statement: letStatement | ifStatement | whileStatement | doStatement | returnStatement */

    tagNonTerminal("statements");

    while (jt.tokenType() == TokenType::kKEYWORD && isStatement(jt.getToken())) {

        switch (jt.keyword()) {

            case Keyword::kLET:
                compileLet();
                break;

            case Keyword::kDO:
                compileDo();
                break;

            case Keyword::kIF:
                compileIf();
                break;

            case Keyword::kWHILE:
                compileWhile();
                break;

            case Keyword::kRETURN:
                compileReturn();

            default:
                break;

        }
    }

    untagNonTerminal("statements");
}
Exemplo n.º 7
0
clang::Stmt const* Pragma::getStatement() const {
	assert(!mTargetNode.isNull() && isStatement());
	return mTargetNode.get<clang::Stmt const*> ();
}
Exemplo n.º 8
0
// statement
//     : type declarator_list ';'
//     | '{' statement_list '}'
//     | expr_statement
//     | IF '(' expr ')' statement
//     | IF '(' expr ')' statement ELSE statement
//     | WHILE '(' expr ')' statement
//     | RETURN ';'
//     | RETURN expr ';'
//     | PRINT ';
//     | PRINT expr_list ';'
//     | SCAN id_list ';'
//     ;
int isStatement()
{
	if (isType())
	{
		if(isDeclaratorList())
		{
			if (match(';'))
			{
				advance();
				return 1;
			}
		}
	}

	if (match('{'))
	{
		advance();
		if (isStatementList())
		{
			if (match('}'))
			{
				advance();
				return 1;
			}
		}
	}

	if (isExpressionStatement())
	{
		return 1;
	}

	if (match(IF))
	{
		advance();
		if (match('('))
		{
			advance();
			if (isExpr())
			{
				if (match(')'))
				{
					advance();
					if (isStatement())
					{
						if (match(ELSE))
						{
							advance();
							if (isStatement())
							{
								return 1;
							}
						}
						return 1;
					}
				}
			}
		}
	}

	if (match(WHILE))
	{
		advance();
		if (match('('))
		{
			advance();
			if (isExpr())
			{
				if (match(')'))
				{
					advance();
					if (isStatement())
					{
						return 1;
					}
				}
			}
		}
	}

	if (match(RETURN))
	{
		advance();
		if (match(';'))
		{
			advance();
			return 1;
		}
		if (isExpr())
		{
			if (match(';'))
			{
				advance();
				return 1;
			}
		}
	}

	if (match(PRINT))
	{
		advance();
		if (match(';'))
		{
			advance();
			return 1;
		}
		if (isExprList())
		{
			if (match(';'))
			{
				advance();
				return 1;
			}
		}
	}

	if (match(SCAN))
	{
		advance();
		if (isIDList())
		{
			if (match(';'))
			{
				return 1;
			}
		}
	}

	return 0;
}
Exemplo n.º 9
0
 Statement(const int &row, const int &col, const int &endrow,
           const int &endcol, const string &raw)
     : CompoundNode(row, col, endrow, endcol, raw) {
   isStatement(true);
 }
Exemplo n.º 10
0
 ~Statement() { isStatement(true); }
Exemplo n.º 11
0
 BreakNode(const int &row, const int &col, const int &endrow,
           const int &endcol, const string &raw)
     : Node(row, col, endrow, endcol, raw) {
   isStatement(true);
 }