execute all statements
@param stmts    statements
@param context  context data
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;
		}
	}
}
1282059
@Override
	public void execute(final Object context, int uiTaskId, final Object... args) {
		
		Activity activity = ContextUtils.asActivity(context);
		
		Set<Method> methods = MethodUtils.getAllMethods(context, UI.class);
		
		for (final Method method : methods) {
			
			final UI uiTask = method.getAnnotation(UI.class);
			
			if(uiTask.value() == uiTaskId) {
			
				final Runnable runnable = new Runnable() {
				
					@Override
					public void run() {
					
						try {
										
							if(!method.isAccessible()) method.setAccessible(true);
										
							method.invoke(context, args);
						} 
						catch (Exception e) {
							
							StringBuilder stringBuilder = new StringBuilder()
							.append("Failed to execute UI task ")
							.append(method.getName())
							.append(" on ")
							.append(context.getClass().getName())
							.append(" with arguments ")
							.append(Arrays.toString(args))
							.append(". ");
										
							Log.e(UITaskService.class.getName(), stringBuilder.toString(), e);
						}
					}
				};
				
				if(uiTask.delay() > 0l) {
				
					try {
						
						Thread.sleep(uiTask.delay());
					}
					catch (InterruptedException ie) {
						
						StringBuilder stringBuilder = new StringBuilder()
						.append("UI task delay of ")
						.append(uiTask.delay())
						.append(" for ")
						.append(method.getName())
						.append(" on ")
						.append(context.getClass().getName())
						.append(" was interrupted!");
						
						Log.e(getClass().getSimpleName(), stringBuilder.toString(), ie);
					}
				}
				
				activity.runOnUiThread(runnable);
				break;
			}
		}
	}
