public void RaiseException(HassiumObject message) { if (Handlers.Count == 0) { var callstack = UnwindCallStack(); string msg; if (message.ContainsAttribute("message")) { msg = message.GetAttribute(this, "message").Invoke(this, inst.SourceLocation).ToString(this, message.GetAttribute(this, "message"), inst.SourceLocation).String; } else { msg = message.ToString(this, message, inst.SourceLocation).String; } throw new UnhandledException(CurrentSourceLocation, callstack, msg); } var handler = Handlers.Pop(); handler.Invoke(this, inst.SourceLocation, message); if (!ExceptionReturns.ContainsKey(handler.Caller)) { ExceptionReturns.Add(handler.Caller, handler.Caller.Labels[handler.Label]); } }
public HassiumBool Is(VirtualMachine vm, SourceLocation location, HassiumObject left) { foreach (var trait in Traits.Dictionary) { string name = trait.Key.ToString(vm, trait.Key, location).String; var val = trait.Value is HassiumMethod?trait.Value.Invoke(vm, location) : trait.Value is HassiumTypeDefinition ? trait.Value : trait.Value.Type(); if (left.ContainsAttribute(name)) { if (!val.Types.Contains(left.BoundAttributes[name].Type())) { return(False); } } else { return(False); } } return(True); }