Commit 2527bba9 authored by Robert Griesemer's avatar Robert Griesemer

casify pretty

R=r
OCL=22899
CL=22899
parent 605d0746
......@@ -54,23 +54,23 @@ export func KindStr(kind int) string {
export type Object struct {
id int; // unique id
Id int; // unique id
pos int; // source position (< 0 if unknown position)
kind int; // object kind
ident string;
typ *Type; // nil for packages
pnolev int; // >= 0: package no., <= 0: function nesting level, 0: global level
Pos int; // source position (< 0 if unknown position)
Kind int; // object kind
Ident string;
Typ *Type; // nil for packages
Pnolev int; // >= 0: package no., <= 0: function nesting level, 0: global level
// attached values
block *array.Array; end int; // stats for function literals; end of block pos
Block *array.Array; End int; // stats for function literals; end of block pos
}
func (obj *Object) IsExported() bool {
switch obj.kind {
switch obj.Kind {
case NONE /* FUNC for now */, CONST, TYPE, VAR, FUNC:
ch, size := utf8.DecodeRuneInString(obj.ident, 0);
ch, size := utf8.DecodeRuneInString(obj.Ident, 0);
return unicode.IsUpper(ch);
}
return false;
......@@ -78,18 +78,18 @@ func (obj *Object) IsExported() bool {
export var Universe_void_typ *Type // initialized by Universe to Universe.void_typ
var ObjectId int;
var objectId int;
export func NewObject(pos, kind int, ident string) *Object {
obj := new(Object);
obj.id = ObjectId;
ObjectId++;
obj.Id = objectId;
objectId++;
obj.pos = pos;
obj.kind = kind;
obj.ident = ident;
obj.typ = Universe_void_typ;
obj.pnolev = 0;
obj.Pos = pos;
obj.Kind = kind;
obj.Ident = ident;
obj.Typ = Universe_void_typ;
obj.Pnolev = 0;
return obj;
}
......@@ -133,23 +133,23 @@ func (scope *Scope) Lookup(ident string) *Object {
}
func (scope *Scope) Add(obj* Object) {
scope.entries[obj.ident] = obj;
func (scope *Scope) add(obj* Object) {
scope.entries[obj.Ident] = obj;
}
func (scope *Scope) Insert(obj *Object) {
if scope.LookupLocal(obj.ident) != nil {
if scope.LookupLocal(obj.Ident) != nil {
panic("obj already inserted");
}
scope.Add(obj);
scope.add(obj);
}
func (scope *Scope) InsertImport(obj *Object) *Object {
p := scope.LookupLocal(obj.ident);
p := scope.LookupLocal(obj.Ident);
if p == nil {
scope.Add(obj);
scope.add(obj);
p = obj;
}
return p;
......@@ -169,8 +169,8 @@ func (scope *Scope) Print() {
// All nodes have a source position and and token.
export type Node struct {
pos int; // source position (< 0 => unknown position)
tok int; // identifying token
Pos int; // source position (< 0 => unknown position)
Tok int; // identifying token
}
......@@ -179,8 +179,8 @@ export type Node struct {
export type Expr struct {
Node;
x, y *Expr; // binary (x, y) and unary (y) expressions
obj *Object;
X, Y *Expr; // binary (X, Y) and unary (Y) expressions
Obj *Object;
}
......@@ -189,7 +189,7 @@ func (x *Expr) Len() int {
return 0;
}
n := 1;
for ; x.tok == Scanner.COMMA; x = x.y {
for ; x.Tok == Scanner.COMMA; x = x.Y {
n++;
}
return n;
......@@ -197,11 +197,11 @@ func (x *Expr) Len() int {
export func NewExpr(pos, tok int, x, y *Expr) *Expr {
if x != nil && x.tok == Scanner.TYPE || y != nil && y.tok == Scanner.TYPE {
if x != nil && x.Tok == Scanner.TYPE || y != nil && y.Tok == Scanner.TYPE {
panic("no type expression allowed");
}
e := new(Expr);
e.pos, e.tok, e.x, e.y = pos, tok, x, y;
e.Pos, e.Tok, e.X, e.Y = pos, tok, x, y;
return e;
}
......@@ -209,7 +209,7 @@ export func NewExpr(pos, tok int, x, y *Expr) *Expr {
// TODO probably don't need the tok parameter eventually
export func NewLit(tok int, obj *Object) *Expr {
e := new(Expr);
e.pos, e.tok, e.obj = obj.pos, tok, obj;
e.Pos, e.Tok, e.Obj = obj.Pos, tok, obj;
return e;
}
......@@ -296,47 +296,47 @@ export const /* channel mode */ (
export type Type struct {
id int; // unique id
Id int; // unique id
ref int; // for exporting only: >= 0 means already exported
form int; // type form
size int; // size in bytes
obj *Object; // primary type object or NULL
scope *Scope; // forwards, structs, interfaces, functions
Ref int; // for exporting only: >= 0 means already exported
Form int; // type form
Size int; // size in bytes
Obj *Object; // primary type object or NULL
Scope *Scope; // forwards, structs, interfaces, functions
// syntactic components
pos int; // source position (< 0 if unknown position)
expr *Expr; // type name, array length
mode int; // channel mode
key *Type; // receiver type or map key
elt *Type; // array, map, channel or pointer element type, function result type
list *array.Array; end int; // struct fields, interface methods, function parameters
scope *Scope; // struct fields, methods
Pos int; // source position (< 0 if unknown position)
Expr *Expr; // type name, array length
Mode int; // channel mode
Key *Type; // receiver type or map key
Elt *Type; // array, map, channel or pointer element type, function result type
List *array.Array; End int; // struct fields, interface methods, function parameters
Scope *Scope; // struct fields, methods
}
var TypeId int;
var typeId int;
export func NewType(pos, form int) *Type {
typ := new(Type);
typ.id = TypeId;
TypeId++;
typ.Id = typeId;
typeId++;
typ.ref = -1; // not yet exported
typ.pos = pos;
typ.form = form;
typ.Ref = -1; // not yet exported
typ.Pos = pos;
typ.Form = form;
return typ;
}
func (t *Type) nfields() int {
if t.list == nil {
func (t *Type) Nfields() int {
if t.List == nil {
return 0;
}
nx, nt := 0, 0;
for i, n := 0, t.list.Len(); i < n; i++ {
if t.list.At(i).(*Expr).tok == Scanner.TYPE {
for i, n := 0, t.List.Len(); i < n; i++ {
if t.List.At(i).(*Expr).Tok == Scanner.TYPE {
nt++;
} else {
nx++;
......@@ -349,10 +349,10 @@ func (t *Type) nfields() int {
}
// requires complete Type.pos access
// requires complete Type.Pos access
export func NewTypeExpr(typ *Type) *Expr {
obj := NewObject(typ.pos, TYPE, "");
obj.typ = typ;
obj := NewObject(typ.Pos, TYPE, "");
obj.Typ = typ;
return NewLit(Scanner.TYPE, obj);
}
......@@ -365,16 +365,16 @@ export var BadType = NewType(0, Scanner.ILLEGAL);
export type Stat struct {
Node;
init, post *Stat;
expr *Expr;
block *array.Array; end int; // block end position
decl *Decl;
Init, Post *Stat;
Expr *Expr;
Block *array.Array; End int; // block end position
Decl *Decl;
}
export func NewStat(pos, tok int) *Stat {
s := new(Stat);
s.pos, s.tok = pos, tok;
s.Pos, s.Tok = pos, tok;
return s;
}
......@@ -387,19 +387,19 @@ export var BadStat = NewStat(0, Scanner.ILLEGAL);
export type Decl struct {
Node;
exported bool;
ident *Expr; // nil for ()-style declarations
typ *Type;
val *Expr;
Exported bool;
Ident *Expr; // nil for ()-style declarations
Typ *Type;
Val *Expr;
// list of *Decl for ()-style declarations
// list of *Stat for func declarations (or nil for forward decl)
list *array.Array; end int;
List *array.Array; End int;
}
export func NewDecl(pos, tok int, exported bool) *Decl {
d := new(Decl);
d.pos, d.tok, d.exported = pos, tok, exported;
d.Pos, d.Tok, d.Exported = pos, tok, exported;
return d;
}
......@@ -411,28 +411,28 @@ export var BadDecl = NewDecl(0, Scanner.ILLEGAL, false);
// Program
export type Comment struct {
pos int;
text string;
Pos int;
Text string;
}
export func NewComment(pos int, text string) *Comment {
c := new(Comment);
c.pos, c.text = pos, text;
c.Pos, c.Text = pos, text;
return c;
}
export type Program struct {
pos int; // tok is Scanner.PACKAGE
ident *Expr;
decls *array.Array;
comments *array.Array;
Pos int; // tok is Scanner.PACKAGE
Ident *Expr;
Decls *array.Array;
Comments *array.Array;
}
export func NewProgram(pos int) *Program {
p := new(Program);
p.pos = pos;
p.Pos = pos;
return p;
}
......@@ -34,7 +34,7 @@ export type Flags struct {
}
type ErrorHandler struct {
type errorHandler struct {
filename string;
src string;
nerrors int;
......@@ -44,7 +44,7 @@ type ErrorHandler struct {
}
func (h *ErrorHandler) Init(filename, src string, columns bool) {
func (h *errorHandler) Init(filename, src string, columns bool) {
h.filename = filename;
h.src = src;
h.nerrors = 0;
......@@ -55,7 +55,7 @@ func (h *ErrorHandler) Init(filename, src string, columns bool) {
// Compute (line, column) information for a given source position.
func (h *ErrorHandler) LineCol(pos int) (line, col int) {
func (h *errorHandler) LineCol(pos int) (line, col int) {
line = 1;
lpos := 0;
......@@ -75,7 +75,7 @@ func (h *ErrorHandler) LineCol(pos int) (line, col int) {
}
func (h *ErrorHandler) ErrorMsg(pos int, msg string) {
func (h *errorHandler) ErrorMsg(pos int, msg string) {
print(h.filename, ":");
if pos >= 0 {
// print position
......@@ -97,7 +97,7 @@ func (h *ErrorHandler) ErrorMsg(pos int, msg string) {
}
func (h *ErrorHandler) Error(pos int, msg string) {
func (h *errorHandler) Error(pos int, msg string) {
// only report errors that are sufficiently far away from the previous error
// in the hope to avoid most follow-up errors
const errdist = 20;
......@@ -112,7 +112,7 @@ func (h *ErrorHandler) Error(pos int, msg string) {
}
func (h *ErrorHandler) Warning(pos int, msg string) {
func (h *errorHandler) Warning(pos int, msg string) {
panic("UNIMPLEMENTED");
}
......@@ -124,7 +124,7 @@ export func Compile(src_file string, flags *Flags) (*AST.Program, int) {
return nil, 1;
}
var err ErrorHandler;
var err errorHandler;
err.Init(src_file, src, flags.columns);
var scanner Scanner.Scanner;
......@@ -148,7 +148,7 @@ export func Compile(src_file string, flags *Flags) (*AST.Program, int) {
}
func FileExists(name string) bool {
func fileExists(name string) bool {
fd, err := OS.Open(name, OS.O_RDONLY, 0);
if err == nil {
fd.Close();
......@@ -158,7 +158,7 @@ func FileExists(name string) bool {
}
func AddDeps(globalset map [string] bool, wset *array.Array, src_file string, flags *Flags) {
func addDeps(globalset map [string] bool, wset *array.Array, src_file string, flags *Flags) {
dummy, found := globalset[src_file];
if !found {
globalset[src_file] = true;
......@@ -168,27 +168,27 @@ func AddDeps(globalset map [string] bool, wset *array.Array, src_file string, fl
return;
}
nimports := prog.decls.Len();
nimports := prog.Decls.Len();
if nimports > 0 {
print(src_file, ".6:\t");
localset := make(map [string] bool);
for i := 0; i < nimports; i++ {
decl := prog.decls.At(i).(*AST.Decl);
assert(decl.tok == Scanner.IMPORT && decl.val.tok == Scanner.STRING);
src := decl.val.obj.ident;
decl := prog.Decls.At(i).(*AST.Decl);
assert(decl.Tok == Scanner.IMPORT && decl.Val.Tok == Scanner.STRING);
src := decl.Val.Obj.Ident;
src = src[1 : len(src) - 1]; // strip "'s
// ignore files when they are seen a 2nd time
dummy, found := localset[src];
if !found {
localset[src] = true;
if FileExists(src + ".go") {
if fileExists(src + ".go") {
wset.Push(src);
print(" ", src, ".6");
} else if
FileExists(Platform.GOROOT + "/pkg/" + src + ".6") ||
FileExists(Platform.GOROOT + "/pkg/" + src + ".a") {
fileExists(Platform.GOROOT + "/pkg/" + src + ".6") ||
fileExists(Platform.GOROOT + "/pkg/" + src + ".a") {
} else {
// TODO should collect these and print later
......@@ -207,6 +207,6 @@ export func ComputeDeps(src_file string, flags *Flags) {
wset := array.New(0);
wset.Push(src_file);
for wset.Len() > 0 {
AddDeps(globalset, wset, wset.Pop().(string), flags);
addDeps(globalset, wset, wset.Pop().(string), flags);
}
}
This diff is collapsed.
......@@ -17,7 +17,7 @@ export var
USER string;
func GetEnv(key string) string {
func getEnv(key string) string {
n := len(key);
for i := 0; i < sys.envc(); i++ {
v := sys.envv(i);
......@@ -30,10 +30,10 @@ func GetEnv(key string) string {
func init() {
GOARCH = GetEnv("GOARCH");
GOOS = GetEnv("GOOS");
GOROOT = GetEnv("GOROOT");
USER = GetEnv("USER");
GOARCH = getEnv("GOARCH");
GOOS = getEnv("GOOS");
GOROOT = getEnv("GOROOT");
USER = getEnv("USER");
}
......@@ -42,13 +42,13 @@ func init() {
export const (
MAGIC_obj_file = "@gri-go.7@v0"; // make it clear that it cannot be a source file
src_file_ext = ".go";
obj_file_ext = ".7";
Src_file_ext = ".go";
Obj_file_ext = ".7";
)
export func ReadObjectFile(filename string) (data string, ok bool) {
data, ok = sys.readfile(filename + obj_file_ext);
data, ok = sys.readfile(filename + Obj_file_ext);
magic := MAGIC_obj_file; // TODO remove once len(constant) works
if ok && len(data) >= len(magic) && data[0 : len(magic)] == magic {
return data, ok;
......@@ -58,13 +58,13 @@ export func ReadObjectFile(filename string) (data string, ok bool) {
export func ReadSourceFile(name string) (data string, ok bool) {
name = Utils.TrimExt(name, src_file_ext) + src_file_ext;
name = Utils.TrimExt(name, Src_file_ext) + Src_file_ext;
data, ok = sys.readfile(name);
return data, ok;
}
export func WriteObjectFile(name string, data string) bool {
name = Utils.TrimExt(Utils.BaseName(name), src_file_ext) + obj_file_ext;
name = Utils.TrimExt(Utils.BaseName(name), Src_file_ext) + Obj_file_ext;
return sys.writefile(name, data);
}
......@@ -29,7 +29,7 @@ func init() {
}
func Usage() {
func usage() {
print("usage: pretty { flags } { files }\n");
Flag.PrintDefaults();
sys.exit(0);
......@@ -40,7 +40,7 @@ func main() {
Flag.Parse();
if Flag.NFlag() == 0 && Flag.NArg() == 0 {
Usage();
usage();
}
// process files
......
This diff is collapsed.
This diff is collapsed.
......@@ -4,7 +4,7 @@
package main
type Proto struct {
export type Proto struct {
a int "a tag";
b, c, d *Proto "bcd" "tag";
*Proto "proto tag"
......
......@@ -11,7 +11,7 @@ import (
)
const /* enum1 */ (
export const /* enum1 */ (
EnumTag0 = iota;
EnumTag1;
EnumTag2;
......@@ -32,10 +32,10 @@ const /* enum2 */ (
)
type S struct {}
export type S struct {}
type T struct {
export type T struct {
x, y int;
s string;
next_t *T
......@@ -43,7 +43,7 @@ type T struct {
var (
A = 5;
aa = 5;
u, v, w int = 0, 0, 0;
foo = "foo";
fixed_array0 = [10]int{};
......@@ -54,7 +54,7 @@ var (
var (
// Unicode identifiers
ä, ö, ü, Á, Ø, Å, ƒ, ß int;
ä, ö, ü, ƒ, ß int;
)
......@@ -105,24 +105,24 @@ func f3(a *[]int, m map[string] int) {
}
println("A3");
for i : x := range a {
for i, x := range a {
println(i, x);
}
println("M1");
for i range m {
for i := range m {
println(i);
}
println("M2");
for i, x range m {
for i, x := range m {
println(i, x);
}
println("M3");
var i string;
var x int;
for i : x = range m {
for i, x = range m {
println(i, x);
}
}
......
......@@ -10,6 +10,7 @@ TMP3=test_tmp3.go
COUNT=0
count() {
#echo $1
let COUNT=$COUNT+1
let M=$COUNT%10
if [ $M == 0 ]; then
......@@ -25,7 +26,7 @@ apply1() {
# files with errors (skip them)
method1.go | selftest1.go | func3.go | bug014.go | bug029.go | bug032.go | bug050.go | \
bug068.go | bug088.go | bug083.go | bug106.go | bug125.go | bug126.go ) ;;
* ) $1 $2; count ;;
* ) $1 $2; count $F;;
esac
}
......@@ -130,7 +131,7 @@ if [ $? != 0 ]; then
echo "Error (selftest1): pretty -t selftest1.go"
exit 1
fi
count
count selftest1.go
# run over all .go files
......
......@@ -11,13 +11,13 @@ import (
)
type State struct {
type state struct {
// setup
err Scanner.ErrorHandler;
}
func (s *State) Init(err Scanner.ErrorHandler) {
func (s *state) Init(err Scanner.ErrorHandler) {
s.err = err;
}
......@@ -42,27 +42,27 @@ func assert(pred bool) {
}
func (s *State) Error(pos int, msg string) {
func (s *state) Error(pos int, msg string) {
s.err.Error(pos, msg);
}
// ----------------------------------------------------------------------------
func (s *State) CheckType() {
func (s *state) CheckType() {
}
func (s *State) CheckDeclaration(d *AST.Decl) {
if d.tok != Scanner.FUNC && d.list != nil {
func (s *state) CheckDeclaration(d *AST.Decl) {
if d.Tok != Scanner.FUNC && d.List != nil {
// group of parenthesized declarations
for i := 0; i < d.list.Len(); i++ {
s.CheckDeclaration(d.list.At(i).(*AST.Decl))
for i := 0; i < d.List.Len(); i++ {
s.CheckDeclaration(d.List.At(i).(*AST.Decl))
}
} else {
// single declaration
switch d.tok {
switch d.Tok {
case Scanner.IMPORT:
case Scanner.EXPORT:
case Scanner.CONST:
......@@ -76,9 +76,9 @@ func (s *State) CheckDeclaration(d *AST.Decl) {
}
func (s *State) CheckProgram(p *AST.Program) {
for i := 0; i < p.decls.Len(); i++ {
s.CheckDeclaration(p.decls.At(i).(*AST.Decl));
func (s *state) CheckProgram(p *AST.Program) {
for i := 0; i < p.Decls.Len(); i++ {
s.CheckDeclaration(p.Decls.At(i).(*AST.Decl));
}
}
......@@ -86,7 +86,7 @@ func (s *State) CheckProgram(p *AST.Program) {
// ----------------------------------------------------------------------------
export func CheckProgram(err Scanner.ErrorHandler, p *AST.Program) {
var s State;
var s state;
s.Init(err);
s.CheckProgram(p);
}
......@@ -11,113 +11,113 @@ import (
export var (
scope *AST.Scope;
types array.Array;
Scope *AST.Scope;
Types array.Array;
// internal types
void_typ,
bad_typ,
nil_typ,
Void_typ,
Bad_typ,
Nil_typ,
// basic types
bool_typ,
uint8_typ,
uint16_typ,
uint32_typ,
uint64_typ,
int8_typ,
int16_typ,
int32_typ,
int64_typ,
float32_typ,
float64_typ,
float80_typ,
string_typ,
integer_typ,
Bool_typ,
Uint8_typ,
Uint16_typ,
Uint32_typ,
Uint64_typ,
Int8_typ,
Int16_typ,
Int32_typ,
Int64_typ,
Float32_typ,
Float64_typ,
Float80_typ,
String_typ,
Integer_typ,
// convenience types
byte_typ,
uint_typ,
int_typ,
float_typ,
uintptr_typ *AST.Type;
Byte_typ,
Uint_typ,
Int_typ,
Float_typ,
Uintptr_typ *AST.Type;
true_obj,
false_obj,
iota_obj,
nil_obj *AST.Object;
True_obj,
False_obj,
Iota_obj,
Nil_obj *AST.Object;
)
func DeclObj(kind int, ident string, typ *AST.Type) *AST.Object {
func declObj(kind int, ident string, typ *AST.Type) *AST.Object {
obj := AST.NewObject(-1 /* no source pos */, kind, ident);
obj.typ = typ;
if kind == AST.TYPE && typ.obj == nil {
typ.obj = obj; // set primary type object
obj.Typ = typ;
if kind == AST.TYPE && typ.Obj == nil {
typ.Obj = obj; // set primary type object
}
scope.Insert(obj);
Scope.Insert(obj);
return obj
}
func DeclType(form int, ident string, size int) *AST.Type {
func declType(form int, ident string, size int) *AST.Type {
typ := AST.NewType(-1 /* no source pos */, form);
typ.size = size;
return DeclObj(AST.TYPE, ident, typ).typ;
typ.Size = size;
return declObj(AST.TYPE, ident, typ).Typ;
}
func Register(typ *AST.Type) *AST.Type {
typ.ref = types.Len();
types.Push(typ);
func register(typ *AST.Type) *AST.Type {
typ.Ref = Types.Len();
Types.Push(typ);
return typ;
}
func init() {
scope = AST.NewScope(nil); // universe has no parent
types.Init(32);
Scope = AST.NewScope(nil); // universe has no parent
Types.Init(32);
// Interal types
void_typ = AST.NewType(-1 /* no source pos */, AST.VOID);
AST.Universe_void_typ = void_typ;
bad_typ = AST.NewType(-1 /* no source pos */, AST.BADTYPE);
nil_typ = AST.NewType(-1 /* no source pos */, AST.NIL);
Void_typ = AST.NewType(-1 /* no source pos */, AST.VOID);
AST.Universe_void_typ = Void_typ;
Bad_typ = AST.NewType(-1 /* no source pos */, AST.BADTYPE);
Nil_typ = AST.NewType(-1 /* no source pos */, AST.NIL);
// Basic types
bool_typ = Register(DeclType(AST.BOOL, "bool", 1));
uint8_typ = Register(DeclType(AST.UINT, "uint8", 1));
uint16_typ = Register(DeclType(AST.UINT, "uint16", 2));
uint32_typ = Register(DeclType(AST.UINT, "uint32", 4));
uint64_typ = Register(DeclType(AST.UINT, "uint64", 8));
int8_typ = Register(DeclType(AST.INT, "int8", 1));
int16_typ = Register(DeclType(AST.INT, "int16", 2));
int32_typ = Register(DeclType(AST.INT, "int32", 4));
int64_typ = Register(DeclType(AST.INT, "int64", 8));
float32_typ = Register(DeclType(AST.FLOAT, "float32", 4));
float64_typ = Register(DeclType(AST.FLOAT, "float64", 8));
float80_typ = Register(DeclType(AST.FLOAT, "float80", 10));
string_typ = Register(DeclType(AST.STRING, "string", 8));
integer_typ = Register(DeclType(AST.INTEGER, "integer", 8));
Bool_typ = register(declType(AST.BOOL, "bool", 1));
Uint8_typ = register(declType(AST.UINT, "uint8", 1));
Uint16_typ = register(declType(AST.UINT, "uint16", 2));
Uint32_typ = register(declType(AST.UINT, "uint32", 4));
Uint64_typ = register(declType(AST.UINT, "uint64", 8));
Int8_typ = register(declType(AST.INT, "int8", 1));
Int16_typ = register(declType(AST.INT, "int16", 2));
Int32_typ = register(declType(AST.INT, "int32", 4));
Int64_typ = register(declType(AST.INT, "int64", 8));
Float32_typ = register(declType(AST.FLOAT, "float32", 4));
Float64_typ = register(declType(AST.FLOAT, "float64", 8));
Float80_typ = register(declType(AST.FLOAT, "float80", 10));
String_typ = register(declType(AST.STRING, "string", 8));
Integer_typ = register(declType(AST.INTEGER, "integer", 8));
// All but 'byte' should be platform-dependent, eventually.
byte_typ = Register(DeclType(AST.UINT, "byte", 1));
uint_typ = Register(DeclType(AST.UINT, "uint", 4));
int_typ = Register(DeclType(AST.INT, "int", 4));
float_typ = Register(DeclType(AST.FLOAT, "float", 4));
uintptr_typ = Register(DeclType(AST.UINT, "uintptr", 8));
Byte_typ = register(declType(AST.UINT, "byte", 1));
Uint_typ = register(declType(AST.UINT, "uint", 4));
Int_typ = register(declType(AST.INT, "int", 4));
Float_typ = register(declType(AST.FLOAT, "float", 4));
Uintptr_typ = register(declType(AST.UINT, "uintptr", 8));
// Predeclared constants
true_obj = DeclObj(AST.CONST, "true", bool_typ);
false_obj = DeclObj(AST.CONST, "false", bool_typ);
iota_obj = DeclObj(AST.CONST, "iota", int_typ);
nil_obj = DeclObj(AST.CONST, "nil", nil_typ);
True_obj = declObj(AST.CONST, "true", Bool_typ);
False_obj = declObj(AST.CONST, "false", Bool_typ);
Iota_obj = declObj(AST.CONST, "iota", Int_typ);
Nil_obj = declObj(AST.CONST, "nil", Nil_typ);
// Builtin functions
DeclObj(AST.BUILTIN, "len", void_typ);
DeclObj(AST.BUILTIN, "new", void_typ);
DeclObj(AST.BUILTIN, "panic", void_typ);
DeclObj(AST.BUILTIN, "print", void_typ);
declObj(AST.BUILTIN, "len", Void_typ);
declObj(AST.BUILTIN, "new", Void_typ);
declObj(AST.BUILTIN, "panic", Void_typ);
declObj(AST.BUILTIN, "print", Void_typ);
// scope.Print();
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment