Translate an assert statement. This emits a verification condition which
ensures the assert condition holds, given the current context.

@param stmt
@param wyalFile
435427
private Context translateAssert(WyilFile.Stmt.Assert stmt, Context context) {
		Pair<Expr, Context> p = translateExpressionWithChecks(stmt.getCondition(), null, context);
		Expr condition = p.first();
		context = p.second();
		//
		VerificationCondition verificationCondition = new VerificationCondition("assertion failed", context.assumptions,
				condition, stmt.getCondition().getParent(WyilFile.Attribute.Span.class));
		context.emit(verificationCondition);
		//
		return context.assume(condition);
	}
224538
private Context translateWhile(WyilFile.Stmt.While stmt, Context context) {
		WyilFile.Decl.FunctionOrMethod declaration = (WyilFile.Decl.FunctionOrMethod) context.getEnvironment()
				.getParent().enclosingDeclaration;
		// Translate the loop invariant and generate appropriate macro
		translateLoopInvariantMacros(stmt, declaration, context.wyalFile);
		// Rule 1. Check loop invariant on entry
		checkLoopInvariant("loop invariant may not hold on entry", stmt, context);
		// Rule 2. Check loop invariant preserved. On entry to the loop body we
		// must havoc all modified variables. This is necessary as such
		// variables should retain their values from before the loop.
		LoopScope scope = new LoopScope();
		Context beforeBodyContext = context.newLoopScope(scope).havoc(stmt.getModified());
		beforeBodyContext = assumeLoopInvariant(stmt, beforeBodyContext);
		Pair<Expr, Context> p = translateExpressionWithChecks(stmt.getCondition(), null, beforeBodyContext);
		Expr trueCondition = p.first();
		beforeBodyContext = p.second().assume(trueCondition);
		Context afterBodyContext = translateStatementBlock(stmt.getBody(), beforeBodyContext);
		// Join continue contexts together since they must also preserve the
		// loop invariant
		afterBodyContext = joinDescendants(beforeBodyContext, afterBodyContext, scope.continueContexts);
		checkLoopInvariant("loop invariant may not be restored", stmt, afterBodyContext);
		// Rule 3. Assume loop invariant holds.
		Context exitContext = context.havoc(stmt.getModified());
		exitContext = assumeLoopInvariant(stmt, exitContext);
		Expr falseCondition = invertCondition(
				translateExpression(stmt.getCondition(), null, exitContext.getEnvironment()), stmt.getCondition());
		exitContext = exitContext.assume(falseCondition);
		//
		// Finally, need to join any break contexts
		exitContext = joinDescendants(context, exitContext, scope.breakContexts);
		//
		return exitContext;
	}
