type-section-rework #6
| @ -12,25 +12,55 @@ data ro cIntegerPointer:{Int} | |||||||
| data ro dMutIntegerPointer:{Int}:mut | data ro dMutIntegerPointer:{Int}:mut | ||||||
| data ro eIntegerArray16:Int:16 | data ro eIntegerArray16:Int:16 | ||||||
| data ro fIntegerArrayVariable:{Int ..} | data ro fIntegerArrayVariable:{Int ..} | ||||||
| data ro gIntegerArrayInitialized:Int:16:< | data ro gIntegerArrayInitialized:Int:16: | ||||||
| 	3948 293 293049 948 912 | 	< | ||||||
| 	340 0 2304 0 4785 92> | 	3948 | ||||||
| data ro jObject:Obj:( | 	293 | ||||||
|  | 	293049 | ||||||
|  | 	948 | ||||||
|  | 	912 | ||||||
|  | 	340 | ||||||
|  | 	0 | ||||||
|  | 	2304 | ||||||
|  | 	0 | ||||||
|  | 	4785 | ||||||
|  | 	92 | ||||||
|  | 	> | ||||||
|  | data ro jObject:Obj: | ||||||
|  | 	( | ||||||
| 	.this:<324> | 	.this:<324> | ||||||
| 	.that:<324>) | 	.that:<324> | ||||||
| data ro kNestedObject:Obj:( | 	) | ||||||
|  | data ro kNestedObject:Obj: | ||||||
|  | 	( | ||||||
| 	.ro newMember:Int:<9023> | 	.ro newMember:Int:<9023> | ||||||
| 	.this:( | 	.this: | ||||||
|  | 		( | ||||||
| 		.bird0:<324> | 		.bird0:<324> | ||||||
| 		.bird1:<"hello world">) | 		.bird1:<"hello world"> | ||||||
| 	.that:( | 		) | ||||||
|  | 	.that: | ||||||
|  | 		( | ||||||
| 		.bird2:<123.8439> | 		.bird2:<123.8439> | ||||||
| 		.bird3:<9328.21348239>)) | 		.bird3:<9328.21348239> | ||||||
|  | 		) | ||||||
|  | 	) | ||||||
| data ro lMutIntegerArray16:Int:16:mut | data ro lMutIntegerArray16:Int:16:mut | ||||||
| data ro mExternalData:Int:8 | data ro mExternalData:Int:8 | ||||||
| 	external | 	external | ||||||
| data ro nIntegerArrayInitialized:Int:16:mut:< | data ro nIntegerArrayInitialized:Int:16:mut: | ||||||
| 	3948 293 293049 948 912 | 	< | ||||||
| 	340 0 2304 0 4785 92> | 	3948 | ||||||
|  | 	293 | ||||||
|  | 	293049 | ||||||
|  | 	948 | ||||||
|  | 	912 | ||||||
|  | 	340 | ||||||
|  | 	0 | ||||||
|  | 	2304 | ||||||
|  | 	0 | ||||||
|  | 	4785 | ||||||
|  | 	92 | ||||||
|  | 	> | ||||||
| `, test) | `, test) | ||||||
| } | } | ||||||
|  | |||||||
| @ -66,12 +66,22 @@ func (identifier Identifier) ToString () (output string) { | |||||||
| 	return | 	return | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| func (what Type) ToString () (output string) { | func (values ObjectDefaultValues) ToString (indent int) (output string) { | ||||||
|  | 	 | ||||||
|  | 	return | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | func (values ArrayDefaultValues) ToString (indent int) (output string) { | ||||||
|  | 	 | ||||||
|  | 	return | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | func (what Type) ToString (indent int) (output string) { | ||||||
| 	if what.kind == TypeKindBasic { | 	if what.kind == TypeKindBasic { | ||||||
| 		output += what.name.ToString() | 		output += what.name.ToString() | ||||||
| 	} else { | 	} else { | ||||||
| 		output += "{" | 		output += "{" | ||||||
| 		output += what.points.ToString() | 		output += what.points.ToString(indent) | ||||||
| 
 | 
 | ||||||
| 		if what.kind == TypeKindVariableArray { | 		if what.kind == TypeKindVariableArray { | ||||||
| 			output += " .." | 			output += " .." | ||||||
| @ -88,13 +98,38 @@ func (what Type) ToString () (output string) { | |||||||
| 		output += ":mut" | 		output += ":mut" | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	// TODO: print out default value | 	if what.members != nil { | ||||||
|  | 		output += ":(" | ||||||
|  | 		for _, member := range what.members { | ||||||
|  | 			output += doIndent ( | ||||||
|  | 				indent, | ||||||
|  | 				"\n" + member.ToString(indent + 1)) | ||||||
|  | 		} | ||||||
|  | 		output += ")" | ||||||
|  | 	} | ||||||
|  | 
 | ||||||
|  | 	defaultValueKind := what.defaultValue.kind | ||||||
|  | 	if defaultValueKind != ArgumentKindNil { | ||||||
|  | 		isComplexDefaultValue := | ||||||
|  | 			defaultValueKind == ArgumentKindObjectDefaultValues || | ||||||
|  | 			defaultValueKind == ArgumentKindArrayDefaultValues | ||||||
|  | 		 | ||||||
|  | 		if isComplexDefaultValue { | ||||||
|  | 			output += ":\n" | ||||||
|  | 			output += what.defaultValue.ToString(indent, true) | ||||||
|  | 		} | ||||||
|  | 	} | ||||||
|  | 
 | ||||||
|  | 	if what.defaultValue.kind == ArgumentKindObjectDefaultValues { | ||||||
|  | 	} else if what.defaultValue.kind != ArgumentKindNil { | ||||||
|  | 		output += ":<" + what.defaultValue.ToString(indent, true) + ">" | ||||||
|  | 	} | ||||||
| 	return | 	return | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| func (declaration Declaration) ToString () (output string) { | func (declaration Declaration) ToString (indent int) (output string) { | ||||||
| 	output += declaration.name + ":" | 	output += declaration.name + ":" | ||||||
| 	output += declaration.what.ToString() | 	output += declaration.what.ToString(indent) | ||||||
| 	return | 	return | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| @ -112,8 +147,13 @@ func (argument Argument) ToString (indent int, breakLine bool) (output string) { | |||||||
| 				indent, | 				indent, | ||||||
| 				breakLine) | 				breakLine) | ||||||
| 	 | 	 | ||||||
| 	case ArgumentKindArrayDefaultValues, ArgumentKindObjectDefaultValues: | 	case ArgumentKindObjectDefaultValues: | ||||||
| 		output += "DEFAULT VALUES IN WRONG PLACE" | 		output += argument.value.(ObjectDefaultValues). | ||||||
|  | 				ToString(indent) | ||||||
|  | 	 | ||||||
|  | 	case ArgumentKindArrayDefaultValues: | ||||||
|  | 		output += argument.value.(ArrayDefaultValues). | ||||||
|  | 				ToString(indent) | ||||||
| 	 | 	 | ||||||
| 	case ArgumentKindIdentifier: | 	case ArgumentKindIdentifier: | ||||||
| 		output += doIndent ( | 		output += doIndent ( | ||||||
| @ -124,7 +164,7 @@ func (argument Argument) ToString (indent int, breakLine bool) (output string) { | |||||||
| 	case ArgumentKindDeclaration: | 	case ArgumentKindDeclaration: | ||||||
| 		output += doIndent ( | 		output += doIndent ( | ||||||
| 			indent, | 			indent, | ||||||
| 			argument.value.(Declaration).ToString()) | 			argument.value.(Declaration).ToString(indent)) | ||||||
| 		if breakLine { output += "\n" } | 		if breakLine { output += "\n" } | ||||||
| 	 | 	 | ||||||
| 	case ArgumentKindInt, ArgumentKindUInt, ArgumentKindFloat: | 	case ArgumentKindInt, ArgumentKindUInt, ArgumentKindFloat: | ||||||
| @ -222,7 +262,7 @@ func (section DataSection) ToString (indent int) (output string) { | |||||||
| 		"type ", | 		"type ", | ||||||
| 		section.permission.ToString(), " ", | 		section.permission.ToString(), " ", | ||||||
| 		section.name, ":", | 		section.name, ":", | ||||||
| 		section.what.ToString(), "\n") | 		section.what.ToString(indent), "\n") | ||||||
| 	return | 	return | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| @ -231,7 +271,7 @@ func (member TypeMember) ToString (indent int) (output string) { | |||||||
| 	 | 	 | ||||||
| 	output += member.permission.ToString() + " " | 	output += member.permission.ToString() + " " | ||||||
| 	output += member.name + ":" | 	output += member.name + ":" | ||||||
| 	output += member.what.ToString() | 	output += member.what.ToString(indent) | ||||||
| 
 | 
 | ||||||
| 	if member.bitWidth > 0 { | 	if member.bitWidth > 0 { | ||||||
| 		output += fmt.Sprint(" & ", member.bitWidth) | 		output += fmt.Sprint(" & ", member.bitWidth) | ||||||
| @ -248,7 +288,7 @@ func (section TypeSection) ToString (indent int) (output string) { | |||||||
| 		"type ", | 		"type ", | ||||||
| 		section.permission.ToString(), " ", | 		section.permission.ToString(), " ", | ||||||
| 		section.name, ":", | 		section.name, ":", | ||||||
| 		section.what.ToString(), "\n") | 		section.what.ToString(indent), "\n") | ||||||
| 	return | 	return | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| @ -259,7 +299,7 @@ func (section EnumSection) ToString (indent int) (output string) { | |||||||
| 		"enum ", | 		"enum ", | ||||||
| 		section.permission.ToString(), " ", | 		section.permission.ToString(), " ", | ||||||
| 		section.name, ":", | 		section.name, ":", | ||||||
| 		section.what.ToString(), "\n") | 		section.what.ToString(indent), "\n") | ||||||
| 
 | 
 | ||||||
| 	for _, member := range section.members { | 	for _, member := range section.members { | ||||||
| 		output += doIndent(indent + 1, member.name) | 		output += doIndent(indent + 1, member.name) | ||||||
| @ -300,11 +340,11 @@ func (behavior FaceBehavior) ToString (indent int) (output string) { | |||||||
| 	output += doIndent(indent, behavior.name, "\n") | 	output += doIndent(indent, behavior.name, "\n") | ||||||
| 	 | 	 | ||||||
| 	for _, inputItem := range behavior.inputs { | 	for _, inputItem := range behavior.inputs { | ||||||
| 		output += doIndent(indent + 1, "> ", inputItem.ToString(), "\n") | 		output += doIndent(indent + 1, "> ", inputItem.ToString(indent), "\n") | ||||||
| 	} | 	} | ||||||
| 	 | 	 | ||||||
| 	for _, outputItem := range behavior.outputs { | 	for _, outputItem := range behavior.outputs { | ||||||
| 		output += doIndent(indent + 1, "< ", outputItem.ToString(), "\n") | 		output += doIndent(indent + 1, "< ", outputItem.ToString(indent), "\n") | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	return | 	return | ||||||
| @ -368,7 +408,7 @@ func (block Block) ToString (indent int) (output string) { | |||||||
| func (funcOutput FuncOutput) ToString (indent int) (output string) { | func (funcOutput FuncOutput) ToString (indent int) (output string) { | ||||||
| 	output += doIndent ( | 	output += doIndent ( | ||||||
| 		indent + 1, | 		indent + 1, | ||||||
| 		"< ", funcOutput.Declaration.ToString(), "\n") | 		"< ", funcOutput.Declaration.ToString(indent), "\n") | ||||||
| 	return | 	return | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| @ -382,11 +422,11 @@ func (section FuncSection) ToString (indent int) (output string) { | |||||||
| 	if section.receiver != nil { | 	if section.receiver != nil { | ||||||
| 		output += doIndent ( | 		output += doIndent ( | ||||||
| 			indent + 1, | 			indent + 1, | ||||||
| 			"@ ", section.receiver.ToString(), "\n") | 			"@ ", section.receiver.ToString(indent), "\n") | ||||||
| 	} | 	} | ||||||
| 	 | 	 | ||||||
| 	for _, inputItem := range section.inputs { | 	for _, inputItem := range section.inputs { | ||||||
| 		output += doIndent(indent + 1, "> ", inputItem.ToString(), "\n") | 		output += doIndent(indent + 1, "> ", inputItem.ToString(indent), "\n") | ||||||
| 	} | 	} | ||||||
| 	 | 	 | ||||||
| 	for _, outputItem := range section.outputs { | 	for _, outputItem := range section.outputs { | ||||||
|  | |||||||
| @ -285,6 +285,8 @@ func (parser *ParsingOperation) parseObjectNewMember () ( | |||||||
| 	if err != nil { return } | 	if err != nil { return } | ||||||
| 	member.what, err = parser.parseType() | 	member.what, err = parser.parseType() | ||||||
| 	if err != nil { return } | 	if err != nil { return } | ||||||
|  | 
 | ||||||
|  | 	// TODO: get bit width | ||||||
| 	 | 	 | ||||||
| 	return | 	return | ||||||
| } | } | ||||||
|  | |||||||
		Reference in New Issue
	
	Block a user