示例#1
0
 internal override Node Bind(Binder b)
 {
     if (Params != null)
     {
         foreach (var p in Params)
         {
             b.AddLocal(p.LookupName, b.ObjectType);
             p.Bind(b);
         }
     }
     ParamArray = b.AddParam(XSharpSpecialNames.ClipperArgs, Binder.ArrayOf(b.ObjectType));
     b.AddConstant(XSharpSpecialNames.ClipperArgCount, Constant.Create(Params?.Count ?? 0));
     PCount = b.AddLocal(XSharpSpecialNames.ClipperPCount, Compilation.Get(NativeType.Int32));
     if (Body != null)
     {
         b.Bind(ref Body);
         if (Body.Datatype.NativeType != NativeType.Void)
         {
             Expr e = Body.Exprs.Last();
             b.Convert(ref e, b.ObjectType);
             Body.Exprs[Body.Exprs.Count - 1] = e;
         }
     }
     Symbol = b.ObjectType;
     return(null);
 }
示例#2
0
 internal override Node Bind(Binder b)
 {
     b.Entity = this;
     if (Params != null)
     {
         foreach (var p in Params)
         {
             b.AddLocal(p.LookupName, b.ObjectType, true);
             p.Bind(b);
         }
     }
     ParamArray = b.AddParam(XSharpSpecialNames.ClipperArgs, Binder.ArrayOf(b.ObjectType));
     b.AddConstant(XSharpSpecialNames.ClipperArgCount, Constant.Create(Params?.Count ?? 0));
     PCount = b.AddLocal(XSharpSpecialNames.ClipperPCount, Compilation.Get(NativeType.Int32));
     if (Body != null)
     {
         b.BindStmt(ref Body);
     }
     return(null);
 }
 internal override Node Bind(Binder b)
 {
     b.Bind(ref Initializer);
     Initializer.RequireGetAccess();
     if (IsConst && Initializer is LiteralExpr c)
     {
         Symbol = b.AddConstant(Name, (Constant)c.Symbol) ?? throw Error(ErrorCode.LocalSameName, Name);
     }
     else
     {
         Symbol = b.AddLocal(Name, Initializer.Datatype) ?? throw Error(ErrorCode.LocalSameName, Name);
         if (IsConst)
         {
             if (Initializer?.IsConstant != true)
             {
                 throw Error(ErrorCode.ValueNotConst);
             }
             Var.SetConst();
         }
         Initializer = InitExpr.Bound(IdExpr.Bound(Var), Initializer, b.Options.Binding);
     }
     return(null);
 }