/// <summary> /// builds the XPT node of this /// </summary> /// <param name="ctx"></param> /// <returns></returns> public bool BuildXPTNode(SelectionRulezContext ctx) { // $ctx.XPTreeNode = (eXPressionTree.IeXPressionTree) new SelectionRule($ctx.ruleid().GetText(), engine: this.Engine); // get the name SelectionRule aRule = new SelectionRule(ctx.ruleid().GetText(), engine: this.Engine); ctx.XPTreeNode = aRule; // add expression if (ctx.selection() != null) { aRule.Selection = new SelectionStatementBlock(engine: this.Engine); aRule.Selection.Add(new @Return((SelectionExpression)ctx.selection().XPTreeNode)); } else if (ctx.selectStatementBlock() != null) { aRule.Selection = (SelectionStatementBlock)ctx.selectStatementBlock().XPTreeNode; } // add the parameters foreach (ParameterDefinition aParameter in ctx.names.Values) { ISymbol symbol = aRule.AddNewParameter(aParameter.name, datatype: aParameter.datatype); // defaultvalue assignment if (aParameter.defaultvalue != null) { aRule.Selection.Nodes.Insert(0, new eXPressionTree.IfThenElse( eXPressionTree.CompareExpression.EQ(symbol, new Literal(null, otDataType.@Null)), new eXPressionTree.Assignment(symbol, (IExpression)aParameter.defaultvalue))); } } return(true); }
/// <summary> /// builds the XPT node of this /// </summary> /// <param name="ctx"></param> /// <returns></returns> public bool BuildXPTNode(SelectionRulezContext ctx) { // $ctx.XPTreeNode = (eXPressionTree.IeXPressionTree) new SelectionRule($ctx.ruleid().GetText(), engine: this.Engine); // get the name SelectionRule aRule = new SelectionRule(ctx.ruleid().GetText(), engine: this.Engine); ctx.XPTreeNode = aRule; // add expression if (ctx.selection() != null) { aRule.Selection = new SelectionStatementBlock(engine: this.Engine); aRule.Selection.Add(new @Return((SelectionExpression)ctx.selection().XPTreeNode)); } else if (ctx.selectStatementBlock() != null) aRule.Selection = (SelectionStatementBlock)ctx.selectStatementBlock().XPTreeNode; // add the parameters foreach (ParameterDefinition aParameter in ctx.names.Values) { ISymbol symbol = aRule.AddNewParameter(aParameter.name, datatype: aParameter.datatype); // defaultvalue assignment if (aParameter.defaultvalue != null) aRule.Selection.Nodes.Insert(0, new eXPressionTree.IfThenElse( eXPressionTree.CompareExpression.EQ(symbol, new Literal(null, otDataType.@Null)), new eXPressionTree.Assignment(symbol, (IExpression)aParameter.defaultvalue))); } return true; }