本文整理汇总了C#中ProtoCore.AST.ImperativeAST.BinaryExpressionNode类的典型用法代码示例。如果您正苦于以下问题:C# ProtoCore.AST.ImperativeAST.BinaryExpressionNode类的具体用法?C# ProtoCore.AST.ImperativeAST.BinaryExpressionNode怎么用?C# ProtoCore.AST.ImperativeAST.BinaryExpressionNode使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ProtoCore.AST.ImperativeAST.BinaryExpressionNode类属于命名空间,在下文中一共展示了ProtoCore.AST.ImperativeAST.BinaryExpressionNode类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TestProtoASTExecute_Imperative_IfStatement02
List<ProtoCore.AST.AssociativeAST.AssociativeNode> astList = new List<ProtoCore.AST.AssociativeAST.AssociativeNode>();
astList.Add(assign);
// Verify the results
ExecutionMirror mirror = thisTest.RunASTSource(astList);
Obj o = mirror.GetValue("a");
Assert.IsTrue((Int64)o.Payload == 11);
}
[Test]
public void TestProtoASTExecute_Imperative_IfStatement02()
{
//
// a = [Imperative]
// {
// b = 10;
// if (b > 10)
// {
// b = 11;
// }
// else
// {
// b = 12
// }
// return = b;
// }
//
List<ProtoCore.AST.ImperativeAST.ImperativeNode> imperativeList = new List<ProtoCore.AST.ImperativeAST.ImperativeNode>();
// b = 10
ProtoCore.AST.ImperativeAST.BinaryExpressionNode imperativeAssign = new ProtoCore.AST.ImperativeAST.BinaryExpressionNode(
new ProtoCore.AST.ImperativeAST.IdentifierNode("b"),
new ProtoCore.AST.ImperativeAST.IntNode(10),
ProtoCore.DSASM.Operator.assign);
imperativeList.Add(imperativeAssign);
// if (b > 10)
ProtoCore.AST.ImperativeAST.BinaryExpressionNode equality = new ProtoCore.AST.ImperativeAST.BinaryExpressionNode(
new ProtoCore.AST.ImperativeAST.IdentifierNode("b"),
new ProtoCore.AST.ImperativeAST.IntNode(10),
ProtoCore.DSASM.Operator.gt);
ProtoCore.AST.ImperativeAST.IfStmtNode ifNode = new ProtoCore.AST.ImperativeAST.IfStmtNode();
ifNode.IfExprNode = equality;
// if body
// b = 11
ProtoCore.AST.ImperativeAST.BinaryExpressionNode ifCodeBlockStmt = new ProtoCore.AST.ImperativeAST.BinaryExpressionNode(
new ProtoCore.AST.ImperativeAST.IdentifierNode("b"),
new ProtoCore.AST.ImperativeAST.IntNode(11),
ProtoCore.DSASM.Operator.assign);
List<ProtoCore.AST.ImperativeAST.ImperativeNode> ifCodeBlock = new List<ProtoCore.AST.ImperativeAST.ImperativeNode>();
ifCodeBlock.Add(ifCodeBlockStmt);
ifNode.IfBody = ifCodeBlock;
// else body
// b = 12
ProtoCore.AST.ImperativeAST.BinaryExpressionNode elseCodeBlockStmt = new ProtoCore.AST.ImperativeAST.BinaryExpressionNode(
new ProtoCore.AST.ImperativeAST.IdentifierNode("b"),
new ProtoCore.AST.ImperativeAST.IntNode(12),
ProtoCore.DSASM.Operator.assign);
List<ProtoCore.AST.ImperativeAST.ImperativeNode> elseCodeBlock = new List<ProtoCore.AST.ImperativeAST.ImperativeNode>();
elseCodeBlock.Add(elseCodeBlockStmt);
ifNode.ElseBody = elseCodeBlock;
imperativeList.Add(ifNode);
// return = b
ProtoCore.AST.ImperativeAST.BinaryExpressionNode returnStmt = new ProtoCore.AST.ImperativeAST.BinaryExpressionNode(
new ProtoCore.AST.ImperativeAST.IdentifierNode("return"),
new ProtoCore.AST.ImperativeAST.IdentifierNode("b"),
ProtoCore.DSASM.Operator.assign);
imperativeList.Add(returnStmt);
// Build the language block
ProtoCore.AST.ImperativeAST.CodeBlockNode imperativeCodeBlock = new ProtoCore.AST.ImperativeAST.CodeBlockNode();
imperativeCodeBlock.Body = imperativeList;
ProtoCore.AST.AssociativeAST.LanguageBlockNode langblock = new ProtoCore.AST.AssociativeAST.LanguageBlockNode();
langblock.codeblock = new ProtoCore.LanguageCodeBlock(ProtoCore.Language.Imperative);
langblock.CodeBlockNode = imperativeCodeBlock;
// Build an assignment where the rhs is the imperative block
ProtoCore.AST.AssociativeAST.BinaryExpressionNode assign = new ProtoCore.AST.AssociativeAST.BinaryExpressionNode(
new ProtoCore.AST.AssociativeAST.IdentifierNode("a"),
langblock,
ProtoCore.DSASM.Operator.assign);
示例2: TestCodegenDS_Imperative_IfStatement01
// Generate the script
ProtoCore.CodeGenDS codegen = new ProtoCore.CodeGenDS(astList);
string code = codegen.GenerateCode();
ExecutionMirror mirror = thisTest.RunScriptSource(code);
Assert.IsTrue((Int64)mirror.GetValue("a").Payload == 10);
}
[Test]
public void TestCodegenDS_Imperative_IfStatement01()
{
//
// a = [Imperative]
// {
// b = 10;
// if (b == 10)
// {
// b = 11;
// }
// return = b;
// }
//
List<ProtoCore.AST.ImperativeAST.ImperativeNode> imperativeList = new List<ProtoCore.AST.ImperativeAST.ImperativeNode>();
// b = 10
ProtoCore.AST.ImperativeAST.BinaryExpressionNode imperativeAssign = new ProtoCore.AST.ImperativeAST.BinaryExpressionNode(
new ProtoCore.AST.ImperativeAST.IdentifierNode("b"),
new ProtoCore.AST.ImperativeAST.IntNode(10),
ProtoCore.DSASM.Operator.assign);
imperativeList.Add(imperativeAssign);
// if (b == 10)
ProtoCore.AST.ImperativeAST.BinaryExpressionNode equality = new ProtoCore.AST.ImperativeAST.BinaryExpressionNode(
new ProtoCore.AST.ImperativeAST.IdentifierNode("b"),
new ProtoCore.AST.ImperativeAST.IntNode(10),
ProtoCore.DSASM.Operator.eq);
ProtoCore.AST.ImperativeAST.IfStmtNode ifNode = new ProtoCore.AST.ImperativeAST.IfStmtNode();
ifNode.IfExprNode = equality;
// b = 11
ProtoCore.AST.ImperativeAST.BinaryExpressionNode ifCodeBlockStmt = new ProtoCore.AST.ImperativeAST.BinaryExpressionNode(
new ProtoCore.AST.ImperativeAST.IdentifierNode("b"),
new ProtoCore.AST.ImperativeAST.IntNode(11),
ProtoCore.DSASM.Operator.assign);
List<ProtoCore.AST.ImperativeAST.ImperativeNode> ifCodeBlock = new List<ProtoCore.AST.ImperativeAST.ImperativeNode>();
ifCodeBlock.Add(ifCodeBlockStmt);
ifNode.IfBody = ifCodeBlock;
imperativeList.Add(ifNode);
// return = b
ProtoCore.AST.ImperativeAST.BinaryExpressionNode returnStmt = new ProtoCore.AST.ImperativeAST.BinaryExpressionNode(
new ProtoCore.AST.ImperativeAST.IdentifierNode("return"),
new ProtoCore.AST.ImperativeAST.IdentifierNode("b"),
ProtoCore.DSASM.Operator.assign);
imperativeList.Add(returnStmt);
// Build the language block
ProtoCore.AST.ImperativeAST.CodeBlockNode imperativeCodeBlock = new ProtoCore.AST.ImperativeAST.CodeBlockNode();
imperativeCodeBlock.Body = imperativeList;
ProtoCore.AST.AssociativeAST.LanguageBlockNode langblock = new ProtoCore.AST.AssociativeAST.LanguageBlockNode();
langblock.codeblock = new ProtoCore.LanguageCodeBlock(ProtoCore.Language.Imperative);
langblock.CodeBlockNode = imperativeCodeBlock;
// Build an assignment where the rhs is the imperative block
ProtoCore.AST.AssociativeAST.BinaryExpressionNode assign = new ProtoCore.AST.AssociativeAST.BinaryExpressionNode(
new ProtoCore.AST.AssociativeAST.IdentifierNode("a"),
langblock,
ProtoCore.DSASM.Operator.assign);
List<ProtoCore.AST.AssociativeAST.AssociativeNode> astList = new List<ProtoCore.AST.AssociativeAST.AssociativeNode>();
示例3: TestProtoASTExecute_Imperative_Assign01
// Generate the script
ProtoCore.CodeGenDS codegen = new ProtoCore.CodeGenDS(astList);
string code = codegen.GenerateCode();
ExecutionMirror mirror = thisTest.RunScriptSource(code);
Assert.IsTrue((Int64)mirror.GetValue("a").Payload == 12);
}
[Test]
public void TestProtoASTExecute_Imperative_Assign01()
{
//
// a = [Imperative]
// {
// return = 10;
// }
//
List<ProtoCore.AST.ImperativeAST.ImperativeNode> imperativeList = new List<ProtoCore.AST.ImperativeAST.ImperativeNode>();
// return = 10
ProtoCore.AST.ImperativeAST.BinaryExpressionNode imperativeAssign = new ProtoCore.AST.ImperativeAST.BinaryExpressionNode(
new ProtoCore.AST.ImperativeAST.IdentifierNode("return"),
new ProtoCore.AST.ImperativeAST.IntNode(10),
ProtoCore.DSASM.Operator.assign);
imperativeList.Add(imperativeAssign);
// Build the language block
ProtoCore.AST.ImperativeAST.CodeBlockNode imperativeCodeBlock = new ProtoCore.AST.ImperativeAST.CodeBlockNode();
imperativeCodeBlock.Body = imperativeList;
ProtoCore.AST.AssociativeAST.LanguageBlockNode langblock = new ProtoCore.AST.AssociativeAST.LanguageBlockNode();
langblock.codeblock = new ProtoCore.LanguageCodeBlock(ProtoCore.Language.Imperative);
langblock.CodeBlockNode = imperativeCodeBlock;
// Build an assignment where the rhs is the imperative block
ProtoCore.AST.AssociativeAST.BinaryExpressionNode assign = new ProtoCore.AST.AssociativeAST.BinaryExpressionNode(
new ProtoCore.AST.AssociativeAST.IdentifierNode("a"),
langblock,
ProtoCore.DSASM.Operator.assign);
示例4: Imperative_DefaultArgDecl
void Imperative_DefaultArgDecl(out ProtoCore.AST.ImperativeAST.ImperativeNode node) {
Imperative_ArgDecl(out node);
ProtoCore.AST.ImperativeAST.VarDeclNode varDeclNode = node as ProtoCore.AST.ImperativeAST.VarDeclNode;
Expect(51);
ProtoCore.AST.ImperativeAST.ImperativeNode rhsNode;
Imperative_expr(out rhsNode);
ProtoCore.AST.ImperativeAST.BinaryExpressionNode bNode = new ProtoCore.AST.ImperativeAST.BinaryExpressionNode();
bNode.LeftNode = varDeclNode.NameNode;
bNode.RightNode = rhsNode;
bNode.Optr = Operator.assign;
NodeUtils.CopyNodeLocation(bNode, varDeclNode);
varDeclNode.NameNode = bNode;
node = varDeclNode;
if(!isGlobalScope) {
localVarCount++;
}
}
示例5: Imperative_functionalMethodBodySingleStatement
void Imperative_functionalMethodBodySingleStatement(out List<ProtoCore.AST.ImperativeAST.ImperativeNode> funcBody) {
funcBody = new List<ProtoCore.AST.ImperativeAST.ImperativeNode>();
ProtoCore.AST.ImperativeAST.BinaryExpressionNode binaryExpr = new ProtoCore.AST.ImperativeAST.BinaryExpressionNode();
binaryExpr.LeftNode = BuildImperativeIdentifier("return", ProtoCore.PrimitiveType.Return);
ProtoCore.AST.ImperativeAST.ImperativeNode expr;
Imperative_expr(out expr);
binaryExpr.RightNode = expr;
binaryExpr.Optr = Operator.assign;
funcBody.Add(binaryExpr);
if (la.kind != _endline)
SynErr(Resources.SemiColonExpected);
Expect(23);
}
示例6: Imperative_term
void Imperative_term(out ProtoCore.AST.ImperativeAST.ImperativeNode node) {
node = null;
#if ENABLE_BIT_OP
Imperative_interimfactor(out node);
#else
Imperative_factor(out node);
#endif
while (la.kind == 56 || la.kind == 57 || la.kind == 58) {
Operator op;
Imperative_mulop(out op);
ProtoCore.AST.ImperativeAST.ImperativeNode rhsNode;
#if ENABLE_BIT_OP
Imperative_interimfactor(out rhsNode);
#else
Imperative_factor(out rhsNode);
#endif
ProtoCore.AST.ImperativeAST.BinaryExpressionNode bNode = new ProtoCore.AST.ImperativeAST.BinaryExpressionNode();
bNode.LeftNode = node;
bNode.RightNode = rhsNode;
bNode.Optr = op;
NodeUtils.CopyNodeLocation(bNode, node);
node = bNode;
}
}
示例7: Imperative_interimfactor
void Imperative_interimfactor(out ProtoCore.AST.ImperativeAST.ImperativeNode node) {
node = null;
Imperative_factor(out node);
while (la.kind == 16 || la.kind == 59 || la.kind == 60) {
Operator op;
Imperative_bitop(out op);
ProtoCore.AST.ImperativeAST.ImperativeNode rhsNode;
Imperative_factor(out rhsNode);
ProtoCore.AST.ImperativeAST.BinaryExpressionNode bNode = new ProtoCore.AST.ImperativeAST.BinaryExpressionNode();
bNode.LeftNode = node;
bNode.RightNode = rhsNode;
bNode.Optr = op;
NodeUtils.CopyNodeLocation(bNode, node);
node = bNode;
}
}
示例8: Imperative_rel
void Imperative_rel(out ProtoCore.AST.ImperativeAST.ImperativeNode node) {
node = null;
Imperative_term(out node);
while (la.kind == 15 || la.kind == 55) {
Operator op;
Imperative_addop(out op);
ProtoCore.AST.ImperativeAST.ImperativeNode rhsNode;
Imperative_term(out rhsNode);
ProtoCore.AST.ImperativeAST.BinaryExpressionNode bNode = new ProtoCore.AST.ImperativeAST.BinaryExpressionNode();
bNode.LeftNode = node;
bNode.RightNode = rhsNode;
bNode.Optr = op;
NodeUtils.SetNodeLocation(bNode, bNode.LeftNode, bNode.RightNode);
node = bNode;
}
}
示例9: Imperative_logicalexpr
void Imperative_logicalexpr(out ProtoCore.AST.ImperativeAST.ImperativeNode node) {
node = null;
Imperative_RangeExpr(out node);
while (StartOf(18)) {
Operator op;
Imperative_relop(out op);
ProtoCore.AST.ImperativeAST.ImperativeNode rhsNode = null;
Imperative_RangeExpr(out rhsNode);
ProtoCore.AST.ImperativeAST.BinaryExpressionNode bNode = new ProtoCore.AST.ImperativeAST.BinaryExpressionNode();
bNode.LeftNode = node;
bNode.RightNode = rhsNode;
bNode.Optr = op;
NodeUtils.SetNodeLocation(bNode, bNode.LeftNode, bNode.RightNode);
node = bNode;
}
}
示例10: Imperative_binexpr
void Imperative_binexpr(out ProtoCore.AST.ImperativeAST.ImperativeNode node) {
node = null;
Imperative_logicalexpr(out node);
while (la.kind == 61 || la.kind == 62) {
Operator op;
Imperative_logicalop(out op);
ProtoCore.AST.ImperativeAST.ImperativeNode rhsNode = null;
Imperative_logicalexpr(out rhsNode);
ProtoCore.AST.ImperativeAST.BinaryExpressionNode bNode = new ProtoCore.AST.ImperativeAST.BinaryExpressionNode();
bNode.LeftNode = node;
bNode.RightNode = rhsNode;
bNode.Optr = op;
NodeUtils.CopyNodeLocation(bNode, node);
node = bNode;
}
}
示例11: Imperative_assignstmt
void Imperative_assignstmt(out ProtoCore.AST.ImperativeAST.ImperativeNode node) {
node = null;
ProtoCore.AST.ImperativeAST.BinaryExpressionNode bNode = new ProtoCore.AST.ImperativeAST.BinaryExpressionNode();
ProtoCore.AST.ImperativeAST.ImperativeNode lhsNode = null;
NodeUtils.SetNodeLocation(bNode, la);
Imperative_decoratedIdentifier(out lhsNode);
node = lhsNode;
if (la.kind == 23) {
Get();
bNode.LeftNode = lhsNode;
bNode.RightNode = null;
bNode.Optr = Operator.assign;
NodeUtils.SetNodeEndLocation(bNode, t);
node = bNode;
} else if (la.kind == 51) {
Get();
ProtoCore.AST.ImperativeAST.ImperativeNode rhsNode = null;
if (HasMoreAssignmentStatements()) {
Imperative_assignstmt(out rhsNode);
} else if (StartOf(4)) {
Imperative_expr(out rhsNode);
if (la.kind != _endline)
SynErr(Resources.SemiColonExpected);
Expect(23);
} else if (la.kind == 10) {
Imperative_languageblock(out rhsNode);
} else SynErr(111);
bNode.LeftNode = lhsNode;
bNode.RightNode = rhsNode;
bNode.Optr = Operator.assign;
NodeUtils.SetNodeEndLocation(bNode, t);
node = bNode;
} else if (StartOf(13)) {
SynErr("';' is expected");
} else SynErr(112);
}
示例12: TestcodegenDS_Imperative_Assign01
public void TestcodegenDS_Imperative_Assign01()
{
//
// a = [Imperative]
// {
// return = 10;
// }
//
List<ProtoCore.AST.ImperativeAST.ImperativeNode> imperativeList = new List<ProtoCore.AST.ImperativeAST.ImperativeNode>();
// return = 10
ProtoCore.AST.ImperativeAST.BinaryExpressionNode imperativeAssign = new ProtoCore.AST.ImperativeAST.BinaryExpressionNode(
new ProtoCore.AST.ImperativeAST.IdentifierNode("return"),
new ProtoCore.AST.ImperativeAST.IntNode(10),
ProtoCore.DSASM.Operator.assign);
imperativeList.Add(imperativeAssign);
// Build the language block
ProtoCore.AST.ImperativeAST.CodeBlockNode imperativeCodeBlock = new ProtoCore.AST.ImperativeAST.CodeBlockNode();
imperativeCodeBlock.Body = imperativeList;
ProtoCore.AST.AssociativeAST.LanguageBlockNode langblock = new ProtoCore.AST.AssociativeAST.LanguageBlockNode();
langblock.codeblock = new ProtoCore.LanguageCodeBlock(ProtoCore.Language.Imperative);
langblock.CodeBlockNode = imperativeCodeBlock;
// Build an assignment where the rhs is the imperative block
ProtoCore.AST.AssociativeAST.BinaryExpressionNode assign = new ProtoCore.AST.AssociativeAST.BinaryExpressionNode(
new ProtoCore.AST.AssociativeAST.IdentifierNode("a"),
langblock,
ProtoCore.DSASM.Operator.assign);
List<ProtoCore.AST.AssociativeAST.AssociativeNode> astList = new List<ProtoCore.AST.AssociativeAST.AssociativeNode>();
astList.Add(assign);
// Generate the script
ProtoCore.CodeGenDS codegen = new ProtoCore.CodeGenDS(astList);
string code = codegen.GenerateCode();
ExecutionMirror mirror = thisTest.RunScriptSource(code);
thisTest.Verify("a", 10);
}