本文整理汇总了C#中Statement类的典型用法代码示例。如果您正苦于以下问题:C# Statement类的具体用法?C# Statement怎么用?C# Statement使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Statement类属于命名空间,在下文中一共展示了Statement类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Resolve
public IEnumerable<Solution> Resolve(Statement st, Solution solution) {
Contract.Assert(ExtractGuard(st) != null, Error.MkErr(st, 2));
/**
* Check if the loop guard can be resolved localy
*/
return IsResolvable() ? ExecuteLoop(st as WhileStmt) : InsertLoop(st as WhileStmt);
}
示例2: ForLoopStatement
public ForLoopStatement(ScriptLoadingContext lcontext, Token nameToken, Token forToken)
: base(lcontext)
{
// for Name ‘=’ exp ‘,’ exp [‘,’ exp] do block end |
// lexer already at the '=' ! [due to dispatching vs for-each]
CheckTokenType(lcontext, TokenType.Op_Assignment);
m_Start = Expression.Expr(lcontext);
CheckTokenType(lcontext, TokenType.Comma);
m_End = Expression.Expr(lcontext);
if (lcontext.Lexer.Current.Type == TokenType.Comma)
{
lcontext.Lexer.Next();
m_Step = Expression.Expr(lcontext);
}
else
{
m_Step = new LiteralExpression(lcontext, DynValue.NewNumber(1));
}
lcontext.Scope.PushBlock();
m_VarName = lcontext.Scope.DefineLocal(nameToken.Text);
m_RefFor = forToken.GetSourceRef(CheckTokenType(lcontext, TokenType.Do));
m_InnerBlock = new CompositeStatement(lcontext);
m_RefEnd = CheckTokenType(lcontext, TokenType.End).GetSourceRef();
m_StackFrame = lcontext.Scope.PopBlock();
lcontext.Source.Refs.Add(m_RefFor);
lcontext.Source.Refs.Add(m_RefEnd);
}
示例3: IfStatement
public IfStatement (int startIndex, ConditionStatement condition, Statement elseStatement, Statement endIfStatement)
{
Start = startIndex;
Condition = condition;
ElseStatement = elseStatement;
EndIfStatement = endIfStatement;
}
示例4: convertStatement
private static Statement convertStatement(JsonData jStatement)
{
if (jStatement[JsonDocumentFields.STATEMENT_EFFECT] == null || !jStatement[JsonDocumentFields.STATEMENT_EFFECT].IsString)
return null;
string jEffect = (string)jStatement[JsonDocumentFields.STATEMENT_EFFECT];
Statement.StatementEffect effect;
if (JsonDocumentFields.EFFECT_VALUE_ALLOW.Equals(jEffect))
effect = Statement.StatementEffect.Allow;
else
effect = Statement.StatementEffect.Deny;
Statement statement = new Statement(effect);
if (jStatement[JsonDocumentFields.STATEMENT_ID] != null && jStatement[JsonDocumentFields.STATEMENT_ID].IsString)
statement.Id = (string)jStatement[JsonDocumentFields.STATEMENT_ID];
convertActions(statement, jStatement);
convertResources(statement, jStatement);
convertCondition(statement, jStatement);
convertPrincipals(statement, jStatement);
return statement;
}
示例5: ForStatement
public ForStatement(Expression init, Expression condition, Expression loop, Statement body)
{
this.Init = init;
this.Condition = condition;
this.Loop = loop;
this.Body = body;
}
示例6: Translate
public static SUnit Translate(Statement statement)
{
// Return empty SUnit for empty statement.
if(statement.GetExpressions().Count() == 0)
{
return new SUnit(SUnitType.SingleMethodCall, "", "", "", new List<string>(), "void");
}
if(statement is ReturnStatement)
{
//Console.WriteLine("TRANSLATE RETURN");
return TranslateReturn(statement);
}
//
if (statement.GetExpressions().First() is VariableDeclaration)
{
//Console.WriteLine("TRANSLATE ASSIGNMENT");
return TranslateAssignment(statement);
}
else
{
//Console.WriteLine("TRANSLATE METHODCALL");
return TranslateMethodCall(statement);
}
}
示例7: Program
public Program(SourceSpan span, SourceSpan start, SourceSpan end, Statement body)
: base(span)
{
_start = start;
_end = end;
_body = body;
}
示例8: UnaryExpression
public UnaryExpression(Statement statement, object p, Expression expression, SourceData sourceData)
: base(statement, sourceData)
{
// TODO: Complete member initialization
this.p = p;
this.expression = expression;
}
示例9: PopTarget
public void PopTarget(Statement s)
{
Debug.Assert(Targets.Count > 0 && Targets[Targets.Count - 1] == s, "Target statement {0} does not exist in the list", s);
Targets.RemoveAt(Targets.Count - 1);
if (CompletionType == Interpreter.CompletionTypes.Break && CompletionTargetStatement == s)
SetCompletion(CompletionTypes.Normal, null);
}
示例10: IfStatement
public IfStatement(Predicate condition, Statement thenStatement, Statement elseStatement) {
Debug.Assert(condition != null);
Debug.Assert(thenStatement != null);
this.condition = condition;
this.thenStatement = thenStatement;
this.elseStatement = elseStatement;
}
示例11: CreateStatement_ExpectValid
public void CreateStatement_ExpectValid()
{
//Arrange
string localStatementIdString = "STMT01";
StatementId localStatementId = new StatementId(localStatementIdString);
SpecificFieldsFactory localfactory = new SpecificFieldsFactory();
string[] listspecificfields = { "Credit Card", "12" };
StatementType localStatementType = new StatementType(localfactory, "CreditCardProvider", listspecificfields);
StatementSpecificFields localspecificfields = localStatementType.getSpecificFields();
int localstatementAccountnumber = 1234567;
string localstatementAccountholdername = "Bruce";
DateTime localstatementDate = DateTime.Now;
StatementCommonFields localStatementCommonFields = new StatementCommonFields(localstatementAccountnumber, localstatementAccountholdername, localstatementDate);
APSUser localAPSUser = new APSUser(new APSUserId("1"), "testusername", "testpassword");
BillingAccount localBillingAccount = new BillingAccount(new BillingAccountId("1"), new BillingCompanyId("1"), "testusername", "testpassword", localAPSUser);
//Act
Statement localStatement = new Statement(localStatementId, localStatementCommonFields, localStatementType, localspecificfields, localAPSUser, localBillingAccount);
//Assert
Assert.AreEqual(localStatement.StatementId, localStatementId);
Assert.AreEqual(localStatement.StatementCommonFields, localStatementCommonFields);
Assert.AreEqual(localStatement.StatementType, localStatementType);
Assert.AreEqual(localStatement.StatementSpecificFields, localspecificfields);
Assert.AreEqual(localStatement.APSUser, localAPSUser);
Assert.AreEqual(localStatement.BillingAccount, localBillingAccount);
}
示例12: StopLossRule
public StopLossRule(string name,
TimeIntervalDefinition executeFrequency,
Variable iterator,
Statement statement,
BooleanExpression stopLossCondition,
Variable positionSet)
: base(name, executeFrequency,
// wrap the statement with for all loop
// and null checking for position
new ForAllStatement(
iterator, positionSet,
new IfStatement(new NotEqual(){
LeftExpression = new PropertyAccessor(iterator,"Currency"),
RightExpression = new Constant(typeof(DBNull),null)},
new CompositeStatement(
new List<Statement>{
statement,
new IfStatement(stopLossCondition,new PositionStopLoss(iterator))
}
)
)
), stopLossCondition, positionSet
)
{
}
示例13: Constants
private Solution Constants(Statement st) {
IVariable lv = null;
List<Expression> callArgs;
var result = new List<Expression>();
InitArgs(st, out lv, out callArgs);
Contract.Assert(lv != null, Error.MkErr(st, 8));
Contract.Assert(callArgs.Count == 1, Error.MkErr(st, 0, 1, callArgs.Count));
foreach(var arg1 in ResolveExpression(callArgs[0])) {
var expression = arg1 as Expression;
Contract.Assert(expression != null, Error.MkErr(st, 1, "Term"));
var expt = ExpressionTree.ExpressionToTree(expression);
var leafs = expt.GetLeafData();
foreach(var leaf in leafs) {
if(leaf is LiteralExpr) {
if(!result.Exists(j => (j as LiteralExpr)?.Value == (leaf as LiteralExpr)?.Value)) {
result.Add(leaf);
}
} else if(leaf is ExprDotName) {
var edn = leaf as ExprDotName;
if (!result.Exists(j => SingletonEquality(j, edn))) {
result.Add(leaf);
}
}
}
}
return AddNewLocal(lv, result);
}
示例14: PythonAst
public PythonAst(Statement body, bool isModule, ModuleOptions languageFeatures, bool printExpressions, CompilerContext context) {
ContractUtils.RequiresNotNull(body, "body");
_body = body;
_isModule = isModule;
_printExpressions = printExpressions;
_languageFeatures = languageFeatures;
_mode = ((PythonCompilerOptions)context.Options).CompilationMode ?? GetCompilationMode(context);
_compilerContext = context;
FuncCodeExpr = _functionCode;
PythonCompilerOptions pco = context.Options as PythonCompilerOptions;
Debug.Assert(pco != null);
string name;
if (!context.SourceUnit.HasPath || (pco.Module & ModuleOptions.ExecOrEvalCode) != 0) {
name = "<module>";
} else {
name = context.SourceUnit.Path;
}
_name = name;
Debug.Assert(_name != null);
PythonOptions po = ((PythonContext)context.SourceUnit.LanguageContext).PythonOptions;
if (po.EnableProfiler && _mode != CompilationMode.ToDisk) {
_profiler = Profiler.GetProfiler(PyContext);
}
_document = context.SourceUnit.Document ?? Ast.SymbolDocument(name, PyContext.LanguageGuid, PyContext.VendorGuid);
}
示例15: RetRemover
public RetRemover(Statement root)
{
_root = root;
IList<Statement> slist = root.AsStatementList();
if (slist.Count > 0)
_lastStatement = slist.Last();
}