486702
private Context translateDoWhile(WyilFile.Stmt.DoWhile stmt, Context context) {
		WyilFile.Decl.FunctionOrMethod declaration = (WyilFile.Decl.FunctionOrMethod) context.getEnvironment()
				.getParent().enclosingDeclaration;
		// Translate the loop invariant and generate appropriate macro
		translateLoopInvariantMacros(stmt, declaration, context.wyalFile);
		// Rule 1. Check loop invariant after first iteration
		LoopScope firstScope = new LoopScope();
		Context beforeFirstBodyContext = context.newLoopScope(firstScope);
		Context afterFirstBodyContext = translateStatementBlock(stmt.getBody(), beforeFirstBodyContext);
		// Join continue contexts together since they must also preserve the
		// loop invariant
		afterFirstBodyContext = joinDescendants(beforeFirstBodyContext, afterFirstBodyContext,
				firstScope.continueContexts);
		//
		checkLoopInvariant("loop invariant may not be established by first iteration", stmt, afterFirstBodyContext);
		// Rule 2. Check loop invariant preserved on subsequence iterations. On
		// entry to the loop body we must havoc all modified variables. This is
		// necessary as such variables should retain their values from before
		// the loop.
		LoopScope arbitraryScope = new LoopScope();
		Context beforeArbitraryBodyContext = context.newLoopScope(arbitraryScope).havoc(stmt.getModified());
		beforeArbitraryBodyContext = assumeLoopInvariant(stmt, beforeArbitraryBodyContext);
		Pair<Expr, Context> p = translateExpressionWithChecks(stmt.getCondition(), null, beforeArbitraryBodyContext);
		Expr trueCondition = p.first();
		beforeArbitraryBodyContext = p.second().assume(trueCondition);
		Context afterArbitraryBodyContext = translateStatementBlock(stmt.getBody(), beforeArbitraryBodyContext);
		// Join continue contexts together since they must also preserve the
		// loop invariant
		afterArbitraryBodyContext = joinDescendants(beforeArbitraryBodyContext, afterArbitraryBodyContext,
				arbitraryScope.continueContexts);
		//
		checkLoopInvariant("loop invariant may not be restored", stmt, afterArbitraryBodyContext);
		// Rule 3. Assume loop invariant holds.
		Context exitContext = context.havoc(stmt.getModified());
		exitContext = assumeLoopInvariant(stmt, exitContext);
		Expr falseCondition = invertCondition(
				translateExpression(stmt.getCondition(), null, exitContext.getEnvironment()), stmt.getCondition());
		exitContext = exitContext.assume(falseCondition);
		//
		// Finally, need to join any break contexts from either first iteration
		// or arbitrary iteration
		exitContext = joinDescendants(context, exitContext, firstScope.breakContexts, arbitraryScope.breakContexts);
		//
		return exitContext;
	}
1284947
def assert_or_raise(stmt: bool, exception: Exception,
                    *exception_args, **exception_kwargs) -> None:
  
  if not stmt:
    raise exception(*exception_args, **exception_kwargs)
323419
def _container_stmt(self, stmt: Statement, sctx: SchemaContext) -> None:
        """"""
        self._handle_child(ContainerNode(), stmt, sctx)
115137
public static void assertTrue(String message, boolean value) {
        if (value) {
            pass(message);
        } else {
            fail(message, null);
        }
    }
232532
def _rpc_action_stmt(self, stmt: Statement, sctx: SchemaContext) -> None:
        """"""
        self._handle_child(RpcActionNode(), stmt, sctx)
