Ejemplo n.º 1
0
            public static Variable BuildVariable(XElement data)
            {
                string   name        = data.Attribute("Name")?.ToString();
                VarTypes type        = Variable.TypeFromGuid[new Guid(data.Attribute("Type").Value)];
                string   description = data.Attribute("Descr")?.Value;
                XElement def         = data.Element("DefValue");

                switch (type)
                {
                case VarTypes.String:
                    return(new String(name, type, description, def));

                // break;

                case VarTypes.Integer:
                    return(new Integer(name, type, description, def));

                // break;

                case VarTypes.Array:
                    return(new Variable(name, type, description));

                // break;

                case VarTypes.Table:
                    return(new Table(name, type, description, def));

                // break;

                default:
                    return(null);
                    // break;
                }
            }
Ejemplo n.º 2
0
            public Table(string name, VarTypes type, string description, XElement def) : base(name, type, description)
            {
                m_rowNames    = new List <string>();
                m_columnNames = new List <string>();

                Rows    = int.Parse(def.Attribute("RowCount").Value);
                Columns = int.Parse(def.Attribute("ColumnCount").Value);
                var cols = def.Element("Columns");

                for (int i = 0; i < Columns; i++)
                {
                    m_columnNames.Add(cols.Attribute("ColumnName" + i).Value);
                }

                m_data = new string[Rows, Columns];
                var r = 0;

                foreach (var row in def.Elements("Row"))
                {
                    var thisRow = new Row(Columns, row);
                    var c       = 0;
                    foreach (var col in thisRow.Data)
                    {
                        m_data[r, c++] = DecodeUnicodeString(col);
                    }

                    r++;
                }
            }
Ejemplo n.º 3
0
 public void Set(Variable var1, VarTypes varTpe, Variable var2, VarTypes var2Type)
 {
     Var1     = var1;
     Var1Type = varTpe;
     Var2     = var2;
     Var2Type = var2Type;
 }
Ejemplo n.º 4
0
        public static void AddArg(this Function func, VarTypes type)
        {
            Variable var = new Variable();

            var.VarType = type;
            func.Arguments.Add(var);
        }
Ejemplo n.º 5
0
 public ArrayVariableNode(string name, VarTypes type, int start, int end) : base(name, type)
 {
     variableName = name;
     this.type    = type;
     startIndex   = start;
     endIndex     = end;
 }
Ejemplo n.º 6
0
        public VarArray(AstArrayTypeName type, VarLocation location) : base(type)
        {
            // Obtain our array size
            ArraySize = VarTypes.ParseArrayTypeComponents(BaseType).arraySize;

            // Set our type name
            ArrayTypeName = type;

            // Set our element parser with the given array element/base type.
            ElementObject = VarTypes.GetVariableObject(ArrayTypeName.BaseType, location);

            // Define our bounds variables
            int storageSlotCount = 1;

            if (ArraySize.HasValue)
            {
                // If an element doesn't fit in a single slot, we keep the storage format as is, and slot count = element count * element slot count.
                // If an element fits in a single slot, we try to compact multiple into a single slot.
                if (ElementObject.SizeBytes >= UInt256.SIZE)
                {
                    storageSlotCount = ArraySize.Value * ElementObject.StorageEntryCount;
                }
                else
                {
                    // Determine how many elements we can fit in a slot.
                    int elementsPerSlot = UInt256.SIZE / ElementObject.SizeBytes;

                    // Figure out how many slots we'll actually need to store the element count.
                    storageSlotCount = (int)Math.Ceiling(ArraySize.Value / (double)elementsPerSlot);
                }
            }

            // Initialize our bounds.
            InitializeBounds(storageSlotCount, UInt256.SIZE, location);
        }
Ejemplo n.º 7
0
 public void Set(Ray var1, VarTypes varTpe, Ray var2, VarTypes var2Type)
 {
     Var1     = var1;
     Var1Type = varTpe;
     Var2     = var2;
     Var2Type = var2Type;
 }
