Inheritance: TypedValue
コード例 #1
0
ファイル: Call.cs プロジェクト: Norbyte/lslib
        public void Read(OsiReader reader)
        {
            Name = reader.ReadString();
            if (Name.Length > 0)
            {
                var hasParams = reader.ReadByte();
                if (hasParams > 0)
                {
                    Parameters = new List<TypedValue>();
                    var numParams = reader.ReadByte();
                    while (numParams-- > 0)
                    {
                        TypedValue param;
                        var type = reader.ReadByte();
                        if (type == 1)
                            param = new Variable();
                        else
                            param = new TypedValue();
                        param.Read(reader);
                        Parameters.Add(param);
                    }
                }

                Negate = reader.ReadBoolean();
            }

            GoalIdOrDebugHook = reader.ReadInt32();
        }
コード例 #2
0
ファイル: Rule.cs プロジェクト: Norbyte/lslib
        public override void Read(OsiReader reader)
        {
            base.Read(reader);
            Calls = reader.ReadList<Call>();

            Variables = new List<Variable>();
            var variables = reader.ReadByte();
            while (variables-- > 0)
            {
                var type = reader.ReadByte();
                if (type != 1) throw new InvalidDataException("Illegal value type in rule variable list");
                var variable = new Variable();
                variable.Read(reader);
                if (variable.Adapted)
                {
                    variable.VariableName = String.Format("_Var{0}", Variables.Count + 1);
                }

                Variables.Add(variable);
            }

            Line = reader.ReadUInt32();

            if (reader.MajorVersion > 1 || (reader.MajorVersion == 1 && reader.MinorVersion >= 6))
                IsQuery = reader.ReadBoolean();
            else
                IsQuery = false;
        }
コード例 #3
0
ファイル: Adapter.cs プロジェクト: Norbyte/lslib
        public Tuple Adapt(Tuple columns)
        {
            var result = new Tuple();
            for (var i = 0; i < LogicalIndices.Count; i++)
            {
                var index = LogicalIndices[i];
                // If a logical index is present, emit an attribute from the input tuple
                if (index != -1)
                {
                    var value = columns.Logical[index];
                    result.Physical.Add(value);
                }
                // Otherwise check if a constant is mapped to the specified logical index
                else if (Constants.Logical.ContainsKey(i))
                {
                    var value = Constants.Logical[i];
                    result.Physical.Add(value);
                }
                // If we haven't found a constant, emit a null variable
                else
                {
                    var nullValue = new Variable();
                    nullValue.TypeId = (uint)Value.Type.Unknown;
                    nullValue.Unused = true;
                    result.Physical.Add(nullValue);
                }
            }

            // Generate logical => physical mappings for the output tuple
            foreach (var map in LogicalToPhysicalMap)
            {
                result.Logical.Add(map.Key, result.Physical[map.Value]);
            }

            return result;
        }