357367
function execute(stmts,context){
	var stmt;
	var exprs;
	var ignoreNest=0;
	var isActive=true;
	var blkStack=[];
	var blkState=0; // 0:executing, 1:if-executing, 2:, if-finding, 3: if-ending, (4:ignore)
	var mode=context.mode;

	if(mode=='cond'){
		executeExpr=executeExpr_withLog_;
	}else{
		executeExpr=executeExpr_;
	}

	for(var i=0;i<stmts.length;i++){
		stmt=stmts[i];
		if(mode=='stmt'){
			console.log(JSON.stringify(stmt));
		}
		exprs=(stmt.exprs)?stmt.exprs:null;
		switch(stmt.type){
		case 'text':
			if(isActive){
				var key;
				if(stmt.value!='//'){
					context.buf+=stmt.value.replace(textRegex,function(match){
						key=match.substring(8,match.length-1);
						return context.params[key] || key;
					});
					context.buf+="\n";
				}
			}
			break;
		case 'define':
			if(isActive){
				context.params[exprs[0]]=executeExpr(exprs[1],context);
			}
			break;
		case 'include':{
			var oldcurdir=context.curdir;
			var filepath=mpath.join(context.curdir,exprs[0]);
			context.curdir=mpath.dirname(filepath);
			var doc=readFileSync_(filepath);
			if(doc!=null){
				compile(doc, context);
				if(!context.includes){
					context.includes={};
				}
				context.includes[exprs[0]]=true;
			}else{
				console.log("error: invalid include file "+exprs[0]);
			}
			context.curdir=oldcurdir;
			break;}
		case 'include_once':{
			if(context.includes&&(context.includes[exprs[0]])){
				// ignore
			}else{
				var oldcurdir=context.curdir;
				var filepath=mpath.join(context.curdir,exprs[0]);
				context.curdir=mpath.dirname(filepath);

				var doc=readFileSync_(filepath);
				if(doc!=null){
					compile(doc, context);
					if(!context.includes){
						context.includes={};
					}
					context.includes[exprs[0]]=true;
				}else{
					console.log("error: invalid include file "+exprs[0]);
				}

				context.curdir=oldcurdir;
			}
			break;}
		case 'include_code':{
			var oldcurdir=context.curdir;
			var filepath=mpath.join(context.curdir,exprs[0]);
			context.curdir=mpath.dirname(filepath);
			var doc=readFileCodeSync_(filepath);
			if(doc!=null){
				compile(doc, context);
				if(!context.includes){
					context.includes={};
				}
				context.includes[exprs[0]]=true;
			}else{
				console.log("error: invalid include file "+exprs[0]);
			}
			context.curdir=oldcurdir;
			break;}
		case 'include_code_once':{
			if(context.includes&&(context.includes[exprs[0]])){
				// ignore
			}else{
				var oldcurdir=context.curdir;
				var filepath=mpath.join(context.curdir,exprs[0]);
				context.curdir=mpath.dirname(filepath);
				var doc=readFileCodeSync_(filepath);
				if(doc!=null){
					compile(doc, context);
					if(!context.includes){
						context.includes={};
					}
					context.includes[exprs[0]]=true;
				}else{
					console.log("error: invalid include file "+exprs[0]);
				}
				context.curdir=oldcurdir;
			}
			break;}
		case 'if':
			if(isActive){
				//assert(blkState==0)
				if(mode=='cond'){
					console.log("stmt:"+executeExpr(exprs,context)+'<='+JSON.stringify(stmt));
				}
				if(executeExpr(exprs,context)){
					blkState=1; //if-executing
				}else{
					blkState=2; //if-finding
				}
				if(blkState==1){ //if-executing
					blkStack.push(blkState);
					blkState=0;
				}else{
					isActive=false;
					ignoreNest++;
				}
			}else{
				ignoreNest++;
			}
			break;
		case 'elseif':
		case 'elif':
		case 'else':
			if(isActive){
				blkState=blkStack.pop();
			}else{
				ignoreNest--;
				if(ignoreNest==0){
					isActive=true;
				}
			}
			if(isActive){
				switch(blkState){
				case 1: //if-executing
					blkState=3;//if-ending
					break;
				case 2: //if-finding
					if((mode=='cond')&&((stmt.type=='elseif')||(stmt.type=='elif'))){
						console.log('stmt:'+executeExpr(exprs,context)+'<='+JSON.stringify(stmt));
					}
					if((stmt.type=='else')||(executeExpr(exprs,context))){
						blkState=1; //if-executing
					}else{
						//nothing to do
					}
					break;
				case 3://if-ending
					// nothing to do
					break;
				}
				if(blkState==1){ //if-executing
					blkStack.push(blkState);
					blkState=0;
				}else{
					//blkState=4; //ignore
					isActive=false;
					ignoreNest++;
				}
			}else{
				ignoreNest++;
			}
			break;
		case 'endif':
			if(isActive){
				blkState=blkStack.pop();
			}else{
				ignoreNest--;
				if(ignoreNest==0){
					isActive=true;
				}
			}
			if(isActive){
				blkState=0;
			}
			break;
		default:
			break;
		}
	}
}
571660
private Environment checkAssign(Stmt.Assign stmt, Environment environment, EnclosingScope scope)
			throws IOException {
		Tuple<LVal> lvals = stmt.getLeftHandSide();
		Type[] types = new Type[lvals.size()];
		for (int i = 0; i != lvals.size(); ++i) {
			types[i] = checkLVal(lvals.get(i), environment);
		}
		checkMultiExpressions(stmt.getRightHandSide(), environment, new Tuple<>(types));
		return environment;
	}
