5 using System.Collections.Generic;
6 using CodeGeneration.ExceptionManagement;
7 namespace CodeGeneration.Operations {
14 internal class CGConvertToOperation<T> : CGTypeSystemOperation where T : ILCodeGenerator {
19 private T codeGenerator;
26 public CGConvertToOperation(
TypeExpression secondTypeExpression, T codeGenerator,
int indent) {
27 this.secondTypeExpression = secondTypeExpression;
28 this.codeGenerator = codeGenerator;
34 public override object Exec(
CharType c,
object arg) {
37 this.codeGenerator.convToDouble(this.indent);
40 return c.
AcceptOperation(
new CGToStringOperation<ILCodeGenerator>(
this.codeGenerator,
this.indent),
true);
45 public override object Exec(
DoubleType d,
object arg) {
48 return d.AcceptOperation(
new CGToStringOperation<ILCodeGenerator>(this.codeGenerator, this.indent),
true);
53 public override object Exec(
IntType i,
object arg) {
55 return i.AcceptOperation(
new CGToStringOperation<ILCodeGenerator>(this.codeGenerator, this.indent),
true);
59 this.codeGenerator.convToDouble(this.indent);
68 public override object Exec(
StringType s,
object arg) {
74 public override object Exec(
TypeVariable t,
object arg) {
76 ReportError(
string.Format(
"Cannot make convertions from type {0} to {1}.", t.
FullName,
this.secondTypeExpression.FullName));
79 return t.Substitution.AcceptOperation(
this, null);
override string FullName
The full name in type variables is calculated just in time
virtual bool HasFreshVariable()
To know if it is a type variable with no substitution
Represent a character type.
Abstract class that represents all different types.
Represents a generic type expression
Represent a integer type.
Represents a double type.
override object AcceptOperation(TypeSystemOperation op, object arg)