//public override bool Equals(object obj) { // throw new InvalidProgramException("INTERNAL ERROR: Attempt to use type before it has been evaluated. (Equals)"); //} public override ITypeDef Resolve(ExecContext context, ref bool error) { if (name == "void") { return(IntrinsicTypeDefs.VOID); } ITypeDef def = context.GetTypeByName(name); if (null == def) { context.engine.LogCompileError(ParseErrorType.TypeNotFound, "Type '" + name + "' not found."); error = true; return(null); } if (null == _templateTypes) { if (_isConst && !def.IsConst()) { return(def.Clone(true)); } return(def); } // If we have template types, then we must be a TypeDef_Class. List <ITypeDef> genericTypes = new List <ITypeDef>(); for (int ii = 0; ii < _templateTypes.Count; ++ii) { genericTypes.Add(_templateTypes[ii].Resolve(context, ref error)); } if (error) { return(null); } //TypeDef_Class result = new TypeDef_Class(name, genericTypes, _isConst); TypeDef_Class result = TypeFactory.GetTypeDef_Class(name, genericTypes, _isConst); if (null == context.RegisterIfUnregisteredTemplate(result)) { error = true; } return(result); }
public static ITypeDef GetConstVersion(ITypeDef original) { if (original.IsConst()) { return(original); } string constName = original.GetName() + " const"; if (_typeRegistry.ContainsKey(constName)) { return(_typeRegistry[constName]); } ITypeDef result = original.Clone(true); _typeRegistry.Add(constName, result); return(result); }