944189
public static function analyze(
        StatementsAnalyzer $statements_analyzer,
        PhpParser\Node\Expr\Ternary $stmt,
        Context $context
    ) {
        $first_if_cond_expr = IfAnalyzer::getDefinitelyEvaluatedExpression($stmt->cond);

        $context->inside_conditional = true;

        $pre_condition_vars_in_scope = $context->vars_in_scope;

        $referenced_var_ids = $context->referenced_var_ids;
        $context->referenced_var_ids = [];

        $pre_assigned_var_ids = $context->assigned_var_ids;
        $context->assigned_var_ids = [];

        if ($first_if_cond_expr) {
            if (ExpressionAnalyzer::analyze($statements_analyzer, $first_if_cond_expr, $context) === false) {
                return false;
            }
        }

        $first_cond_assigned_var_ids = $context->assigned_var_ids;
        $context->assigned_var_ids = array_merge(
            $pre_assigned_var_ids,
            $first_cond_assigned_var_ids
        );

        /** @var array<string, bool> */
        $first_cond_referenced_var_ids = $context->referenced_var_ids;
        $context->referenced_var_ids = array_merge(
            $referenced_var_ids,
            $first_cond_referenced_var_ids
        );

        $context->inside_conditional = false;

        $t_if_context = clone $context;

        $t_if_context->inside_conditional = true;

        if ($first_if_cond_expr !== $stmt->cond) {
            $assigned_var_ids = $context->assigned_var_ids;
            $t_if_context->assigned_var_ids = [];

            $referenced_var_ids = $context->referenced_var_ids;
            $t_if_context->referenced_var_ids = [];

            if (ExpressionAnalyzer::analyze($statements_analyzer, $stmt->cond, $t_if_context) === false) {
                return false;
            }

            /** @var array<string, bool> */
            $more_cond_referenced_var_ids = $t_if_context->referenced_var_ids;
            $t_if_context->referenced_var_ids = array_merge(
                $more_cond_referenced_var_ids,
                $referenced_var_ids
            );

            $cond_referenced_var_ids = array_merge(
                $first_cond_referenced_var_ids,
                $more_cond_referenced_var_ids
            );

            /** @var array<string, bool> */
            $more_cond_assigned_var_ids = $t_if_context->assigned_var_ids;
            $t_if_context->assigned_var_ids = array_merge(
                $more_cond_assigned_var_ids,
                $assigned_var_ids
            );

            $cond_assigned_var_ids = array_merge(
                $first_cond_assigned_var_ids,
                $more_cond_assigned_var_ids
            );
        } else {
            $cond_referenced_var_ids = $first_cond_referenced_var_ids;

            $cond_assigned_var_ids = $first_cond_assigned_var_ids;
        }

        $newish_var_ids = array_map(
            /**
             * @param Type\Union $_
             *
             * @return true
             */
            function (Type\Union $_) {
                return true;
            },
            array_diff_key(
                $t_if_context->vars_in_scope,
                $pre_condition_vars_in_scope,
                $cond_referenced_var_ids,
                $cond_assigned_var_ids
            )
        );

        // get all the var ids that were referened in the conditional, but not assigned in it
        $cond_referenced_var_ids = array_diff_key($cond_referenced_var_ids, $cond_assigned_var_ids);

        // remove all newly-asserted var ids too
        $cond_referenced_var_ids = array_filter(
            $cond_referenced_var_ids,
            /**
             * @param string $var_id
             *
             * @return bool
             */
            function ($var_id) use ($pre_condition_vars_in_scope) {
                return isset($pre_condition_vars_in_scope[$var_id]);
            },
            ARRAY_FILTER_USE_KEY
        );

        $cond_referenced_var_ids = array_merge($newish_var_ids, $cond_referenced_var_ids);

        $t_if_context->inside_conditional = false;

        $codebase = $statements_analyzer->getCodebase();

        $if_clauses = \Psalm\Type\Algebra::getFormula(
            $stmt->cond,
            $statements_analyzer->getFQCLN(),
            $statements_analyzer,
            $codebase
        );

        $mixed_var_ids = [];

        foreach ($context->vars_in_scope as $var_id => $type) {
            if ($type->hasMixed()) {
                $mixed_var_ids[] = $var_id;
            }
        }

        foreach ($context->vars_possibly_in_scope as $var_id => $_) {
            if (!isset($context->vars_in_scope[$var_id])) {
                $mixed_var_ids[] = $var_id;
            }
        }


        $if_clauses = array_values(
            array_map(
                /**
                 * @return \Psalm\Internal\Clause
                 */
                function (\Psalm\Internal\Clause $c) use ($mixed_var_ids) {
                    $keys = array_keys($c->possibilities);

                    foreach ($keys as $key) {
                        foreach ($mixed_var_ids as $mixed_var_id) {
                            if (preg_match('/^' . preg_quote($mixed_var_id, '/') . '(\[|-)/', $key)) {
                                return new \Psalm\Internal\Clause([], true);
                            }
                        }
                    }

                    return $c;
                },
                $if_clauses
            )
        );

        $ternary_clauses = Algebra::simplifyCNF(array_merge($context->clauses, $if_clauses));

        $negated_clauses = Algebra::negateFormula($if_clauses);

        $negated_if_types = Algebra::getTruthsFromFormula(
            Algebra::simplifyCNF(
                array_merge($context->clauses, $negated_clauses)
            )
        );

        $reconcilable_if_types = Algebra::getTruthsFromFormula($ternary_clauses, $cond_referenced_var_ids);

        $changed_var_ids = [];

        if ($reconcilable_if_types) {
            $t_if_vars_in_scope_reconciled = Reconciler::reconcileKeyedTypes(
                $reconcilable_if_types,
                $t_if_context->vars_in_scope,
                $changed_var_ids,
                $cond_referenced_var_ids,
                $statements_analyzer,
                [],
                $t_if_context->inside_loop,
                new CodeLocation($statements_analyzer->getSource(), $stmt->cond)
            );

            $t_if_context->vars_in_scope = $t_if_vars_in_scope_reconciled;
        }

        $t_else_context = clone $context;

        if ($stmt->if) {
            if (ExpressionAnalyzer::analyze($statements_analyzer, $stmt->if, $t_if_context) === false) {
                return false;
            }

            foreach ($t_if_context->vars_in_scope as $var_id => $type) {
                if (isset($context->vars_in_scope[$var_id])) {
                    $context->vars_in_scope[$var_id] = Type::combineUnionTypes($context->vars_in_scope[$var_id], $type);
                }
            }

            $context->referenced_var_ids = array_merge(
                $context->referenced_var_ids,
                $t_if_context->referenced_var_ids
            );

            $context->unreferenced_vars = array_intersect_key(
                $context->unreferenced_vars,
                $t_if_context->unreferenced_vars
            );
        }

        if ($negated_if_types) {
            $t_else_vars_in_scope_reconciled = Reconciler::reconcileKeyedTypes(
                $negated_if_types,
                $t_else_context->vars_in_scope,
                $changed_var_ids,
                $cond_referenced_var_ids,
                $statements_analyzer,
                [],
                $t_else_context->inside_loop,
                new CodeLocation($statements_analyzer->getSource(), $stmt->else)
            );

            $t_else_context->vars_in_scope = $t_else_vars_in_scope_reconciled;
        }

        if (ExpressionAnalyzer::analyze($statements_analyzer, $stmt->else, $t_else_context) === false) {
            return false;
        }

        foreach ($t_else_context->vars_in_scope as $var_id => $type) {
            if (isset($context->vars_in_scope[$var_id])) {
                $context->vars_in_scope[$var_id] = Type::combineUnionTypes(
                    $context->vars_in_scope[$var_id],
                    $type
                );
            } elseif (isset($t_if_context->vars_in_scope[$var_id])) {
                $context->vars_in_scope[$var_id] = Type::combineUnionTypes(
                    $t_if_context->vars_in_scope[$var_id],
                    $type
                );
            }
        }

        $context->vars_possibly_in_scope = array_merge(
            $context->vars_possibly_in_scope,
            $t_if_context->vars_possibly_in_scope,
            $t_else_context->vars_possibly_in_scope
        );

        $context->referenced_var_ids = array_merge(
            $context->referenced_var_ids,
            $t_else_context->referenced_var_ids
        );

        $context->unreferenced_vars = array_intersect_key(
            $context->unreferenced_vars,
            $t_else_context->unreferenced_vars
        );

        $lhs_type = null;

        if ($stmt->if) {
            if (isset($stmt->if->inferredType)) {
                $lhs_type = $stmt->if->inferredType;
            }
        } elseif (isset($stmt->cond->inferredType)) {
            $if_return_type_reconciled = Reconciler::reconcileTypes(
                '!falsy',
                $stmt->cond->inferredType,
                '',
                $statements_analyzer,
                $context->inside_loop,
                [],
                new CodeLocation($statements_analyzer->getSource(), $stmt),
                $statements_analyzer->getSuppressedIssues()
            );

            $lhs_type = $if_return_type_reconciled;
        }

        if (!$lhs_type || !isset($stmt->else->inferredType)) {
            $stmt->inferredType = Type::getMixed();
        } else {
            $stmt->inferredType = Type::combineUnionTypes($lhs_type, $stmt->else->inferredType);
        }

        return null;
    }
