Ejemplo n.º 1
0
 public Digest(Checksum checksum, LValue lValue, Q q, Body body)
 {
     _lValue   = lValue;
     _checksum = checksum;
     _q        = q;
     _body     = body;
 }
Ejemplo n.º 2
0
        public static LValue lengthdir_y(Game _assets, Domain _environment, LValue[] _arguments, Int32 _count, Stack <LValue> _stack)
        {
            double _len = _arguments[0].Number;
            double _dir = _arguments[1].Number;

            return(LValue.Real(_len * Math.Sin(_dir * Math.PI / 180)));
        }
Ejemplo n.º 3
0
        public static LValue ds_map_create(Game _assets, Domain _environment, LValue[] _arguments, Int32 _count, Stack <LValue> _stack)
        {
            double _mapIndex = VM.Maps.Count;

            VM.Maps.Add(new Dictionary <LValue, LValue>());
            return(LValue.Real(_mapIndex));
        }
Ejemplo n.º 4
0
        public override void Perform(Game _assets, Domain _environment, LCode _code, Stack <LValue> _stack)
        {
            switch (this.Type)
            {
            case LArgumentType.Variable: {
                if (this.Data == 0 && _stack.Count > 0)
                {
                    LValue _valPush = _stack.Pop();
                    Dictionary <string, LValue> _variableList = Helper.GetVariables(_assets, _environment, (double)_stack.Pop().Value);
                    LValue _varFind = _variableList[this.Variable.Name];
                    switch (_varFind.Type)
                    {
                    case LType.Array: {
                        _stack.Push(_varFind.Array[(int)(double)_valPush.Value]);
                        break;
                    }

                    default: {
                        throw new Exception(String.Format("Could not handle push for type: {0}", _varFind.Type));
                    }
                    }
                }
                else
                {
                    _stack.Push(Helper.GetVariables(_assets, _environment, this.Data)[this.Variable.Name]);
                }
                break;
            }

            default: {
                _stack.Push(this.Value);
                break;
            }
            }
        }
Ejemplo n.º 5
0
        public override void Perform(Game _assets, Domain _environment, LCode _code, Stack <LValue> _stack)
        {
            LValue _valRight = _stack.Pop();
            LValue _valLeft  = _stack.Pop();

            _stack.Push(_valLeft / _valRight);
        }
Ejemplo n.º 6
0
        public static LValue object_is_ancestor(Game _assets, Domain _environment, LValue[] _arguments, Int32 _count, Stack <LValue> _stack)
        {
            int _objGet = (int)_arguments[0].Number;
            int _parGet = (int)_arguments[0].Number;

            if (_objGet >= 0 && _objGet < _assets.ObjectMapping.Count && _parGet >= 0 && _parGet < _assets.ObjectMapping.Count)
            {
                //define the recursive function
                //variables go in Game but where do functions go?
                //will move when I know that
                Func <LObject, LObject, bool> checkAncestry = null;
                checkAncestry = (_childObj, _parentObj) =>
                {
                    if (_childObj.Parent == _parentObj)
                    {
                        return(true);
                    }
                    bool _isAncestor = false;
                    if (_childObj.Parent != null)
                    {
                        _isAncestor = checkAncestry(_parentObj, _parentObj.Parent);
                    }

                    return(_isAncestor);
                };
                LObject _obj = _assets.ObjectMapping[_objGet];
                LObject _par = _assets.ObjectMapping[_objGet];
                if (_obj.Sprite != null)
                {
                    return(LValue.Real(checkAncestry(_obj, _par) ? 1 : 0));
                }
            }
            return(LValue.Real(0));
        }
Ejemplo n.º 7
0
        public static LValue draw_sprite(Game _assets, Domain _environment, LValue[] _arguments, Int32 _count, Stack <LValue> _stack)
        {
            LSprite _sprite = _assets.SpriteMapping[(int)_arguments[0].Number];
            int     _subimg = (int)_arguments[1].Number;
            double  _x      = _arguments[2].Number;
            double  _y      = _arguments[3].Number;
            int     _texid  = _sprite.TextureEntries[_subimg].GLTexture;

            GL.Enable(EnableCap.Texture2D);
            GL.BindTexture(TextureTarget.Texture2D, _texid);
            GL.Begin(PrimitiveType.TriangleStrip);
            GL.Color4((OpenTK.Graphics.Color4)_assets.CurrentColor);

            //the best way to do this right now is to just draw the triangles in a strip
            GL.TexCoord2(0.0, 0.0);
            GL.Vertex2(_x - _sprite.XOrigin, _y - _sprite.YOrigin);
            GL.TexCoord2(1.0, 0.0);
            GL.Vertex2(_x - _sprite.XOrigin + _sprite.Width, _y - _sprite.YOrigin);
            GL.TexCoord2(0.0, 1.0);
            GL.Vertex2(_x - _sprite.XOrigin, _y - _sprite.YOrigin + _sprite.Height);
            GL.TexCoord2(1.0, 1.0);
            GL.Vertex2(_x - _sprite.XOrigin + _sprite.Width, _y - _sprite.YOrigin + _sprite.Height);

            GL.End();
            GL.Disable(EnableCap.Texture2D);
            return(LValue.Real(0));
        }