Ejemplo n.º 8
0
            public SetVariable(XElement data, XElement children) : base("Set Variable Value", OperTypes.SetVariable, data, children)
            {
                VariableName = data.Attribute("VariableName")?.Value;
                var typenumber = int.Parse(data.Attribute("VariableType").Value);

                VariableType = Variable.TypeFromNumber[typenumber];
            }
        //=========== HELPERS ============
        #region Helpers

        /**<summary>Parses a variable based on its type.</summary>*/
        private object ParseVariable(VarTypes type, string text)
        {
            try {
                switch (type)
                {
                case VarTypes.Bool:             return(bool.Parse(text));

                case VarTypes.Byte:             return(byte.Parse(text));

                case VarTypes.Short:    return(short.Parse(text));

                case VarTypes.Int:              return(int.Parse(text));

                case VarTypes.Float:    return(float.Parse(text));

                case VarTypes.String:   return(text);

                case VarTypes.Color:    return(ParseColor(text));

                case VarTypes.UseSound: return(ParseUseSound(text));
                }
                return(null);
            }
            catch (Exception ex) {
                return(ex);
            }
        }
Ejemplo n.º 10
0
        public VarFixedBytes(AstElementaryTypeName type) : base(type)
        {
            // Determine the size of our fixed array.
            int sizeBytes = VarTypes.GetFixedArraySizeInBytes(BaseType);

            // Initialize our bounds
            InitializeBounds(1, sizeBytes);
        }
Ejemplo n.º 11
0
        public VarInt(AstElementaryTypeName type) : base(type)
        {
            // Obtain our size in bytes
            int sizeBytes = VarTypes.GetIntegerSizeInBytes(BaseType, GenericType);

            // Initialize our bounds
            InitializeBounds(1, sizeBytes);
        }
Ejemplo n.º 12
0
        public void OnEventAddAgain(string name, Domains domain, VarTypes varType, string question)
        {
            var handler = EventAddAgain;

            if (handler != null)
            {
                handler(name, domain, varType, question);
            }
        }
Ejemplo n.º 13
0
        public VarBase(AstElementaryTypeName type)
        {
            // Set our type
            Type = type;

            // Obtain the components of our type and set them.
            BaseType = VarTypes.ParseTypeComponents(type.TypeDescriptions.TypeString).baseType;

            // Obtain our generic type.
            GenericType = VarTypes.GetGenericType(BaseType);
        }
Ejemplo n.º 14
0
 public Integer(string name, VarTypes type, string description, XElement def) : base(name, type, description)
 {
     if (int.TryParse(def.Elements().FirstOrDefault()?.ToString(), out var temp))
     {
         Default = temp;
     }
     else
     {
         Default = null;
     }
 }
 /**<summary>Constructs the base variable.</summary>*/
 public VarInfo(VarTypes type, string internalName, VarSetters setter = VarSetters.Normal)
 {
     this.Type = type;
     if (internalName != "")
     {
         this.Field = typeof(Item).GetField(internalName);
     }
     else
     {
         this.Field = null;
     }
     this.Setter = setter;
 }
Ejemplo n.º 16
0
        public bool isPercentageScan; //next scan

        public ScanParameters()
        {
            //default config
            ScanOption         = ScanOptions.soExactValue;
            VarType            = VarTypes.vtDword;
            RoundingType       = RoundingTypes.rtExtremerounded;
            StartAddress       = 0;
            StopAddress        = (UInt64)(Int64.MaxValue);
            ProtectionFlags    = "+W-C"; //wirable, not copy-on-write, and ignore execute
            AlignmentType      = FastScanMethods.fsmAligned;
            AlignmentValue     = "4";
            isHexadecimalInput = false;
            isUTF16Scan        = false;
            isCaseSensitive    = false;
            isPercentageScan   = false;
        }
Ejemplo n.º 17
0
        protected Color getColor(VarTypes t)
        {
            switch (t)
            {
            case VarTypes.Int:
                return(intColor);

            case VarTypes.Float:
                return(floatColor);

            case VarTypes.Bool:
                return(boolColor);

            case VarTypes.Object:
                return(objectColor);

            case VarTypes.MatineeData:
                return(interpDataColor);

            default:
                return(Color.Black);
            }
        }
