當前位置: 首頁>>代碼示例>>Golang>>正文


Golang gelo.ArgumentError函數代碼示例

本文整理匯總了Golang中code/google/com/p/gelo.ArgumentError函數的典型用法代碼示例。如果您正苦於以下問題:Golang ArgumentError函數的具體用法?Golang ArgumentError怎麽用?Golang ArgumentError使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了ArgumentError函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: DictToCommand

func DictToCommand(vm *gelo.VM, args *gelo.List, ac uint) gelo.Word {
	if ac != 1 {
		gelo.ArgumentError(vm, "dict->command", "dictionary", args)
	}
	m := vm.API.DictOrElse(args.Value).Map()
	return gelo.Alien(func(vm *gelo.VM, args *gelo.List, ac uint) gelo.Word {
		if ac == 0 {
			gelo.ArgumentError(vm, "command generated by dict->command",
				"argument+", args)
		}
		name := args.Value.Ser().String()
		if v, ok := m[name]; ok {
			if args.Next != nil {
				return vm.API.TailInvokeCmd(v, args.Next)
			} else {
				return vm.API.TailInvokeWordOrReturn(v)
			}
		} else if args.Next != nil {
			gelo.RuntimeError(vm, name, "is not a valid subcommand")
		} else {
			gelo.RuntimeError(vm, name, "is not a valid subcommand or entry")
		}
		panic("command generated by dict->command in impossible state") //Issue 65
	})
}
開發者ID:catb0t,項目名稱:gelo,代碼行數:25,代碼來源:dict.go

示例2: ArgumentError

func ArgumentError(vm *gelo.VM, args *gelo.List, ac uint) gelo.Word {
	if ac != 2 {
		gelo.ArgumentError(vm, "ArgumentError", "name arg-spec args", args)
	}
	gelo.ArgumentError(vm, args.Value.Ser(), args.Next.Value.Ser(),
		args.Next.Next.Value.Ser())
	panic("Issue 65")
}
開發者ID:catb0t,項目名稱:gelo,代碼行數:8,代碼來源:error.go

示例3: DictAggregate

func DictAggregate(vm *gelo.VM, args *gelo.List, ac uint) gelo.Word {
	if ac < 2 {
		gelo.ArgumentError(vm, "dict", "dictionary command args*", args)
	}
	d := args.Value
	command := args.Next.Value.Ser().String()
	rest := args.Next.Next
	if _, ok := _dict_commands[command]; !ok {
		gelo.ArgumentError(vm, "dict",
			"dictionary 'set!|'unset!|'get|'get!|'set?|'keys|'value args*",
			command)
	}
	return _dict_commands[command](vm, &gelo.List{d, rest}, ac-1)
}
開發者ID:catb0t,項目名稱:gelo,代碼行數:14,代碼來源:dict.go

示例4: MakeOrElseArgParser

func MakeOrElseArgParser(spec string) func(*gelo.VM, *gelo.List) map[string]gelo.Word {
	parser := MakeArgParser(spec)
	return func(vm *gelo.VM, args *gelo.List) map[string]gelo.Word {
		Args, ok := parser(args)
		if !ok {
			if len(spec) != 0 {
				gelo.ArgumentError(vm, "argparser", spec, args)
			} else {
				gelo.ArgumentError(vm, "argparser", "no arguments", args)
			}
		}
		return Args
	}
}
開發者ID:catb0t,項目名稱:gelo,代碼行數:14,代碼來源:argparse.go

示例5: set

func (p *ConfigParser) set(vm *gelo.VM, args *gelo.List, ac uint) gelo.Word {
	if ac == 0 {
		gelo.ArgumentError(vm, "set", "<name> [args*]", args)
	}
	name := vm.API.SymbolOrElse(args.Value)

	// Check that we're in correct section
	checkInSection(vm, "set", "port", "plugin")

	// Check that all arguments are compatible values
	for tmp := args; tmp != nil; tmp = tmp.Next {
		_, oksym := tmp.Value.(gelo.Symbol)
		_, oknum := tmp.Value.(*gelo.Number)
		_, okbool := tmp.Value.(gelo.Bool)
		if !(oksym || oknum || okbool) {
			runtimeError(vm, "Arguments of set should be symbols or numbers or booleans")
		}
	}

	var values *gelo.List
	if ac == 1 {
		values = gelo.NewListFromGo([]interface{}{gelo.True})
	} else {
		values = args.Next
	}

	d := getOrMakeDict(vm, "data")
	d.Set(name, values)

	return nil
}
開發者ID:netvl,項目名稱:bridge-server,代碼行數:31,代碼來源:misc.go

示例6: NS_globals

func NS_globals(vm *gelo.VM, args *gelo.List, ac uint) gelo.Word {
	if ac != 0 {
		gelo.ArgumentError(vm, "ns.globals", "", args)
	}
	d := vm.Ns.Locals(-1)
	return d
}
開發者ID:catb0t,項目名稱:gelo,代碼行數:7,代碼來源:names.go

示例7: PortClosedp