752898
def split_bel_stmt(stmt: str, line_num) -> tuple:
    """"""

    m = re.match(f"^(.*?\))\s+([a-zA-Z=\->\|:]+)\s+([\w(]+.*?)$", stmt, flags=0)
    if m:
        return (m.group(1), m.group(2), m.group(3))
    else:
        log.info(
            f"Could not parse bel statement into components at line number: {line_num} assertion: {stmt}"
        )
        return (stmt, None, None)
696350
public void addAssertions(Assertions asserts) {
    if (getCommandline().getAssertions() != null) {
        throw new BuildException("Only one assertion declaration is allowed");
    }
    getCommandline().setAssertions(asserts);
  }
483863
def where_stmt_handle(tokens):
    """"""
    internal_assert(len(tokens) == 2, "invalid where statement tokens", tokens)
    base_stmt, assignment_stmts = tokens
    stmts = list(assignment_stmts) + [base_stmt]
    return "\n".join(stmts) + "\n"
666862
@Override
    public void assertStatement(org.openrdf.model.Statement stmnt) {
	try {
	    if (currentContext==null) {
		manager.getConnection().add(stmnt);
	    } else {
		manager.getConnection().add(stmnt, currentContext);
	    }
	} catch (org.openrdf.repository.RepositoryException e) {
	}
    }
772928
def _uses_stmt(self, stmt: Statement, sctx: SchemaContext) -> None:
        """"""
        if not sctx.schema_data.if_features(stmt, sctx.text_mid):
            return
        grp, gid = sctx.schema_data.get_definition(stmt, sctx)
        if stmt.find1("when"):
            sn = GroupNode()
            self._add_child(sn)
        else:
            sn = self
        sn._handle_substatements(grp, gid)
        for augst in stmt.find_all("augment"):
            sn._augment_stmt(augst, sctx)
        for refst in stmt.find_all("refine"):
            sn._refine_stmt(refst, sctx)
292199
@Override
    public void verifyMIC ( byte[] data, byte[] mic ) throws CIFSException {
        if ( !this.completed ) {
            throw new CIFSException("Context is not established");
        }
        this.mechContext.verifyMIC(data, mic);
    }
1372557
private Context translateSwitch(WyilFile.Stmt.Switch stmt, Context context) {
		Tuple<WyilFile.Stmt.Case> cases = stmt.getCases();
		//
		Pair<Expr, Context> p = translateExpressionWithChecks(stmt.getCondition(), null, context);
		Expr value = p.first();
		context = p.second();
		//
		WyalFile.Stmt defaultValue = null;
		Context[] descendants = new Context[cases.size() + 1];
		Context defaultContext = null;
		boolean hasDefault = false;
		//
		for (int i = 0; i != cases.size(); ++i) {
			WyilFile.Stmt.Case caSe = cases.get(i);
			Context caseContext;
			// Setup knowledge from case values
			if (!caSe.isDefault()) {
				WyalFile.Stmt e = null;
				for (WyilFile.Expr constant : caSe.getConditions()) {
					// Expr v = convert(constant, stmt, context.getEnvironment());
					Expr v = translateExpression(constant, null, context.getEnvironment());
					e = or(e, new Expr.Equal(value, v));
					defaultValue = and(defaultValue, new Expr.NotEqual(value, v));
				}
				caseContext = context.assume(e);
				descendants[i] = translateStatementBlock(caSe.getBlock(), caseContext);
			} else {
				defaultContext = context.assume(defaultValue);
				defaultContext = translateStatementBlock(caSe.getBlock(), defaultContext);
				hasDefault = true;
			}
		}
		// Sort out default context
		if (!hasDefault) {
			// indicates no default block was present, so we just assume what we
			// know and treat it as a fall through.
			defaultContext = context.assume(defaultValue);
		}
		descendants[descendants.length - 1] = defaultContext;
		//
		return joinDescendants(context, descendants);
	}
401637
protected function validateNewExpression(New_ $stmt)
    {
        // if class name is an expression or an anonymous class, give it a pass for now
        if (!$stmt->class instanceof Expr && !$stmt->class instanceof Class_) {
            $this->ensureClassExists($this->getFullyQualifiedName($stmt->class), $stmt);
        }
    }