Ejemplo n.º 8
0
 public override string AST(int depth = 0)
 {
     return($"{Spaces(depth)}[{Name}\n" +
            (Type != null ? $"{Type.AST(depth + 1)}" : "") +
            //$"{Id.AST(depth + 1)}{Expression.AST(depth + 1)}{Spaces(depth)}]\n";
            $"{LValue.AST(depth + 1)}{Expression.AST(depth + 1)}{Spaces(depth)}]\n");
 }
Ejemplo n.º 9
0
        public static LValue instance_destroy(Game _assets, Domain _environment, LValue[] _arguments, Int32 _count, Stack <LValue> _stack)
        {
            bool _instDestroy = (_count < 2 || LValue.GetBool(_arguments[1]) == true);

            if (_count > 0)
            {
                double _instIndex = _arguments[1].Number;
                if (_instIndex < LInstance.IDStart)
                {
                    LInstance _instGet = LInstance.Find(_assets, _instIndex, false);
                    while (_instGet != null)
                    {
                        _instGet.Remove(_assets, _instDestroy);
                        _instGet = LInstance.Find(_assets, _instIndex, false);
                    }
                }
                else
                {
                    LInstance _instGet = LInstance.Find(_assets, _instIndex, false);
                    if (_instGet != null)
                    {
                        _instGet.Remove(_assets, _instDestroy);
                    }
                }
            }
            else
            {
                if (_environment.Instance.ID >= LInstance.IDStart)
                {
                    _environment.Instance.Remove(_assets, _instDestroy);
                }
            }
            return(LValue.Real(0));
        }
Ejemplo n.º 10
0
        public override TypeReturn CheckSemantics(List <Scope> scope_list, List <Error> errors)
        {
            TypeReturn typeOfAsign = Asign.CheckSemantics(scope_list, errors); //hago el chequeo semantico de la asignacion

            if (typeOfAsign is ReturnNotValue)                                 //verifico que devuelva algun valor
            {
                errors.Add(new Error(line, column, "La parte derecha de la asignacion debe devolver algun valor"));
            }

            TypeReturn typeOfLvalue = LValue.CheckSemantics(scope_list, errors); //hago el chequeo semantico del Lvalue

            if (LValue is VariableNode && Utils.NoAsignVar(scope_list, ((VariableNode)LValue).Name))
            {
                errors.Add(new Error(line, column,
                                     "No se le puede asignar ningún valor a la variable '" +
                                     ((VariableNode)LValue).Name + "'"));
            }

            if (typeOfAsign is ReturnNil)      //pregunto si la parte derecha es nil
            {
                if (typeOfLvalue is ReturnInt) //un entero no permite nil (todos los demas tipos si)
                {
                    errors.Add(new Error(line, column,
                                         "No se le puede asignar un '" + typeOfAsign + "' a un '" + typeOfLvalue + "'"));
                }
            }
            else if (typeOfLvalue != null && typeOfAsign != null &&           //pregunto si no hubo problema con el chequeo de las variables
                     !typeOfLvalue.ToString().Equals(typeOfAsign.ToString())) //chequeo que los tipos sean iguales
            {
                errors.Add(new Error(line, column,
                                     "No se le puede asignar un '" + typeOfAsign + "' a un '" + typeOfLvalue + "'"));
            }

            return(new ReturnNotValue()); //la asignacion no devuelve valor
        }
Ejemplo n.º 11
0
 /// <summary>
 /// Returns a <see cref="System.String" /> that represents this instance.
 /// </summary>
 /// <returns>
 /// A <see cref="System.String" /> that represents this instance.
 /// </returns>
 public override string ToString()
 {
     return(string.Format("{0}:{1}:{2}:{3}:{4}:{5}",
                          Address, BasePtr, RetAddress, Name ?? "(null)",
                          Value.ToString(),
                          LValue != null ? LValue.ToString() : "(null)"));
 }
