public void SetSelfParameter(AstTypeDefinitionIntrinsic type)
        {
            Ast.Guard(!FunctionType.Parameters.Any(), "A Self parameter has to be first.");
            var parameter = new AstFunctionParameterDefinition(AstIdentifierIntrinsic.Self);

            parameter.SetTypeReference(AstTypeReferenceType.From(type));
            FunctionType.AddParameter(parameter);
        }
Exemple #2
0
        public override void VisitFunctionParameterDefinition(AstFunctionParameterDefinition parameter)
        {
            var paramDef = parameter.Context switch
            {
                Function_parameterContext ctx => new AstFunctionParameterDefinition(ctx, parameter.IsSelf),
                Function_parameter_selfContext ctx => new AstFunctionParameterDefinition(ctx, parameter.IsSelf),
                _ => new AstFunctionParameterDefinition(parameter.Identifier)
            };

            paramDef.TrySetIdentifier(parameter.Identifier);

            var fnDef = _current.GetCurrent <AstFunctionDefinition>();

            fnDef.FunctionType.AddParameter(paramDef);

            _current.SetCurrent(paramDef);
            parameter.VisitChildren(this);
            _current.RevertCurrent();

            // parameter symbols are registered with FunctionDefinition.CreateSymbols()
        }