Ejemplo n.º 1
0
        public ArgumentInfo(Variable[] arguments, ScriptTrace trace)
        {
            int length = arguments.Length;
            var args   = new Argument[length];

            for (int i = 0; i < length; i++)
            {
                args[i] = (arguments[i].TypeName, arguments[i]);
            }
            Arguments   = args;
            ScriptTrace = trace;
        }
Ejemplo n.º 2
0
 public override Variable Initialize(Access access, Usage usage, string name, Compiler.Scope scope, ScriptTrace trace) => new VarSelector(access, usage, name, scope);
Ejemplo n.º 3
0
 public override Variable InvokeOperation(Operation operation, Variable operand, ScriptTrace trace)
 {
     switch (operation)
     {
     case Operation.Equal: {
         if (operand is VarPrimitive right || operand.TryCast(TypeName, out right))
         {
             VarBool result;
             if (Usage == Usage.Constant)
             {
                 if (right.Usage == Usage.Constant)
                 {
                     result = new VarBool(Access.Private, Usage.Constant, GetNextHiddenID(), Scope);
                     result.SetValue(Constant == right.Constant ? 1 : 0);
                 }
                 else
                 {
                     result = new VarBool(Access.Private, Usage.Default, GetNextHiddenID(), Scope);
                     result.SetValue(0);
                     new Spy(null, $"execute if score " +
                             $"{right.Selector.GetConstant()} {right.Objective.GetConstant()} matches " +
                             $"{Constant} run " +
                             $"scoreboard players set {result.Selector.GetConstant()} {result.Objective.GetConstant()} 1", null);
                 }
             }
             else
             {
                 if (right.Usage == Usage.Constant)
                 {
                     result = new VarBool(Access.Private, Usage.Default, GetNextHiddenID(), Scope);
                     result.SetValue(0);
                     new Spy(null, $"execute if score " +
                             $"{Selector.GetConstant()} {Objective.GetConstant()} matches " +
                             $"{right.Constant} run " +
                             $"scoreboard players set {result.Selector.GetConstant()} {result.Objective.GetConstant()} 1", null);
                 }
                 else
                 {
                     result = new VarBool(Access.Private, Usage.Default, GetNextHiddenID(), Scope);
                     result.SetValue(0);
                     new Spy(null, $"execute if score " +
                             $"{Selector.GetConstant()} {Objective.GetConstant()} = " +
                             $"{right.Selector.GetConstant()} {right.Objective.GetConstant()} run " +
                             $"scoreboard players set {result.Selector.GetConstant()} {result.Objective.GetConstant()} 1", null);
                 }
             }
             return(result);
         }
Ejemplo n.º 4
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);
         }
Ejemplo n.º 5
0
        public override Variable InvokeOperation(Operation operation, Variable operand, ScriptTrace trace)
        {
            switch (operation)
            {
            case Operation.Set: {
#if DEBUG_OUT
                new Spy(null, $"# OP # {this}@{Scope} := {operand}@{operand.Scope}", null);
#endif
                if ((operand is VarStruct varStruct || operand.TryCast(TypeName, out varStruct)) &&
                    varStruct.TypeName == TypeName /* || [TODO:  user-defined casts] */)
                {
                    foreach ((string field, Variable value) in varStruct.Fields)
                    {
                        Fields[field].InvokeOperation(Operation.Set, value, trace);
                    }
                    return(this);
                }
Ejemplo n.º 6
0
 public override Variable Initialize(Access access, Usage usage, string name, Compiler.Scope scope, ScriptTrace trace) => throw new Compiler.SyntaxException("Cannot make an instance of a static class.", trace);
Ejemplo n.º 7
0
 public override Variable Initialize(Access access, Usage usage, string name, Compiler.Scope scope, ScriptTrace trace) => null;
Ejemplo n.º 8
0
 public override Variable Initialize(Access access, Usage usage, string name, Compiler.Scope scope, ScriptTrace trace) => throw new NotImplementedException();
Ejemplo n.º 9
0
 public override Variable InvokeOperation(Operation operation, Variable operand, ScriptTrace trace) => Variable.InvokeOperation(operation, operand, trace);