Beispiel #1
0
        public override Variable Construct(ArgumentInfo arguments)
        {
            if (ConstructorScopes is null)
            {
                ConstructorScopes = InnerScope.CreateChildren(3);
            }
            if (ConstructorOverloads is null)
            {
                ConstructorOverloads = new ParameterInfo[] {
                    new ParameterInfo(),
                    new ParameterInfo((true, VarString.StaticTypeName, "type", ConstructorScopes[0])),
                    new ParameterInfo((true, VarString.StaticTypeName, "type", ConstructorScopes[1]), (true, VarString.StaticTypeName, "name", ConstructorScopes[1])),
                }
            }
            ;
            (ParameterInfo match, int index) = ParameterInfo.HighestMatch(ConstructorOverloads, arguments);
            match.Grab(arguments);

            string name, type;

            switch (index)
            {
            case 1:
                name = GetNextID();
                type = "dummy";
                goto Construct;

            case 2:
                name = GetNextID();
                type = (match["type"].Value as VarString).GetConstant();
                goto Construct;

            case 3:
                name = (match["name"].Value as VarString).GetConstant();
                type = (match["type"].Value as VarString).GetConstant();
                goto Construct;

Construct:
                var value = new VarObjective(Access.Private, Usage.Default, GetNextHiddenID(), Compiler.CurrentScope)
                {
                    Type = type, ID = name
                };
                if (ObjectiveIDs.ContainsKey(value.ID))
                {
                    throw new Compiler.InternalError($"Duplicate {StaticTypeName} ID created.", arguments.ScriptTrace);
                }
                else
                {
                    ObjectiveIDs.Add(value.ID, this);
                }
                value.Constructed = true;
                return(value);

            default: throw new MissingOverloadException("Objective constructor", index, arguments);
            }
Beispiel #2
0
 public VarObject() : base()
 {
     objectId = null;
 }