Ejemplo n.º 12
0
        public override void CheckSemantic(Scope scope, ErrorLog log)
        {
            LValue.CheckSemantic(scope, log);
            Value.CheckSemantic(scope, log);

            if (LValue.Type != null)
            {
                //if (!LValue.Type.Match(Value.Type))
                //{
                //    log.Error("The types do not match", Line, Column);
                //}
                Type = LValue.Type;
            }

            //if (Type != null)
            //{
            //    if (Operator == AssignOp.AddAssign ||
            //       Operator == AssignOp.SubAssign ||
            //       Operator == AssignOp.MulAssign ||
            //       Operator == AssignOp.DivAssign)
            //    {
            //        if (!(Type.IsPrimitive &&
            //            (Type.ReflectionType.Class == Graphics.TypeClass.Vector ||
            //            Type.ReflectionType.Class == Graphics.TypeClass.Scalar ||
            //            Type.ReflectionType.Class == Graphics.TypeClass.Matrix)))
            //        {
            //            log.Error("The " + GetValue(Operator) + " is only allowed on type " + Type.Name, Line, Column);
            //        }
            //    }
            //}
            if (Type == null)
            {
                Type = ShaderRuntime.Unknow;
            }
        }
Ejemplo n.º 13
0
        public static LValue ds_map_clear(Game _assets, Domain _environment, LValue[] _arguments, Int32 _count, Stack <LValue> _stack)
        {
            Dictionary <LValue, LValue> _mapFind = VM.Maps[(int)_arguments[0].Number];

            _mapFind.Clear();
            return(LValue.Real(0));
        }
Ejemplo n.º 14
0
        public override void Perform(Game _assets, Domain _environment, LCode _code, Stack <LValue> _stack)
        {
            switch (this.Variable)
            {
            case "room": {
                _stack.Push(LValue.Real((double)_assets.CurrentRoom.Index));
                break;
            }

            case "room_width": {
                _stack.Push(LValue.Real((double)_assets.CurrentRoom.Width));
                break;
            }

            case "room_height": {
                _stack.Push(LValue.Real((double)_assets.CurrentRoom.Height));
                break;
            }

            case "undefined": {
                _stack.Push(LValue.Undef());
                break;
            }

            case "current_time": {
                _stack.Push(LValue.Real(VM.Timer.ElapsedMilliseconds));
                break;
            }

            default: {
                throw new Exception(String.Format("Could not return built-in variable named: \"{0}\"", this.Variable));
            }
            }
        }
Ejemplo n.º 15
0
        public override void GenCode(ICodeGenerator cg)
        {
            LValue.GenCode(cg);
            var expType   = LValue.ReturnType.PrimitiveType.ILType; //Obtengo el tipo del LValue
            var fieldInfo = expType.GetField(FieldName);            //Obtengo el tipo del campo

            cg.GetGenerator.Emit(OpCodes.Ldfld, fieldInfo);
        }
Ejemplo n.º 16
0
        public override void GenCode(ICodeGenerator cg)
        {
            var       gen       = cg.GetGenerator;
            ArrayType arrayType = (LValue.ReturnType.PrimitiveType as ArrayType);

            LValue.GenCode(cg);
            IndexInstruction.GenCode(cg);
            gen.Emit(OpCodes.Ldelem, arrayType.BaseType.ILType);
        }
Ejemplo n.º 17
0
 public static LValue min(Game _assets, Domain _environment, LValue[] _arguments, Int32 _count, Stack <LValue> _stack)
 {
     double[] _val = new double[_count];
     for (int i = 0; i < _count; i++)
     {
         _val[i] = (double)_arguments[i];
     }
     return(LValue.Real(_val.Min()));
 }
Ejemplo n.º 18
0
        public string ShowRule(int pad)
        {
            String padStr = new string(' ', pad * 4);

            return
                (padStr + "Begin And\r\n" +
                 LValue.ShowRule(pad + 1) +
                 RValue.ShowRule(pad + 1) +
                 padStr + "End And\r\n");
        }
Ejemplo n.º 19
0
        public static LValue object_get_name(Game _assets, Domain _environment, LValue[] _arguments, Int32 _count, Stack <LValue> _stack)
        {
            int _objGet = (int)_arguments[0].Number;

            if (_objGet >= 0 && _objGet < _assets.ObjectMapping.Count)
            {
                return(LValue.Text(_assets.ObjectMapping[_objGet].Name));
            }
            return(LValue.Real(0));
        }
Ejemplo n.º 20
0
        public static LValue choose(Game _assets, Domain _environment, LValue[] _arguments, Int32 _count, Stack <LValue> _stack)
        {
            if (_count == 0)
            {
                return(LValue.Undef());
            }
            int choice = WellGenerator.ENext(_count);

            return(_arguments[choice]);
        }
