public override void VisitUnboxAnyInstruction(UnboxAnyInstruction instruction) { ControlState.EvaluationStack.PopValue(out CilValueReference objRef); var obj = ManagedMemory.Load(objRef); var type = instruction.TypeSpec.GetCilType(_program); var value = type.Unbox(obj, ManagedMemory, _program); ControlState.EvaluationStack.PushValue(value); ControlState.MoveToNextInstruction(); }
public override CILInstructionType BuildNode(ParseTreeNode node) { var instrTypeParseTreeNode = node.GetFirstChildWithGrammarName(GrammarNames.INSTR_TYPE); CILInstructionType result = null; var boxParseTreeNode = instrTypeParseTreeNode?.GetFirstChildWithGrammarName(GrammarNames.keyword_box); if (boxParseTreeNode != null) { result = new BoxInstruction(); } var newarrParseTreeNode = instrTypeParseTreeNode?.GetFirstChildWithGrammarName(GrammarNames.keyword_newarr); if (newarrParseTreeNode != null) { result = new NewArrayInstruction(); } var unboxanyParseTreeNode = instrTypeParseTreeNode?.GetFirstChildWithGrammarName(GrammarNames.keyword_unboxany); if (unboxanyParseTreeNode != null) { result = new UnboxAnyInstruction(); } if (result != null) { var typeSpecParseTreeNode = node.GetFirstChildWithGrammarName(GrammarNames.typeSpec); result.TypeSpecification = TypeSpecParseTreeNodeHelper.GetValue(typeSpecParseTreeNode); return(result); } throw new ArgumentException("Cannot recognize CIL instruction type."); }
public abstract void VisitUnboxAnyInstruction(UnboxAnyInstruction instruction);