本文整理汇总了Golang中tritium/proto.Function.Description方法的典型用法代码示例。如果您正苦于以下问题:Golang Function.Description方法的具体用法?Golang Function.Description怎么用?Golang Function.Description使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tritium/proto.Function
的用法示例。
在下文中一共展示了Function.Description方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: Parse
func (p *Parser) Parse() *tp.ScriptObject {
script := new(tp.ScriptObject)
// script.Name = proto.String(p.FullPath)
if !p.RootFile || TritiumParserShowRewriterFileName {
script.Name = proto.String(filepath.Join(p.ScriptPath, p.FileName))
} else {
script.Name = proto.String("__rewriter__")
}
stmts := tp.ListInstructions()
defs := make([]*tp.Function, 0) // Add a new constructor in instruction.go
// Look for the namespace directive first.
if p.peek().Lexeme == NAMESPACE {
p.namespaces()
}
for p.peek().Lexeme != EOF {
switch p.peek().Lexeme {
case FUNC:
defs = append(defs, p.definition())
case OPEN:
p.open(false)
default:
stmt := p.statement()
stmts = append(stmts, stmt)
// need to intersperse imports with definitions
if constants.Instruction_InstructionType_name[int32(stmt.GetType())] == "IMPORT" {
// Make a special function stub that represents the import.
// Need to do this because we can't mix definitions and instructions in
// the same array.
imp := new(tp.Function)
imp.Name = proto.String("@import")
imp.Description = proto.String(stmt.GetValue())
defs = append(defs, imp)
}
}
}
if len(defs) == 0 {
defs = nil
}
var line int32
if len(stmts) == 0 {
stmts = nil
} else {
line = *stmts[0].LineNumber
}
script.Functions = defs
script.Root = tp.MakeBlock(stmts, line)
// if defs == nil && p.currentNamespace() != "tritium" {
// panic(fmt.Sprintf("%s: %d -- custom modules may only be declared in function definition files", p.FileName, moduleLineNum))
// }
return script
}