visitFuncDecl method

  1. @override
String visitFuncDecl(
  1. FuncDecl stmt
)
override

Implementation

@override
String visitFuncDecl(FuncDecl stmt) {
  final output = StringBuffer();
  if (stmt.isExternal) {
    output.write('${_lexicon.kExternal} ');
  }
  if (stmt.isStatic) {
    output.write('${_lexicon.kStatic} ');
  }
  switch (stmt.category) {
    case FunctionCategory.normal:
    case FunctionCategory.method:
    case FunctionCategory.literal:
      output.write(_lexicon.kFun);
      break;
    case FunctionCategory.constructor:
      output.write(_lexicon.kFactory);
      break;
    case FunctionCategory.factoryConstructor:
      output.write(_lexicon.kFactory);
      break;
    case FunctionCategory.getter:
      output.write(_lexicon.kGet);
      break;
    case FunctionCategory.setter:
      output.write(_lexicon.kSet);
      break;
    default:
      break;
  }
  if (stmt.externalTypeId != null) {
    output.write(
        ' ${_lexicon.externalFunctionTypeDefStart}${stmt.externalTypeId}${_lexicon.externalFunctionTypeDefEnd}');
  }
  if (stmt.id != null) {
    output.write(' ${stmt.id!.id}');
  }
  final paramDeclString = printParamDecls(stmt.paramDecls);
  output.write('$paramDeclString ');
  if (stmt.returnType != null) {
    output.write('${_lexicon.functionReturnTypeIndicator} ');
    final returnTypeString = formatAST(stmt.returnType!);
    output.write('$returnTypeString ');
  } else if (stmt.redirectingCtorCallExpr != null) {
    output.write('${_lexicon.constructorInitializationListIndicator} ');
    final referCtorString =
        visitReferConstructCallExpr(stmt.redirectingCtorCallExpr!);
    output.write('$referCtorString ');
  }
  if (stmt.definition != null) {
    final blockString = formatAST(stmt.definition!);
    output.write(blockString);
  }
  return output.toString();
}