mirror of
https://github.com/dbalsom/x86_microcode.git
synced 2026-06-09 13:04:17 +03:00
72 lines
1.8 KiB
C++
72 lines
1.8 KiB
C++
#include "alfe/main.h"
|
|
|
|
#ifndef INCLUDED_STRING_FUNCTIONS_H
|
|
#define INCLUDED_STRING_FUNCTIONS_H
|
|
|
|
#include "alfe/function.h"
|
|
|
|
class AddStringString : public Nullary<Function, AddStringString>
|
|
{
|
|
public:
|
|
class Body : public Nullary::Body
|
|
{
|
|
public:
|
|
Value evaluate(List<Value> arguments, Span span) const
|
|
{
|
|
auto i = arguments.begin();
|
|
String l = i->value<String>();
|
|
++i;
|
|
return Value(l + i->value<String>());
|
|
}
|
|
Identifier identifier() const { return OperatorPlus(); }
|
|
FunctionType type() const
|
|
{
|
|
return FunctionType(StringType(), StringType(), StringType());
|
|
}
|
|
};
|
|
};
|
|
|
|
class MultiplyIntegerString : public Nullary<Function, MultiplyIntegerString>
|
|
{
|
|
public:
|
|
class Body : public Nullary::Body
|
|
{
|
|
public:
|
|
Value evaluate(List<Value> arguments, Span span) const
|
|
{
|
|
auto i = arguments.begin();
|
|
int l = i->value<int>();
|
|
++i;
|
|
return Value(l*i->value<String>());
|
|
}
|
|
Identifier identifier() const { return OperatorStar(); }
|
|
FunctionType type() const
|
|
{
|
|
return FunctionType(StringType(), IntegerType(), StringType());
|
|
}
|
|
};
|
|
};
|
|
|
|
class MultiplyStringInteger : public Nullary<Function, MultiplyStringInteger>
|
|
{
|
|
public:
|
|
class Body : public Nullary::Body
|
|
{
|
|
public:
|
|
Value evaluate(List<Value> arguments, Span span) const
|
|
{
|
|
auto i = arguments.begin();
|
|
String l = i->value<String>();
|
|
++i;
|
|
return Value(l*i->value<int>());
|
|
}
|
|
Identifier identifier() const { return OperatorStar(); }
|
|
FunctionType type() const
|
|
{
|
|
return FunctionType(StringType(), StringType(), IntegerType());
|
|
}
|
|
};
|
|
};
|
|
|
|
#endif // INCLUDED_STRING_FUNCTIONS_H
|