Пример #1
0
        public VarEntity(Access access, Usage usage, string name, Compiler.Scope scope) : base(access, usage, name, scope)
        {
            AddAutoProperty(Selector = new VarSelector(Access.Public, Usage.Default, NamingStyleConverter.FromSingleToCamel(VarSelector.StaticTypeName), InnerScope));

            Compiler.Scope[] scopesMergeData = new Compiler.Scope[1];
            for (int i = 0; i < scopesMergeData.Length; i++)
            {
                scopesMergeData[i] = new Compiler.Scope(InnerScope);
            }
            ParameterInfo[] infoMergeData = new ParameterInfo[] {
                new ParameterInfo(
                    (true, VarString.StaticTypeName, "name", scopesMergeData[0]),
                    (true, VarString.StaticTypeName, "data", scopesMergeData[0])
                    )
            };
            Methods.Add("MergeData", (arguments) => {
                (ParameterInfo match, int index) = ParameterInfo.HighestMatch(infoMergeData, arguments);
                match.Grab(arguments);

                switch (index)
                {
                case 0:
                    VarString name = match[0].Value as VarString;
                    VarString data = match[1].Value as VarString;
                    new Spy(null, $"data merge entity {Selector.GetConstant()} {{{name.GetConstant()}:{data.GetConstant()}}}", null);
                    return(null);

                default: throw new MissingOverloadException("MergeData", index, arguments);
                }
            });
        }
Пример #2
0
 public override Variable InvokeOperation(Operation operation, Variable operand, ScriptTrace trace)
 {
     switch (operation)
     {
     case Operation.Set: {
         if (operand is VarEntity entity || operand.TryCast(TypeName, out entity))
         {
             Selector    = entity.Selector;
             Constructed = true;
             return(this);
         }