MCPcopy Create free account
hub / github.com/elliotchance/c2go / AddMessage

Method AddMessage

program/program.go:187–212  ·  view source on GitHub ↗

AddMessage adds a message (such as a warning or error) comment to the output file. Usually the message is generated from one of the Generate functions in the ast package. It is expected that the message already have the comment ("//") prefix. The message will not be appended if it is blank. This i

(message string)

Source from the content-addressed store, hash-verified

185//
186// The return value will be true if a message was added, otherwise false.
187func (p *Program) AddMessage(message string) bool {
188 if message == "" {
189 return false
190 }
191
192 p.messages = append(p.messages, message)
193
194 // Compactizarion warnings stack
195 if len(p.messages) > 1 {
196 var (
197 new = len(p.messages) - 1
198 last = len(p.messages) - 2
199 )
200 // Warning collapsing for minimaze warnings
201 warning := "// Warning"
202 if strings.HasPrefix(p.messages[last], warning) {
203 l := p.messages[last][len(warning):]
204 if strings.HasSuffix(p.messages[new], l) {
205 p.messages[last] = p.messages[new]
206 p.messages = p.messages[0:new]
207 }
208 }
209 }
210
211 return true
212}
213
214// GetMessageComments - get messages "Warnings", "Error" like a comment
215// Location of comments only NEAR of error or warning and

Callers 15

StartFunction · 0.95
CastExprFunction · 0.80
transpileFieldDeclFunction · 0.80
transpileRecordDeclFunction · 0.80
transpileTypedefDeclFunction · 0.80
transpileVarDeclFunction · 0.80
transpileConstantExprFunction · 0.80
TranspileASTFunction · 0.80
transpileToExprFunction · 0.80
transpileToStmtsFunction · 0.80
transpileToStmtFunction · 0.80
transpileToNodeFunction · 0.80

Calls 1

lenClass · 0.50

Tested by

no test coverage detected