2
0
mirror of https://github.com/esiur/esiur-dart.git synced 2026-04-04 10:18:20 +00:00
Files
esiur-dart/lib/src/Resource/Template/FunctionTemplate.dart
2022-03-12 16:21:29 +03:00

44 lines
1.1 KiB
Dart

import 'MemberTemplate.dart';
import '../../Data/DC.dart';
import '../../Data/BinaryList.dart';
import 'TypeTemplate.dart';
import 'MemberType.dart';
import 'ArgumentTemplate.dart';
import '../../Data/RepresentationType.dart';
class FunctionTemplate extends MemberTemplate {
String? expansion;
// bool isVoid;
List<ArgumentTemplate> arguments;
RepresentationType returnType;
DC compose() {
var name = super.compose();
var bl = new BinaryList()
..addUint8(name.length)
..addDC(name)
..addDC(returnType.compose())
..addUint8(arguments.length);
for (var i = 0; i < arguments.length; i++) bl.addDC(arguments[i].compose());
if (expansion != null) {
var exp = DC.stringToBytes(expansion as String);
bl
..addInt32(exp.length)
..addDC(exp);
bl.insertUint8(0, inherited ? 0x90 : 0x10);
} else
bl.insertUint8(0, inherited ? 0x80 : 0x0);
return bl.toDC();
}
FunctionTemplate(TypeTemplate template, int index, String name,
bool inherited, this.arguments, this.returnType,
[this.expansion = null])
: super(template, index, name, inherited) {}
}