Esempio n. 1
0
        public override DHJassValue Divide(DHJassValue value)
        {
            DHJassReal returnValue = new DHJassReal();

            returnValue.value = this.value / value.RealValue;

            return returnValue;
        }
Esempio n. 2
0
        public DHJassFunction(List<string> declaration, List<string> lines)
            : base(declaration[0])
        {
            this.declaration = declaration[0];

            ///////////////////////
            //   parameters
            ///////////////////////

            argsArray = new DHJassValue[declaration.Count - 2];

            for (int i = 0; i < declaration.Count - 2; i++)
            {
                DHJassValue value = DbJassTypeValueKnowledge.CreateKnownValue(declaration[i + 2]);
                if (value != null)
                {
                    args.Add(value.Name, value);
                    argsArray[i] = value;
                }
            }
            ///////////////////////
            //   return value
            ///////////////////////
            //string return_value_declaration = declaration.Groups["returns"].Value;
            returnValue = new DHJassUnusedType();//DbJassTypeValueKnowledge.CreateKnownValue(return_value_declaration);

            //////////////////////////////////////////////
            //   save body lines for compiling on demand
            //////////////////////////////////////////////
            this.lines = lines;
        }
Esempio n. 3
0
        public override DHJassValue Add(DHJassValue value)
        {
            DHJassInt returnValue = new DHJassInt();

            returnValue.Value = this.value + value.IntValue;

            return returnValue;
        }
Esempio n. 4
0
 public virtual DHJassValue Subtract(DHJassValue value)
 {
     return null;
 }
Esempio n. 5
0
        public void SetElementValue(int index, DHJassValue value)
        {
            DHJassValue result;
            if (!array.TryGetValue(index, out result) || result == null
                || (result is DHJassUnusedType && !(value is DHJassUnusedType))
                || (!(result is DHJassUnusedType) && value is DHJassUnusedType))
            {
                result = value.GetNew();
                array[index] = result;
            }

            result.SetValue(value);
        }
Esempio n. 6
0
 public virtual DHJassValue Multiply(DHJassValue value)
 {
     return null;
 }
Esempio n. 7
0
 public virtual DHJassBoolean Or(DHJassValue value)
 {
     return new DHJassBoolean(null, this.BoolValue || value.BoolValue);
 }
Esempio n. 8
0
 public override DHJassValue Add(DHJassValue value)
 {
     return this;
 }
Esempio n. 9
0
 public override DHJassValue Divide(DHJassValue value)
 {
     return this;
 }
Esempio n. 10
0
 public override DHJassValue Add(DHJassValue value)
 {
     return new DHJassString(null, this.value + value.StringValue);
 }
Esempio n. 11
0
 public override void SetValue(DHJassValue value)
 {
     this.value = value.StringValue;
 }
Esempio n. 12
0
        public override DHJassValue Subtract(DHJassValue value)
        {
            DHJassReal returnValue = new DHJassReal();

            returnValue.value = this.value - value.RealValue;

            return returnValue;
        }
Esempio n. 13
0
        public override DHJassBoolean NotEquals(DHJassValue value)
        {
            DHJassBoolean result = new DHJassBoolean();

            object obj = value.Value;
            if (obj is int)
                result.Value = DHJassSyntax.Comparer.Compare(this.Value, (double)(int)obj) != 0;
            else
                result.Value = DHJassSyntax.Comparer.Compare(this.Value, obj) != 0;
            return result;
        }
Esempio n. 14
0
        public override DHJassValue Multiply(DHJassValue value)
        {
            DHJassReal returnValue = new DHJassReal();

            returnValue.value = this.value * value.RealValue;

            return returnValue;
        }
Esempio n. 15
0
 public virtual DHJassBoolean Less(DHJassValue value)
 {
     DHJassBoolean result = new DHJassBoolean();
     try
     {
         result.Value = DHJassSyntax.Comparer.Compare(this.Value, value.Value) < 0;
     }
     catch { result.Value = false; }
     return result;
 }
Esempio n. 16
0
 public override DHJassValue Multiply(DHJassValue value)
 {
     return this;
 }
Esempio n. 17
0
 public virtual DHJassBoolean LessOrEqual(DHJassValue value)
 {
     DHJassBoolean result = new DHJassBoolean();
     result.Value = DHJassSyntax.Comparer.Compare(this.Value, value.Value) <= 0;
     return result;
 }
Esempio n. 18
0
 public override DHJassBoolean NotEquals(DHJassValue value)
 {
     DHJassBoolean result = new DHJassBoolean();
     try
     {
         if (value is DHJassString)
             result.Value = (DHJassSyntax.Comparer.Compare(this.Value, value.Value) != 0);
         else
             result.Value = (DHJassSyntax.Comparer.Compare(this.RealValue, value.RealValue) != 0);
     }
     catch { result.Value = false; }
     return result;
 }
