private void VisitAssignStatement(ASTAssignStatementNode assignNode) { if (assignNode.Left is ASTVariableNode varNode) { VisitVariable(varNode); } }
/// <summary> /// Builds assignment statement /// </summary> /// <param name="assignNode">Assignment statement node</param> private void BuildAssignStatement(ASTAssignStatementNode assignNode) { //to dictionary assign if (assignNode.Left is ASTIndexOpNode indexNode) { //get object BuildIndexOp(indexNode); //get index BuildExpression(indexNode.Index); _emitter.Box(); //get value BuildExpression(assignNode.Right); _emitter.Box(); //call setter _emitter.VirtualCall(typeof(Dictionary <object, object>), "set_Item", new Type[] { typeof(object), typeof(object) }); } if (assignNode.Left is ASTVariableNode varNode)//to local assign { BuildExpression(assignNode.Right); _emitter.Box(); if (_context.IsLocal(varNode.Name)) { _emitter.StoreLocal(_context.GetLocal(varNode.Name)); } else { _emitter.StoreArg(_context.GetArgID(varNode.Name)); } } }
private void CheckAssignStatement(ASTAssignStatementNode assignNode) { if (IsRvalue(assignNode.Left)) { _messages.Add(new MessageRecord( MsgCode.RvalueAssign, assignNode.SourcePath, assignNode.StartLine, assignNode.StartPos, null )); } else { CheckExpression(assignNode.Left); } CheckExpression(assignNode.Right); }