233385
protected function _process( array $stmts )
	{
		$this->_msg( 'Adding constraint for table mshop_product_tag', 0 ); $this->_status( '' );

		if( $this->_schema->tableExists( 'mshop_product_tag' ) === true )
		{
			foreach ( $stmts as $constraint=>$stmt )
			{
				$this->_msg( sprintf( 'Checking constraint "%1$s": ', $constraint ), 1 );

				if( $this->_schema->constraintExists( 'mshop_product_tag', $constraint ) === false )
				{
					$this->_execute( $stmt );
					$this->_status( 'added' );
				}
				else
				{
					$this->_status( 'OK' );
				}
			}
		}
	}
1109701
public void execute(Runnable statements)
	{
		try (HibernateTransaction tx = start().withAutoRollback())
		{
			statements.run();

			// Success, perform a TX commit
			tx.commit();
		}
	}
20344
protected function _process( array $stmts )
	{
		$this->_msg( 'Migrating catalog suggest tables', 0 ); $this->_status( '' );
		$this->_msg( sprintf( 'Checking table "%1$s": ', 'mshop_catalog_suggest' ), 1 );

		if( $this->_schema->tableExists( 'mshop_catalog_suggest' ) === true )
		{
			$result = $this->_conn->create( $stmts['gettypeid'] )->execute();

			if( ( $row = $result->fetch( MW_DB_Result_Abstract::FETCH_NUM ) ) === false ) {
				throw new MW_Setup_Exception( 'Product list type "suggestion" is missing' );
			}

			$result->finish();


			$result = $this->_conn->create( str_replace( ':typeid', $row[0], $stmts['migrate'] ) )->execute();
			$count = $result->affectedRows();
			$result->finish();


			$this->_executeList( $stmts['drop'] );

			$this->_status( sprintf( 'migrated (%1$d)', $count ) );
		}
		else
		{
			$this->_status( 'OK' );
		}
	}
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)
1180683
protected function process( array $stmts )
	{
		$this->msg( 'Adding "vatid" column to fe_users tables', 0 ); $this->status( '' );

		foreach( $stmts as $table => $stmt )
		{
			$this->msg( sprintf( 'Checking "%1$s" table', $table ), 1 );

			if( $this->schema->tableExists( $table ) === true
				&& $this->schema->columnExists( $table, 'vatid' ) === false )
			{
				$this->execute( $stmt );
				$this->status( 'added' );
			} else {
				$this->status( 'OK' );
			}
		}
	}
