예제 #1
0
 internal static void GetGlobal(VirtualMachine vm, Instruction i)
 {
     Value name = vm.Stack.Shift();
     if (name.Type != ValueTypes.STRING || name.String_Value == null || name.String_Value == "") {
         vm.RaiseError("Tried to access a global bound value with a non-string name");
         return;
     }
     if (vm.GlobalsExists(name.String_Value) == false) {
         vm.RaiseError("Tried to access non-existent global bound value name " + name.String_Value);
         return;
     }
     vm.Stack.Push(vm.GetGlobal(name.String_Value));
     return;
 }
예제 #2
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);
 }