Example #1
0
        //Pop index operator operand
        public override void ExitIndexOp([NotNull] CmanParser.IndexOpContext context)
        {
            ASTIndexOpNode indexOp = (ASTIndexOpNode)_nodes.ElementAt(2);

            indexOp.Index      = (IASTExprNode)_nodes.Pop();
            indexOp.Expression = (IASTExprNode)_nodes.Pop();
        }
Example #2
0
 private void CheckIndexOp(ASTIndexOpNode indexOpNode)
 {
     if (!(indexOpNode.Expression is ASTIndexOpNode) &&
         !(indexOpNode.Expression is ASTVariableNode) &&
         !(indexOpNode.Expression is ASTCallStatementNode)
         )
     {
         _messages.Add(new MessageRecord(
                           MsgCode.RvalueIndexing,
                           indexOpNode.SourcePath,
                           indexOpNode.StartLine,
                           indexOpNode.StartPos,
                           null
                           ));
     }
     else
     {
         if (indexOpNode.Expression is ASTIndexOpNode indexOp)
         {
             CheckIndexOp(indexOp);
         }
         if (indexOpNode.Expression is ASTVariableNode varNode)
         {
             CheckVariable(varNode);
         }
         if (indexOpNode.Expression is ASTCallStatementNode callNode)
         {
             CheckSubCall(callNode, true);
         }
     }
     //TODO: null index check
     CheckExpression(indexOpNode.Index);
 }
Example #3
0
 //TODO: пересмотреть
 private void BuildIndexOp(ASTIndexOpNode indexOp)
 {
     if (indexOp.Expression is ASTIndexOpNode subIndexOp)
     {
         //get sub object
         BuildIndexOp(subIndexOp);
         //get index
         BuildExpression(subIndexOp.Index);
         _emitter.Box();
         //get item
         _emitter.VirtualCall(typeof(Dictionary <object, object>), "get_Item", new Type[] { typeof(object) });
     }
     if (indexOp.Expression is ASTVariableNode varNode)
     {
         //get root object
         BuildVariable(varNode);
     }
 }