Ejemplo n.º 18
0
        private void FOnEventAddAgain(string name, Domains domains, VarTypes varTypes, string question)
        {
            //2. Если ОК, то выполняется проверка на совпадение
            var same = _esCopy.Variables.Where(x => x.Name.ToLower() == name.ToLower()).Select(x => x);

            if (same.Any())
            {
                MessageBox.Show("Переменная с таким именем уже существует.");
                return;
            }
            //3. Если Не совпадает, то новая переменная добавляется  в копию БД
            var variable = new Variables {
                Name = name, Domains = domains, VarTypes = varTypes, Question = question
            };

            _esCopy.Variables.InsertOnSubmit(variable);
            _esCopy.SubmitChanges();
            FillListViewVariables();
            if (!_somethingChanged)
            {
                Text += "*";
            }
            _somethingChanged = true;
        }
Ejemplo n.º 19
0
        public dynamic GetParameterType(string paramName, ReturnType returnType)
        {
            VarTypes ret = GetVarType(paramName);

            if (returnType == ReturnType.AsEnum)
            {
                return(ret);
            }

            if (ret == VarTypes.TypeArray)
            {
                return("Array");
            }

            if (ret == VarTypes.TypeFloat)
            {
                return("Float");
            }

            if (ret == VarTypes.TypeInteger)
            {
                return("Integer");
            }

            if (ret == VarTypes.TypeOther)
            {
                return("Other");
            }

            if (ret == VarTypes.TypeTagged)
            {
                return("Tagged");
            }

            return(null);
        }
Ejemplo n.º 20
0
        public DeclarationsNode Declarations()
        {
            var declarations = new DeclarationsNode();

            while (token.value == "var")
            {
                Match(TokenTypes.ID, "var");
                VarTypes type     = VarTypes.NONE;
                var      tempList = new List <string>();//holds the names of declared variables
                Match(TokenTypes.ID);
                tempList.Add(returnToken.value);
                while (token.value == ",")
                {
                    Match(TokenTypes.COMMA);
                    Match(TokenTypes.ID);
                    tempList.Add(returnToken.value);
                }
                Match(TokenTypes.COLON);

                if (token.value == "array")//if its an array
                {
                    Match(TokenTypes.ID, "array");
                    Match(TokenTypes.LBRACKET);
                    Match(TokenTypes.NUM);
                    int startIndex = int.Parse(returnToken.value);
                    Match(TokenTypes.COLON);
                    Match(TokenTypes.NUM);
                    int endIndex = int.Parse(returnToken.value);
                    Match(TokenTypes.RBRACKET);
                    Match(TokenTypes.ID, "of");

                    if (token.value == "integer")
                    {
                        type = VarTypes.INT;
                    }
                    else if (token.value == "real")
                    {
                        type = VarTypes.REAL;
                    }
                    Match(TokenTypes.ID);
                    foreach (var name in tempList)
                    {
                        var var = new ArrayVariableNode(name, type, startIndex, endIndex);
                        declarations.variableList.Add(var);
                    }
                }
                else//if its not an array
                {
                    if (token.value == "integer")
                    {
                        type = VarTypes.INT;
                    }
                    else if (token.value == "real")
                    {
                        type = VarTypes.REAL;
                    }
                    Match(TokenTypes.ID);
                    foreach (var name in tempList)
                    {
                        var vari = new VariableNode(name, type);
                        declarations.variableList.Add(vari);
                    }
                }
                Match(TokenTypes.SEMICOLON);
            }
            return(declarations);
        }
Ejemplo n.º 21
0
 public static void AddArg(this Function func, VarTypes type)
 {
     Variable var = new Variable();
     var.VarType = type;
     func.Arguments.Add(var);
 }
Ejemplo n.º 22
0
 public Variable(string name, VarTypes type, string description)
 {
     Name        = name;
     Type        = type;
     Description = description;
 }