Esempio n. 19
0
 public virtual DHJassBoolean NotEquals(DHJassValue value)
 {
     DHJassBoolean result = new DHJassBoolean();
     result.Value = (DHJassSyntax.Comparer.Compare(this.Value, value.Value) != 0);
     return result;
 }
Esempio n. 20
0
 public override DHJassValue Subtract(DHJassValue value)
 {
     return this;
 }
Esempio n. 21
0
 public virtual void SetValue(DHJassValue value)
 {
     this.Value = value.Value;
 }
Esempio n. 22
0
        // @"\A\s*(constant\s+)?" + typename + @"(\s+(?<name>\b(?!array)\w+)\s*(=\s*(?<value>.+))?|\z)";
        // @"\A\s*(?<element_type>\w+)\s+array\s+(?<name>\w+)(=(?<value>\w+))?"
        public static bool TryParseDeclaration(string code, out DHJassValue value, out List<string> args)
        {
            if (code.Length < 4)
            {
                value = null;
                args = null;
                return false;
            }

            string constantStr = "constant"; // should be interned
            string arrayStr = "array";

            bool isConstant = false;

            unsafe
            {
                fixed (char* pCode = code, ptrCONSTANT = constantStr, ptrARRAY = arrayStr)
                {
                    char* ptr = pCode;

                    // skip whitespaces
                    DHJassSyntax.skipWhiteSpacesFast(ref ptr);

                    // "constant" keyword could be here
                    if (DHJassSyntax.checkStringsEqual(ptr, ptrCONSTANT, constantStr.Length))
                    {
                        isConstant = true;

                        // skip the "constant" bytes
                        ptr += constantStr.Length;

                        // skip whitespaces
                        DHJassSyntax.skipWhiteSpacesFast(ref ptr);
                    }

                    char* pStart = ptr;

                    // typename should be here
                    DHJassSyntax.skipNonWhiteSpacesFast(ref ptr);
                    string typeName = new string(pStart, 0, (int)(ptr - pStart));

                    if (!DbJassTypeValueKnowledge.TypenameValuePairs.TryGetValue(typeName, out value))
                    {
                        args = null;
                        return false;
                    }

                    args = new List<string>(2);

                    // skip whitespaces
                    DHJassSyntax.skipWhiteSpacesFast(ref ptr);

                    // check for "array" keyword
                    if (!isConstant && DHJassSyntax.checkStringsEqual(ptr, ptrARRAY, arrayStr.Length))
                    {
                        value = DbJassTypeValueKnowledge.TypeValuePairs[typeof(DHJassArray)];

                        // skip the "array" bytes
                        ptr += arrayStr.Length;

                        // skip whitespaces
                        DHJassSyntax.skipWhiteSpacesFast(ref ptr);
                    }

                    pStart = ptr;

                    // reach end of the variable name
                    DHJassSyntax.reachEndOfVariableNameSyntaxFast(ref ptr);

                    // add variable name
                    args.Add(new string(pStart, 0, (int)(ptr - pStart)));

                    // skip whitespaces
                    DHJassSyntax.skipWhiteSpacesFast(ref ptr);

                    if (*ptr != '=') return true;

                    ptr++;

                    // skip whitespaces
                    DHJassSyntax.skipWhiteSpacesFast(ref ptr);

                    // add variable's initial value
                    args.Add(new string(ptr));

                    return true;
                }
            }
        }
Esempio n. 23
0
        public DHJassValue this[DHJassValue index]
        {
            get
            {
                object intIndex = index.GetValue();

                if (intIndex is int)
                    return array[(int)intIndex];
                else
                    return null;
            }
            set
            {
                object intIndex = index.GetValue();

                if (intIndex is int)
                    array[(int)intIndex] = value;
            }
        }
Esempio n. 24
0
 public virtual DHJassValue Add(DHJassValue value)
 {
     return null;
 }
Esempio n. 25
0
 public override void SetValue(DHJassValue value)
 {
     this.value = value.CodeValue;
 }
Esempio n. 26
0
 public virtual DHJassBoolean And(DHJassValue value)
 {
     return new DHJassBoolean(null, this.BoolValue && value.BoolValue);
 }
Esempio n. 27
0
 public override void SetValue(DHJassValue value)
 {
 }
Esempio n. 28
0
 public virtual DHJassValue Divide(DHJassValue value)
 {
     return null;
 }
Esempio n. 29
0
        public override DHJassBoolean Equals(DHJassValue value)
        {
            DHJassBoolean result = new DHJassBoolean();

            object obj = value.Value;
            if (obj == null)
                result.Value = (this.value == 0);
            else
                result.Value = (DHJassSyntax.Comparer.Compare(this.Value, obj) == 0);

            return result;
        }
Esempio n. 30
0
        public override DHJassValue Subtract(DHJassValue value)
        {
            DHJassInt returnValue = new DHJassInt();

            returnValue.value = this.value - value.IntValue;

            return returnValue;
        }