Exemplo n.º 1
0
 public override void Visit(RppParam node)
 {
     int index = node.Index;
     FieldBuilder capturedParam;
     if (ClosureContext?.CapturedParams != null && ClosureContext.CapturedParams.TryGetValue(index, out capturedParam))
     {
         LoadArg(0);
         _body.Emit(OpCodes.Ldfld, capturedParam);
     }
     else
     {
         LoadArg(index);
     }
 }
Exemplo n.º 2
0
        //param ::= {Annotation} id [‘:’ ParamType] [‘=’ Expr]
        private bool ParseParam(out RppParam funcParam)
        {
            funcParam = null;
            if (!Require(RppLexer.Id))
            {
                return false;
            }
            string name = _lastToken.Text;
            Expect(RppLexer.OP_Colon);
            RTypeName type;
            if (!ParseType(out type))
            {
                RaiseSyntaxError("Type is expected");
            }

            bool variadic = Require(RppLexer.OP_Star);

            var a = new RppParam(name, new ResolvableType(type), variadic);
            funcParam = a;
            return true;
        }
Exemplo n.º 3
0
        private static IEnumerable<RppFunc> CreatePropertyAccessors(RppField field)
        {
            IRppParam valueParam = new RppParam("value", field.Type);

            if (field.MutabilityFlag != MutabilityFlag.MfVal)
            {
                RppFunc setter = new RppFunc(RppMethodInfo.GetSetterAccessorName(field.Name), new[] {valueParam}, ResolvableType.UnitTy,
                    new RppAssignOp(new RppId(field.MangledName), new RppId("value", valueParam)))
                {
                    IsSynthesized = true,
                    IsPropertyAccessor = true,
                    Modifiers = field.Modifiers
                };

                yield return setter;
            }

            RppFunc getter = new RppFunc(RppMethodInfo.GetGetterAccessorName(field.Name), Enumerable.Empty<IRppParam>(), field.Type,
                new RppId(field.MangledName, field))
            {
                IsSynthesized = true,
                IsPropertyAccessor = true,
                Modifiers = field.Modifiers
            };

            yield return getter;
        }
Exemplo n.º 4
0
        private bool ParseBinding(out RppParam binding)
        {
            binding = null;
            if (!Require(RppLexer.Id))
            {
                return false;
            }

            string name = _lastToken.Text;

            ResolvableType type = ResolvableType.UndefinedTy;
            if (Require(RppLexer.OP_Colon))
            {
                RTypeName typeName;
                if (!ParseType(out typeName))
                {
                    RaiseSyntaxError("Type is expected");
                }

                type = new ResolvableType(typeName);
            }

            binding = new RppParam(name, type) {IsClosureBinding = true};
            return true;
        }
Exemplo n.º 5
0
 public virtual void Visit(RppParam node)
 {
 }