642673
def execute(stmt, args=()):
    
    ctx = Context.current()
    with ctx.mdr:
        cursor = ctx.execute(stmt, args)
        row_count = cursor.rowcount
        _safe_close(cursor)
    return row_count
325272
protected function _process( array $stmts )
	{
		$table = "madmin_job";
		$this->_msg( sprintf( 'Converting "%1$s" to InnoDB".', $table ), 0 );

		$stmt = $this->_conn->create( $stmts['check'] );
		$stmt->bind( 1, $this->_schema->getDBName() );
		$stmt->bind( 2, $table );
		$result = $stmt->execute();
		$dbname = $result->fetch();
		$result->finish();

		if( $this->_schema->tableExists( $table ) === true
			&& $dbname['ENGINE'] === 'MyISAM' )
		{
			$this->_execute( $stmts['convert'] );
			$this->_status( 'converted' );
		}
		else
		{
			$this->_status( 'OK' );
		}
	}
869911
protected function _process( $stmts )
	{
		$this->_msg( 'Renameing shipping to costs in catalog index price table', 0 );

		if( $this->_schema->tableExists( 'mshop_catalog_index_price' ) === true
			&& $this->_schema->columnExists( 'mshop_catalog_index_price', 'shipping' ) === true )
		{
			$this->_execute( $stmts );
			$this->_status( 'done' );
		}
		else
		{
			$this->_status( 'OK' );
		}
	}
530282
public static void close(Statement stmt) {
        if (stmt != null) {
            try {
                stmt.close();
            } catch (SQLException ex) {
                logger.error("", ex);
            }
        }
    }
1348782
private Status executeContinue(Stmt.Continue stmt, CallStack frame, EnclosingScope scope) {
		return Status.CONTINUE;
	}
28184
def _handle_substatements(self, stmt: Statement, sctx: SchemaContext) -> None:
        """"""
        for s in stmt.substatements:
            if s.prefix:
                key = (
                    sctx.schema_data.modules[sctx.text_mid].prefix_map[s.prefix][0]
                    + ":" + s.keyword)
            else:
                key = s.keyword
            mname = SchemaNode._stmt_callback.get(key, "_noop")
            method = getattr(self, mname)
            method(s, sctx)
957754
protected function process( array $stmts )
	{
		$table = 'users_address';
		$this->msg( sprintf( 'Rename "refid" to "parentid" in table "%1$s"', $table ), 0 ); $this->status( '' );

		foreach( $stmts as $column => $stmts )
		{
			$this->msg( sprintf( 'Checking column "%1$s"', $column ), 1 );

			if( $this->schema->tableExists( $table )
				&& $this->schema->columnExists( $table, $column ) === true
			) {
				$this->executeList( $stmts );
				$this->status( 'done' );
			} else {
				$this->status( 'OK' );
			}
		}
	}
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) {
	}
    }
1018019
private void executeStatement(String statement) throws SQLException {

        Statement stmt = null;

        try {
            stmt = m_con.createStatement();
            stmt.execute(statement);
        } finally {
            if (stmt != null) {
                stmt.close();
            }
        }
    }