Exemple #1
0
func maclin() {
	var buf bytes.Buffer
	var symb string

	n := getnsn()
	c := getc()
	if n < 0 {
		goto bad
	}
	for {
		if c == ' ' || c == '\t' {
			c = getc()
			continue
		}

		if c == '"' {
			break
		}
		if c == '\n' {
			symb = "<noname>"
			goto nn
		}

		goto bad
	}

	for {
		c = getc()
		if c == '"' {
			break
		}
		buf.WriteByte(byte(c))
	}
	symb = buf.String()

	c = getcom()
	if c != '\n' {
		goto bad
	}

nn:
	obj.Linklinehist(Ctxt, int(Lineno), symb, int(n))
	return

bad:
	unget(c)
	Yyerror("syntax in #line")
	macend()
}
Exemple #2
0
func newfile(s string, f *os.File) {
	i := ionext
	i.Link = iostack
	iostack = i
	i.F = f
	if f == nil {
		var err error
		i.F, err = os.Open(s)
		if err != nil {
			Yyerror("%ca: %v", Thechar, err)
			errorexit()
		}
	}

	fi.P = nil
	obj.Linklinehist(Ctxt, int(Lineno), s, 0)
}
Exemple #3
0
func filbuf() int {
	var n int

loop:
	i := iostack
	if i == nil {
		return EOF
	}
	if i.F == nil {
		goto pop
	}
	n, _ = i.F.Read(i.B[:])
	if n == 0 {
		i.F.Close()
		obj.Linklinehist(Ctxt, int(Lineno), "<pop>", 0)
		goto pop
	}
	fi.P = i.B[1:n]
	return int(i.B[0]) & 0xff

pop:
	iostack = i.Link
	i.Link = iofree
	iofree = i
	i = iostack
	if i == nil {
		return EOF
	}
	fi.P = i.P
	if len(fi.P) == 0 {
		goto loop
	}
	tmp8 := fi.P
	fi.P = fi.P[1:]
	return int(tmp8[0]) & 0xff
}
Exemple #4
0
func macprag() {
	var c int

	s := getsym()

	if s != nil && s.Name == "lib" {
		c0 := getnsc()
		if c0 != '"' {
			c = c0
			if c0 != '<' {
				goto bad
			}
			c0 = '>'
		}

		var buf bytes.Buffer
		for {
			c = getc()
			if c == c0 {
				break
			}
			if c == '\n' {
				goto bad
			}
			buf.WriteByte(byte(c))
		}
		symb := buf.String()

		c = getcom()
		if c != '\n' {
			goto bad
		}

		/*
		 * put pragma-line in as a funny history
		 */
		obj.Linklinehist(Ctxt, int(Lineno), symb, -1)
		return
	}
	if s != nil && s.Name == "pack" {
		pragpack()
		return
	}

	if s != nil && s.Name == "fpround" {
		pragfpround()
		return
	}

	if s != nil && s.Name == "textflag" {
		pragtextflag()
		return
	}

	if s != nil && s.Name == "dataflag" {
		pragdataflag()
		return
	}

	if s != nil && s.Name == "varargck" {
		pragvararg()
		return
	}

	if s != nil && s.Name == "incomplete" {
		pragincomplete()
		return
	}

	if s != nil && (strings.HasPrefix(s.Name, "cgo_") || strings.HasPrefix(s.Name, "dyn")) {
		pragcgo(s.Name)
		return
	}

	for getnsc() != '\n' {
	}
	return

bad:
	unget(c)
	Yyerror("syntax in #pragma lib")
	macend()
}