Ejemplo n.º 1
0
 internal static void SetGlobal(VirtualMachine vm, Instruction i)
 {
     Value vName = vm.Stack.Shift();
     Value vValue = vm.Stack.Shift();
     if (vName.Type != ValueTypes.STRING || vName.String_Value == null || vName.String_Value == "") {
         vm.RaiseError("Tried to use a non-string value for a variable name");
         return;
     }
     if (vm.GlobalsExists(vName.String_Value) && i.Type == OpCodeTypes.TYPESET_TOP) {
         Value vTop = vm.GetGlobal(vName.String_Value);
         if (vTop.Type != vValue.Type) {
             vm.RaiseError("Tried to redefine type for value " + vName.String_Value + ": variable is " + vTop.Type + ", new value is " + vValue.Type);
             return;
         }
     }
     vm.SetGlobal(vName.String_Value, vValue);
 }