Ejemplo n.º 23
0
        public static string GetTypeName(this VarTypes type, Assembly asm, int StructID, int dimension)
        {
            string name = "";

            try
            {
                switch (type)
                {
                case VarTypes.StrucRef:
                    name = "ref " + asm.Structures[StructID].Name;
                    break;

                case VarTypes.Struct:
                    name = asm.Structures[StructID].Name;
                    break;

                case VarTypes.ArrayStruct:
                    name = asm.Structures[StructID].Name + dimension.GetDimension();
                    break;

                case VarTypes.IntRef:
                    name = "ref int";
                    break;

                case VarTypes.FloatRef:
                    name = "ref float";
                    break;

                case VarTypes.StringRef:
                    name = "ref string";
                    break;

                case VarTypes.ArrayIntRef:
                    name = "ref int" + dimension.GetDimension();
                    break;

                case VarTypes.ArrayFloatRef:
                    name = "ref float" + dimension.GetDimension();
                    break;

                case VarTypes.ArrayStringRef:
                    name = "ref string" + dimension.GetDimension();
                    break;

                case VarTypes.ArrayStructRef:
                    name = "ref " + asm.Structures[StructID].Name + dimension.GetDimension();
                    break;

                case VarTypes.ArrayInt:
                    name = "int" + dimension.GetDimension();
                    break;

                case VarTypes.ArrayFloat:
                    name = "float" + dimension.GetDimension();
                    break;

                case VarTypes.ArrayString:
                    name = "string" + dimension.GetDimension();
                    break;

                case VarTypes.ArrayBool:
                    name = "bool" + dimension.GetDimension();
                    break;

                case VarTypes.ArrayDelegate:
                    name = "delegate" + dimension.GetDimension();
                    break;

                default:
                    name = type.ToString().ToLower();
                    break;
                }
            }
            catch
            {
                name = type.ToString().ToLower();
            }
            return(name);
        }
Ejemplo n.º 24
0
        public SubProgramNode SubProgram()
        {
            SubProgramNode subProgramNode = new SubProgramNode();

            Match(TokenTypes.ID);
            subProgramNode.id = returnToken.value;
            if (token.value == "(")
            {
                bool end;
                Match(TokenTypes.LPAR);
                do
                {
                    VarTypes type     = VarTypes.NONE;
                    var      tempList = new List <string>();//holds the names of declared variables
                    Match(TokenTypes.ID);
                    tempList.Add(returnToken.value);
                    while (token.value == ",")
                    {
                        Match(TokenTypes.COMMA);
                        Match(TokenTypes.ID);
                        tempList.Add(returnToken.value);
                    }
                    Match(TokenTypes.COLON);
                    if (token.value == "array")//if its an array
                    {
                        Match(TokenTypes.ID, "array");
                        Match(TokenTypes.LBRACKET);
                        Match(TokenTypes.NUM);
                        int startIndex = int.Parse(returnToken.value);
                        Match(TokenTypes.COLON);
                        Match(TokenTypes.NUM);
                        int endIndex = int.Parse(returnToken.value);
                        Match(TokenTypes.RBRACKET);
                        Match(TokenTypes.ID, "of");

                        if (token.value == "integer")
                        {
                            type = VarTypes.INT;
                        }
                        else if (token.value == "real")
                        {
                            type = VarTypes.REAL;
                        }
                        Match(TokenTypes.ID);
                        foreach (var name in tempList)
                        {
                            var var = new ArrayVariableNode(name, type, startIndex, endIndex);
                            subProgramNode.argumentList.Add(var);
                        }
                    }
                    else//if its not an array
                    {
                        if (token.value == "integer")
                        {
                            type = VarTypes.INT;
                        }
                        else if (token.value == "real")
                        {
                            type = VarTypes.REAL;
                        }
                        Match(TokenTypes.ID);
                        foreach (var name in tempList)
                        {
                            var vari = new VariableNode(name, type);
                            subProgramNode.argumentList.Add(vari);
                        }
                    }
                    end = token.value == ")";
                    if (!end)
                    {
                        Match(TokenTypes.SEMICOLON);
                    }
                } while (!end);
                Match(TokenTypes.RPAR);
                if (token.value == ":")
                {
                    Match(TokenTypes.COLON);
                    Match(TokenTypes.ID);
                    subProgramNode.type = returnToken.value;
                }
                Match(TokenTypes.SEMICOLON);
            }
            subProgramNode.declarations = Declarations();
            SubProgramDeclarations(subProgramNode.methodList);
            CompoundStatement(subProgramNode.statementList);
            return(subProgramNode);
        }
Ejemplo n.º 25
0
 public VariableNode(string name, VarTypes type)
 {
     variableName = name;
     this.type    = type;
 }
