/// <summary> /// Creates a Flame IR method from an appropriately-encoded /// LNode. /// </summary> /// <param name="node">The node to decode.</param> /// <param name="decoder">The decoder to use.</param> private IrMethod(LNode node, DecoderState decoder) : base(node, decoder) { this.isStaticCache = new Lazy <bool>(() => decoder.DecodeBoolean(node.Args[1])); var methodDecoder = decoder.WithScope(new TypeParent(this)); this.genericParameterCache = new Lazy <IReadOnlyList <IGenericParameter> >(() => node.Args[2].Args.EagerSelect(methodDecoder.DecodeGenericParameterDefinition)); this.returnParameterCache = new Lazy <Parameter>(() => methodDecoder.DecodeParameter(node.Args[3])); this.parameterCache = new Lazy <IReadOnlyList <Parameter> >(() => node.Args[4].Args.EagerSelect(methodDecoder.DecodeParameter)); this.baseMethodCache = new Lazy <IReadOnlyList <IMethod> >(() => node.Args[5].Args.EagerSelect(methodDecoder.DecodeMethod)); this.methodBodyCache = new Lazy <MethodBody>(() => node.ArgCount > 6 ? new MethodBody( ReturnParameter, Parameter.CreateThisParameter(this.ParentType), Parameters, methodDecoder.DecodeFlowGraph(node.Args[6])) : null); }
/// <summary> /// Creates a type that is the decoded version of a node. /// </summary> /// <param name="node">The node to decode.</param> /// <param name="decoder">The decoder to use.</param> internal IrType(LNode node, DecoderState decoder) : base(node, decoder) { var typeParamDecoder = decoder.WithScope(new TypeParent(this)); this.genericParameterCache = new Lazy <IReadOnlyList <IGenericParameter> >(() => node.Args[1].Args.EagerSelect(typeParamDecoder.DecodeGenericParameterDefinition)); this.baseTypeCache = new Lazy <IReadOnlyList <IType> >(() => node.Args[2].Args.EagerSelect(decoder.DecodeType)); this.initializer = DeferredInitializer.Create(DecodeMembers); }