1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72
|
#pragma once
#include "Compiler/Template.h"
#include "Compiler/Function.h"
namespace storm {
STORM_PKG(core.lang);
/**
* Provide a system-wide toS function for value types that only implement toS(StrBuf).
*/
class ToSTemplate : public Template {
STORM_CLASS;
public:
// Create.
STORM_CTOR ToSTemplate();
virtual MAYBE(Named *) STORM_FN generate(SimplePart *part);
};
/**
* Function generated.
*/
class ToSFunction : public Function {
STORM_CLASS;
public:
// Create. Pass the 'toS(StrBuf)' to use.
STORM_CTOR ToSFunction(Function *fn);
protected:
// Detect if the target type gets its own toS function.
void STORM_FN notifyAdded(NameSet *to, Named *added);
private:
// Output function to use.
Function *use;
// Generate code.
CodeGen *CODECALL create();
};
/**
* Provide a system-wide << function for value types that provide eiter toS() or toS(StrBuf).
*/
class OutputOperatorTemplate : public Template {
STORM_CLASS;
public:
// Create.
STORM_CTOR OutputOperatorTemplate();
virtual MAYBE(Named *) STORM_FN generate(SimplePart *part);
};
/**
* Output operator that is generated.
*/
class OutputOperator : public Function {
STORM_CLASS;
public:
// Create. Pass the 'toS()' or 'toS(StrBuf)' to use.
STORM_CTOR OutputOperator(Function *fn);
private:
// Function to use.
Function *use;
// Generate code.
CodeGen *CODECALL create();
};
}
|