Ejemplo n.º 21
0
        public static LValue draw_set_colour(Game _assets, Domain _environment, LValue[] _arguments, Int32 _count, Stack <LValue> _stack)
        {
            int  _col = _arguments[0].I32;
            byte _r   = (byte)(_col & 0xFF);
            byte _g   = (byte)((_col >> 8) & 0xFF);
            byte _b   = (byte)((_col >> 16) & 0xFF);

            _assets.CurrentColor = new LColour(_r, _g, _b, 0xFF);//this is a cast btw
            return(LValue.Real(0));
        }
Ejemplo n.º 22
0
        public static LValue parameter_string(Game _assets, Domain _environment, LValue[] _arguments, Int32 _count, Stack <LValue> _stack)
        {
            int _paramIndex = (int)(double)_arguments[0];

            if (_paramIndex >= 0 && _paramIndex < Program.Arguments.Length)
            {
                return(LValue.Text(Program.Arguments[_paramIndex]));
            }
            return(LValue.Text(""));
        }
Ejemplo n.º 23
0
        public static LValue ds_map_find_value(Game _assets, Domain _environment, LValue[] _arguments, Int32 _count, Stack <LValue> _stack)
        {
            Dictionary <LValue, LValue> _mapFind = VM.Maps[(int)_arguments[0].Number];

            if (_mapFind.ContainsKey(_arguments[1]) == true)
            {
                return(_mapFind[_arguments[1]]);
            }
            return(LValue.Undef());
        }
Ejemplo n.º 24
0
        public static LValue NewGMLArray(Game _assets, Domain _environment, LValue[] _arguments, Int32 _count, Stack <LValue> _stack)
        {
            LValue _valArray = new LValue(LType.Array, new LValue[_count]);

            for (int i = 0; i < _count; i++)
            {
                _valArray.Array[i] = _arguments[i];
            }
            return(_valArray);
        }
Ejemplo n.º 25
0
 /// <inheritdoc />
 public override string ToString()
 {
     if (LValue == null)
     {
         return(base.ToString());
     }
     else
     {
         return(LValue.ToString() + " " + GetHashCode());
     }
 }
Ejemplo n.º 26
0
        public static LValue draw_get_colour(Game _assets, Domain _environment, LValue[] _arguments, Int32 _count, Stack <LValue> _stack)
        {
            int col = 0;

            col += _assets.CurrentColor.Red;
            col  = col << 8;
            col += _assets.CurrentColor.Green;
            col  = col << 8;
            col += _assets.CurrentColor.Blue;
            return(LValue.Real(col));
        }
Ejemplo n.º 27
0
        public static LValue object_set_solid(Game _assets, Domain _environment, LValue[] _arguments, Int32 _count, Stack <LValue> _stack)
        {
            int  _objGet = (int)_arguments[0].Number;
            bool _solid  = _arguments[0];

            if (_objGet >= 0 && _objGet < _assets.ObjectMapping.Count)
            {
                _assets.ObjectMapping[_objGet].Solid = _solid;
            }
            return(LValue.Real(0));
        }
Ejemplo n.º 28
0
 public override int GenerateCode(int loc, IVirtualMachine vm, CheckerInformation info)
 {
     if (LValue.GetExpressionType(info) != RValue.GetExpressionType(info))
     {
         throw new CheckerException("An assignment has to have the same types for LValue and RValue");
     }
     loc = RValue.GenerateCode(loc, vm, info);
     loc = LValue.GenerateLValue(loc, vm, info);
     vm.Store(loc++);
     return(loc);
 }
Ejemplo n.º 29
0
        public static LValue object_get_visible(Game _assets, Domain _environment, LValue[] _arguments, Int32 _count, Stack <LValue> _stack)
        {
            int _objGet = (int)_arguments[0].Number;

            if (_objGet >= 0 && _objGet < _assets.ObjectMapping.Count)
            {
                LObject _obj = _assets.ObjectMapping[_objGet];
                return(LValue.Real(_obj.Visible ? 1 : 0));
            }
            return(LValue.Real(0));
        }
Ejemplo n.º 30
0
        public static LValue room_get_viewport(Game _assets, Domain _environment, LValue[] _arguments, Int32 _count, Stack <LValue> _stack)
        {
            int _roomGet = (int)_arguments[0].Number;
            int _viewGet = (int)_arguments[1].Number;

            if (_roomGet >= 0 && _roomGet < _assets.RoomMapping.Count && _viewGet >= 0 && _viewGet < 8)
            {
                LRoomView _view = _assets.RoomMapping[_roomGet].Views[_viewGet];
                return(LValue.Values(_view.Enabled, _view.X, _view.Y, _view.Width, _view.Height));
            }
            return(LValue.Real(0));
        }
Ejemplo n.º 31
0
 void LValue(out LValue lv)
 {
     lv = null;
     Expect(1);
     lv = new VariableLValue(GetPragma(t), GetVariable(t.val)); SetEndPragma(lv);
 }