コード例 #1
0
        public eeObject Divide(eeObject exp)
        {
            if (this.type != eeObjectType.NUMBER || exp.type != eeObjectType.NUMBER)
            {
                throw new InvalidOperationError("division", type, exp.type);
            }

            return(eeObject.newNumberObject(this.AsNumber() / exp.AsNumber()));
        }
コード例 #2
0
        public bool IsGreaterThan(eeObject obj)
        {
            switch (this.type)
            {
            case eeObjectType.NUMBER:
                return(this.AsNumber() > obj.AsNumber());

            case eeObjectType.LIST:
                return(ListMathHelpers.GreaterThan(this, obj));

            case eeObjectType.STRING:
                return(StringMathHelpers.GreaterThan(this, obj));

            case eeObjectType.BOOL:
            default:
                throw new InvalidOperationException("TO DO");
            }
        }
コード例 #3
0
 public eeObject Multiply(eeObject exp)
 {
     if (this.type == eeObjectType.STRING || exp.type == eeObjectType.STRING)
     {
         return(StringMathHelpers.Multiply(this, exp));
     }
     else if (this.type == eeObjectType.LIST || exp.type == eeObjectType.LIST)
     {
         return(ListMathHelpers.Multiply(this, exp));
     }
     else if (this.type == eeObjectType.NUMBER && exp.type == eeObjectType.NUMBER) // regular arithmetic
     {
         return(eeObject.newNumberObject(this.AsNumber() * exp.AsNumber()));
     }
     else
     {
         throw new InvalidOperationError("multiplication", type, exp.type);
     }
 }
コード例 #4
0
 public eeObject Subtract(eeObject exp)
 {
     if (this.type == eeObjectType.STRING || exp.type == eeObjectType.STRING) // string math
     {
         return(StringMathHelpers.Subtract(this, exp));
     }
     else if (this.type == eeObjectType.LIST || exp.type == eeObjectType.LIST) // list math
     {
         return(ListMathHelpers.Subtract(this, exp));
     }
     else if (this.type == eeObjectType.NUMBER && exp.type == eeObjectType.NUMBER) // regular arithmetic
     {
         return(eeObject.newNumberObject(this.AsNumber() - exp.AsNumber()));
     }
     else
     {
         throw new InvalidOperationError("subtraction", type, exp.type);
     }
 }
コード例 #5
0
        // If this object is an element of a list, this method with replace it with another value
        public void CopyFrom(eeObject fromObj, bool asArrayElement = false)
        {
            switch (fromObj.type)
            {
            case eeObjectType.NUMBER:
                this.value = fromObj.AsNumber().Copy();
                break;

            default:     // all other types are natively constants so we dont need to explicity copy them
                this.value = fromObj.value;
                break;
            }

            this.attributes = fromObj.attributes;
            this.methods    = fromObj.methods;
            this.type       = fromObj.type;

            // Array elements do not get modifiers
            if (asArrayElement)
            {
                modifier = null;
            }
        }