Ejemplo n.º 26
0
 protected Color getColor(VarTypes t)
 {
     switch (t)
     {
         case VarTypes.Int:
             return Color.FromArgb(34, 218, 218);//cyan
         case VarTypes.Float:
             return Color.FromArgb(23, 23, 213);//blue
         case VarTypes.Bool:
             return Color.FromArgb(215, 37, 33); //red
         case VarTypes.Object:
             return Color.FromArgb(219, 39, 217);//purple
         case VarTypes.MatineeData:
             return Color.FromArgb(222, 123, 26);//orange
         default:
             return Color.Black;
     }
 }
Ejemplo n.º 27
0
 public static Loop Random(Random random) =>
 new Loop(VarTypes.Random(random), OpTypes.Random(random), VarTypes.Random(random));
Ejemplo n.º 28
0
        //=========== HELPERS ============
        #region Helpers

        /**<summary>Registers a variable.</summary>*/
        private static void AddVar(VarTypes type, string internalName, string externalName, VarSetters setter = VarSetters.Normal)
        {
            VarInfoList.Add(externalName, new VarInfo(type, internalName, setter));
        }
Ejemplo n.º 29
0
 public String(string name, VarTypes type, string description, XElement def) : base(name, type, description)
 {
     Default = def.Elements().FirstOrDefault()?.Value;
 }
Ejemplo n.º 30
0
        protected void prepareErrorDescription()
        {
            switch (ErrorType)
            {
            case "ZeroDivisionError":
                PositionInLine = Value.LastIndexOf("/");
                break;

            case "TypeError":
            {
                Match noArgsMatch = functionWithoutArgsRegex.Match(Description);
                if (noArgsMatch.Success)
                {
                    string functionName = noArgsMatch.Groups[1].Value;
                    int    argsRequired = int.Parse(noArgsMatch.Groups[2].Value);
                    Description = $"<{functionName}> FUNCTION too less args (required {argsRequired} more)";
                    break;
                }
                Match functionErrorMatch = functionArguementsRegex.Match(Description);
                if (functionErrorMatch.Success)
                {
                    int argsRequired = int.Parse(functionErrorMatch.Groups[2].Value);
                    int argsGiven    = int.Parse(functionErrorMatch.Groups[3].Value);

                    Description = $"<{functionErrorMatch.Groups[1].Value}> FUNCTION too many args (takes {argsRequired} args only)";
                    break;
                }
                Match binaryOperationErrorMatch = binaryOperationArgumentsRegex.Match(Description);
                if (binaryOperationErrorMatch.Success)
                {
                    string operation = binaryOperationErrorMatch.Groups[1].Value;
                    string type1     = binaryOperationErrorMatch.Groups[2].Value;
                    string type2     = binaryOperationErrorMatch.Groups[3].Value;
                    PositionInLine = Value.LastIndexOf(operation);
                    operation      = Token.GetTokenType(operation).ToString();
                    VarTypes varType = VarTypes.NONE_VAR;
                    if (StringVarTypes.TryGetValue(type1, out varType))
                    {
                        type1 = varType.ToString();
                    }
                    if (StringVarTypes.TryGetValue(type2, out varType))
                    {
                        type2 = varType.ToString();
                    }
                    Description = $"operation << {type1} {operation} {type2} >> is impossible";
                    break;
                }
                break;
            }

            case "NameError":
            {
                Match nameErrorMatch = nameErrorRegex.Match(Description);
                if (nameErrorMatch.Success)
                {
                    string name = nameErrorMatch.Groups[1].Value;
                    Description    = $"<<{name}>> UNKNOWN_VAR";
                    PositionInLine = Value.IndexOf(name);
                }
                break;
            }

            default:
                break;
            }
        }
Ejemplo n.º 31
0
 protected Color getColor(VarTypes t)
 {
     switch (t)
     {
         case VarTypes.Int:
             return intColor;
         case VarTypes.Float:
             return floatColor;
         case VarTypes.Bool:
             return boolColor;
         case VarTypes.Object:
             return objectColor;
         case VarTypes.MatineeData:
             return interpDataColor;
         default:
             return Color.Black;
     }
 }