func PortClosedp(vm *gelo.VM, args *gelo.List, ac uint) gelo.Word {
	if ac != 1 {
		gelo.ArgumentError(vm, "closed?", "port", args)
	}
	p := vm.API.PortOrElse(args.Value)
	return gelo.ToBool(p.Closed())
}
開發者ID:catb0t,項目名稱:gelo,代碼行數:7,代碼來源:port.go

示例8: plugin

func (p *ConfigParser) plugin(vm *gelo.VM, args *gelo.List, ac uint) gelo.Word {
	if ac != 2 {
		gelo.ArgumentError(vm, "plugin", "<name> {body}", args)
	}
	name := args.Value.Ser().String()
	body := vm.API.QuoteOrElse(args.Next.Value)

	checkInSection(vm, "plugin", "plugins")

	insideSection(vm, "plugin", name,
		func() {
			p.conf.Plugins[name] = new(conf.PluginConf)
			p.conf.Plugins[name].Name = name
			vm.API.InvokeCmdOrElse(body, args)

			p.conf.Plugins[name].Options = make(map[string][]string)
			d := getOrMakeDict(vm, "data")
			for k, v := range d.Map() {
				var elements []string
				args.Slice()
				for e := vm.API.ListOrElse(v); e != nil; e = e.Next {
					elements = append(elements, e.Value.Ser())
				}
				p.conf.Plugins[name].Options[k] = elements
			}
		},
	)

	return nil
}
開發者ID:netvl,項目名稱:bridge-server,代碼行數:30,代碼來源:plugins.go

示例9: Value

//For each item, Value acts as the identity unless the item is a quote.
//If it is a quote attempt to invoke and return result if there were no errors
//If invocation fails for any reason Value returns the quote as a literal.
func Value(vm *gelo.VM, args *gelo.List, ac uint) gelo.Word {
	if ac == 0 {
		gelo.ArgumentError(vm, "value", "items+", "")
	}
	return args.MapOrApply(func(w gelo.Word) gelo.Word {
		return vm.API.TailInvokeWordOrReturn(w)
	})
}
開發者ID:catb0t,項目名稱:gelo,代碼行數:11,代碼來源:eval.go

示例10: Copy

func Copy(vm *gelo.VM, args *gelo.List, ac uint) gelo.Word {
	if ac == 0 {
		gelo.ArgumentError(vm, "copy", "values+", "")
	}
	return args.MapOrApply(func(w gelo.Word) gelo.Word {
		return w.Copy()
	})
}
開發者ID:catb0t,項目名稱:gelo,代碼行數:8,代碼來源:copy.go

示例11: Mod

func Mod(vm *gelo.VM, args *gelo.List, ac uint) gelo.Word {
	if ac != 2 {
		gelo.ArgumentError(vm, "mod", "number base", args)
	}
	n := vm.API.NumberOrElse(args.Value).Real()
	m := vm.API.NumberOrElse(args.Next.Value).Real()
	return gelo.NewNumber(math.Mod(n, m))
}
開發者ID:catb0t,項目名稱:gelo,代碼行數:8,代碼來源:math.go

示例12: TypeMismatchError

func TypeMismatchError(vm *gelo.VM, args *gelo.List, ac uint) gelo.Word {
	if ac != 2 {
		gelo.ArgumentError(vm, "TypeMismatchError",
			"expected-type recieved-type", args)
	}
	gelo.TypeMismatch(vm, args.Value.Ser(), args.Next.Value.Ser())
	panic("Issue 65")
}
開發者ID:catb0t,項目名稱:gelo,代碼行數:8,代碼來源:error.go

示例13: SyntaxError

func SyntaxError(vm *gelo.VM, args *gelo.List, ac uint) gelo.Word {
	if ac == 0 {
		gelo.ArgumentError(vm, "SyntaxError", "error-msg+", "")
	}
	//TODO should get a line-no, etc to allow creation of good error message
	gelo.SyntaxError(args)
	panic("Issue 65")
}
開發者ID:catb0t,項目名稱:gelo,代碼行數:8,代碼來源:error.go

示例14: Dict_setp

func Dict_setp(vm *gelo.VM, args *gelo.List, ac uint) gelo.Word {
	if ac != 2 {
		gelo.ArgumentError(vm, "dict.setp?", "dictionary key", args)
	}
	d := vm.API.DictOrElse(args.Value.(*gelo.Dict))
	k := args.Next.Value
	return gelo.ToBool(d.Has(k))
}
開發者ID:catb0t,項目名稱:gelo,代碼行數:8,代碼來源:dict.go

示例15: NS_inject

func NS_inject(vm *gelo.VM, args *gelo.List, ac uint) gelo.Word {
	if ac != 1 {
		gelo.ArgumentError(vm, "ns.inject", "dictionary", args)
	}
	d := vm.API.DictOrElse(args.Value)
	vm.Ns.Inject(0, d)
	return d
}
開發者ID:catb0t,項目名稱:gelo,代碼行數:8,代碼來源:names.go


注:本文中的code/google/com/p/gelo.ArgumentError函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。