private ProcScope CreateInterfaceNamespaceFunction(string name, int offset) { //Console.WriteLine(name); ProcScope cnfn = new ProcScope(name,cur_scope); cnfn.declaringUnit = root_scope; if (CanReadObject()) br.ReadInt32(); br.ReadBoolean();//ïðîïóñêàåì ôëàã - èíòåðôåéñíîñòè br.ReadInt32();//name index bool is_generic = br.ReadBoolean(); if (is_generic) { throw new NotSupportedException(); } if (br.ReadByte() == 1) { cnfn.return_type = GetTypeReference(); GetLocalVariable(cnfn); } int num_par = br.ReadInt32(); for (int i=0; i<num_par; i++) cnfn.parameters.Add(GetParameter(cnfn)); br.ReadInt32(); //namespace br.ReadInt32(); //attributes cnfn.is_forward = br.ReadBoolean(); cnfn.Complete(); AddMember(cnfn, offset); return cnfn; }
public static string GetDocumentation(ProcScope mi) { try { if (mi.declaringUnit != null) { CodeCompletionTools.XmlDoc xdoc = (CodeCompletionTools.XmlDoc)ht[mi.declaringUnit]; if (xdoc != null) { string s = ""; if (mi.declaringType != null) { if (!mi.is_constructor) s = GetNormalHint(xdoc.GetDocumentation("M:" + mi.declaringType.si.name + "." + mi.si.name + GetParamNames(mi), true)); else s = GetNormalHint(xdoc.GetDocumentation("M:" + mi.declaringType.si.name + ".#ctor" + GetParamNames(mi), true)); } else s = GetNormalHint(xdoc.GetDocumentation("M:" + mi.name + GetParamNames(mi), true)); return s; } } } catch(Exception e) { } return ""; }
private static string GetDelegateName(ProcScope value) { StringBuilder sb = new StringBuilder(); if (value.return_type != null) sb.Append("@function"); else sb.Append("@procedure"); sb.Append(GetParamNames(value)); if (value.return_type != null) sb.Append(":"+GetTypeName(value.return_type)); return sb.ToString(); }
public virtual TypeScope GetInstance(List<TypeScope> gen_args) { TypeScope ts = new TypeScope(this.kind, this.topScope, this.baseScope); ts.original_type = this; ts.loc = this.loc; for (int i = 0; i < gen_args.Count; i++) { ts.AddGenericParameter(gen_args[i].si.name); ts.AddGenericInstanciation(gen_args[i]); } ts.si.name = this.si.name; ts.documentation = this.documentation; ts.si.description = ts.GetDescription(); if (this.elementType != null) { ts.elementType = internalInstance(this.elementType, gen_args); } if (this.indexers != null && this.indexers.Count > 0) { ts.indexers = new List<TypeScope>(); for (int j = 0; j < this.indexers.Count; j++) ts.indexers.Add(internalInstance(this.indexers[j], gen_args)); } Hashtable procs = new Hashtable(); for (int i = 0; i < members.Count; i++) { SymScope ss = members[i]; ts.members.Add(ss); if (ss is ElementScope) { ElementScope es = ss as ElementScope; ElementScope new_es = new ElementScope(new SymInfo(es.si.name, es.si.kind, es.si.name), es.sc, ts); ts.members[i] = new_es; new_es.loc = es.loc; new_es.documentation = es.documentation; new_es.si.acc_mod = es.si.acc_mod; new_es.si.has_doc = es.si.has_doc; if (es.indexers != null && es.indexers.Count > 0) { new_es.indexers = new List<TypeScope>(); for (int j = 0; j < es.indexers.Count; j++) new_es.indexers.Add(internalInstance(es.indexers[j], gen_args)); } if (es.elementType != null) { new_es.elementType = internalInstance(es.elementType, gen_args); } new_es.sc = internalInstance(es.sc as TypeScope, gen_args); new_es.MakeDescription(); } else if (ss is ProcScope) { ProcScope ps = ss as ProcScope; ProcScope new_proc = new ProcScope(ps.si.name, ts, ps.is_constructor); procs[ps] = new_proc; new_proc.loc = ps.loc; new_proc.documentation = ps.documentation; new_proc.si.acc_mod = ps.si.acc_mod; new_proc.is_static = ps.is_static; new_proc.is_virtual = ps.is_virtual; new_proc.is_abstract = ps.is_abstract; new_proc.is_override = ps.is_override; new_proc.is_reintroduce = ps.is_reintroduce; ts.members[i] = new_proc; if (ps.parameters != null) for (int j = 0; j < ps.parameters.Count; j++) { ElementScope es = ps.parameters[j]; ElementScope es2 = new ElementScope(new SymInfo(es.si.name, es.si.kind, es.si.name), es.sc, new_proc); es2.loc = es.loc; es2.cnst_val = es.cnst_val; es2.si.acc_mod = es.si.acc_mod; es2.param_kind = es.param_kind; es2.sc = internalInstance(es.sc as TypeScope, gen_args); es2.MakeDescription(); new_proc.AddParameter(es2); } new_proc.return_type = internalInstance(ps.return_type, gen_args); new_proc.Complete(); } } foreach (ProcScope ps in procs.Keys) { ProcScope new_ps = procs[ps] as ProcScope; if (ps.nextProc != null && procs[ps.nextProc] != null) { new_ps.nextProc = procs[ps.nextProc] as ProcScope; } } return ts; }
public override bool IsParamsEquals(ProcScope ps) { if (ps is CompiledMethodScope || ps is CompiledConstructorScope) return false; if ((ps.parameters == null || ps.parameters.Count == 0) && this.mi.GetParameters().Length == 0) return true; return false; }
public virtual bool IsParamsEquals(ProcScope ps) { try { if (ps is CompiledMethodScope) { return (ps as CompiledMethodScope).IsParamsEquals(this); } else if (ps is CompiledConstructorScope) { return (ps as CompiledConstructorScope).IsParamsEquals(this); } else { if (this.parameters == null || this.parameters.Count == 0) if (ps.parameters == null || ps.parameters.Count == 0) { if (this.return_type == null) { if (ps.return_type == null) return true; else return false; } else return this.return_type.IsEqual(ps.return_type); } else return false; if (this.parameters.Count != ps.parameters.Count) return false; for (int i = 0; i < this.parameters.Count; i++) { if (this.parameters[i].param_kind != ps.parameters[i].param_kind) return false; if (!this.parameters[i].sc.IsEqual(ps.parameters[i].sc)) return false; } if (this.return_type == null) if (ps.return_type != null) return false; else return true; return this.return_type.IsEqual(ps.return_type); } } catch { return false; } }
public void AddExtensionMethod(string name, ProcScope meth, TypeScope ts) { if (extension_methods == null) extension_methods = new Dictionary<TypeScope, List<ProcScope>>(); List<ProcScope> meth_list = null; if (ts is CompiledScope && (ts as CompiledScope).CompiledType.IsGenericType && !(ts as CompiledScope).CompiledType.IsGenericTypeDefinition) ts = TypeTable.get_compiled_type((ts as CompiledScope).CompiledType.GetGenericTypeDefinition()); if (ts.original_type != null) ts = ts.original_type; if (!extension_methods.TryGetValue(ts, out meth_list)) { meth_list = new List<ProcScope>(); extension_methods.Add(ts, meth_list); } meth_list.Add(meth); }
private void add_standart_types(SymScope cur_scope) { string type_name = null; //obj_type = new CompiledScope(new SymInfo(PascalABCCompiler.TreeConverter.compiler_string_consts.object_type_name, SymbolKind.Type,PascalABCCompiler.TreeConverter.compiler_string_consts.object_type_name),typeof(object)); cur_scope.AddName(PascalABCCompiler.TreeConverter.compiler_string_consts.object_type_name,TypeTable.obj_type); //int_type = new CompiledScope(new SymInfo(PascalABCCompiler.TreeConverter.compiler_string_consts.integer_type_name, SymbolKind.Type,PascalABCCompiler.TreeConverter.compiler_string_consts.integer_type_name),typeof(int)); //cur_scope.AddName(PascalABCCompiler.TreeConverter.compiler_string_consts.integer_type_name, int_type); type_name = this.converter.controller.Parser.LanguageInformation.GetStandardTypeByKeyword(PascalABCCompiler.Parsers.KeywordKind.IntType); if (type_name != null) cur_scope.AddName(type_name, TypeTable.int_type); //real_type = new CompiledScope(new SymInfo(PascalABCCompiler.TreeConverter.compiler_string_consts.real_type_name, SymbolKind.Type,PascalABCCompiler.TreeConverter.compiler_string_consts.real_type_name),typeof(double)); //cur_scope.AddName(PascalABCCompiler.TreeConverter.compiler_string_consts.real_type_name,real_type); type_name = this.converter.controller.Parser.LanguageInformation.GetStandardTypeByKeyword(PascalABCCompiler.Parsers.KeywordKind.DoubleType); if (type_name != null) cur_scope.AddName(type_name, TypeTable.real_type); //string_type = new CompiledScope(new SymInfo(PascalABCCompiler.TreeConverter.compiler_string_consts.string_type_name, SymbolKind.Class,PascalABCCompiler.TreeConverter.compiler_string_consts.string_type_name),typeof(string)); cur_scope.AddName(PascalABCCompiler.TreeConverter.compiler_string_consts.string_type_name,TypeTable.string_type); //cur_scope.AddName(PascalABCCompiler.TreeConverter.compiler_string_consts.string_type_name, //new CompiledScope(new SymInfo(PascalABCCompiler.TreeConverter.compiler_string_consts.string_type_name, SymbolKind.Type,PascalABCCompiler.TreeConverter.compiler_string_consts.ShortStringTypeName),typeof(string))); //char_type = new CompiledScope(new SymInfo(PascalABCCompiler.TreeConverter.compiler_string_consts.char_type_name, SymbolKind.Type,PascalABCCompiler.TreeConverter.compiler_string_consts.char_type_name),typeof(char)); type_name = this.converter.controller.Parser.LanguageInformation.GetStandardTypeByKeyword(PascalABCCompiler.Parsers.KeywordKind.CharType); if (type_name != null) cur_scope.AddName(type_name, TypeTable.char_type); //cur_scope.AddName(PascalABCCompiler.TreeConverter.compiler_string_consts.char_type_name,char_type); //bool_type = new CompiledScope(new SymInfo(PascalABCCompiler.TreeConverter.compiler_string_consts.bool_type_name, SymbolKind.Type,PascalABCCompiler.TreeConverter.compiler_string_consts.bool_type_name),typeof(bool)); type_name = this.converter.controller.Parser.LanguageInformation.GetStandardTypeByKeyword(PascalABCCompiler.Parsers.KeywordKind.BoolType); if (type_name != null) cur_scope.AddName(type_name, TypeTable.bool_type); //cur_scope.AddName(PascalABCCompiler.TreeConverter.compiler_string_consts.bool_type_name,bool_type); //byte_type = new CompiledScope(new SymInfo(PascalABCCompiler.TreeConverter.compiler_string_consts.byte_type_name, SymbolKind.Type,PascalABCCompiler.TreeConverter.compiler_string_consts.byte_type_name),typeof(byte)); type_name = this.converter.controller.Parser.LanguageInformation.GetStandardTypeByKeyword(PascalABCCompiler.Parsers.KeywordKind.ByteType); if (type_name != null) cur_scope.AddName(type_name, TypeTable.byte_type); //cur_scope.AddName(PascalABCCompiler.TreeConverter.compiler_string_consts.byte_type_name,byte_type); //int16_type = new CompiledScope(new SymInfo(PascalABCCompiler.TreeConverter.compiler_string_consts.short_type_name, SymbolKind.Type,PascalABCCompiler.TreeConverter.compiler_string_consts.short_type_name),typeof(short)); type_name = this.converter.controller.Parser.LanguageInformation.GetStandardTypeByKeyword(PascalABCCompiler.Parsers.KeywordKind.ShortType); if (type_name != null) cur_scope.AddName(type_name, TypeTable.int16_type); //cur_scope.AddName(PascalABCCompiler.TreeConverter.compiler_string_consts.short_type_name,int16_type); //sbyte_type = new CompiledScope(new SymInfo(PascalABCCompiler.TreeConverter.compiler_string_consts.sbyte_type_name, SymbolKind.Type,PascalABCCompiler.TreeConverter.compiler_string_consts.sbyte_type_name),typeof(sbyte)); type_name = this.converter.controller.Parser.LanguageInformation.GetStandardTypeByKeyword(PascalABCCompiler.Parsers.KeywordKind.SByteType); if (type_name != null) cur_scope.AddName(type_name, TypeTable.sbyte_type); //cur_scope.AddName(PascalABCCompiler.TreeConverter.compiler_string_consts.sbyte_type_name,sbyte_type); //uint16_type = new CompiledScope(new SymInfo(PascalABCCompiler.TreeConverter.compiler_string_consts.ushort_type_name, SymbolKind.Type,PascalABCCompiler.TreeConverter.compiler_string_consts.ushort_type_name),typeof(ushort)); type_name = this.converter.controller.Parser.LanguageInformation.GetStandardTypeByKeyword(PascalABCCompiler.Parsers.KeywordKind.UShortType); if (type_name != null) cur_scope.AddName(type_name, TypeTable.uint16_type); //cur_scope.AddName(PascalABCCompiler.TreeConverter.compiler_string_consts.ushort_type_name,uint16_type); //uint32_type = new CompiledScope(new SymInfo(PascalABCCompiler.TreeConverter.compiler_string_consts.uint_type_name, SymbolKind.Type,PascalABCCompiler.TreeConverter.compiler_string_consts.uint_type_name),typeof(uint)); type_name = this.converter.controller.Parser.LanguageInformation.GetStandardTypeByKeyword(PascalABCCompiler.Parsers.KeywordKind.UIntType); if (type_name != null) cur_scope.AddName(type_name, TypeTable.uint32_type); //cur_scope.AddName(PascalABCCompiler.TreeConverter.compiler_string_consts.uint_type_name,uint32_type); //int64_type = new CompiledScope(new SymInfo(PascalABCCompiler.TreeConverter.compiler_string_consts.long_type_name, SymbolKind.Type,PascalABCCompiler.TreeConverter.compiler_string_consts.long_type_name),typeof(long)); type_name = this.converter.controller.Parser.LanguageInformation.GetStandardTypeByKeyword(PascalABCCompiler.Parsers.KeywordKind.Int64Type); if (type_name != null) cur_scope.AddName(type_name, TypeTable.int64_type); //cur_scope.AddName(PascalABCCompiler.TreeConverter.compiler_string_consts.long_type_name,int64_type); //uint64_type = new CompiledScope(new SymInfo(PascalABCCompiler.TreeConverter.compiler_string_consts.ulong_type_name, SymbolKind.Type,PascalABCCompiler.TreeConverter.compiler_string_consts.ulong_type_name),typeof(ulong)); type_name = this.converter.controller.Parser.LanguageInformation.GetStandardTypeByKeyword(PascalABCCompiler.Parsers.KeywordKind.UInt64Type); if (type_name != null) cur_scope.AddName(type_name, TypeTable.uint64_type); //cur_scope.AddName(PascalABCCompiler.TreeConverter.compiler_string_consts.ulong_type_name,uint64_type); //float_type = new CompiledScope(new SymInfo(PascalABCCompiler.TreeConverter.compiler_string_consts.float_type_name, SymbolKind.Type,PascalABCCompiler.TreeConverter.compiler_string_consts.float_type_name),typeof(float)); type_name = this.converter.controller.Parser.LanguageInformation.GetStandardTypeByKeyword(PascalABCCompiler.Parsers.KeywordKind.FloatType); if (type_name != null) cur_scope.AddName(type_name, TypeTable.float_type); //cur_scope.AddName(PascalABCCompiler.TreeConverter.compiler_string_consts.float_type_name,float_type); //ptr_type = new CompiledScope(new SymInfo(PascalABCCompiler.TreeConverter.compiler_string_consts.pointer_type_name, SymbolKind.Type,PascalABCCompiler.TreeConverter.compiler_string_consts.pointer_type_name),Type.GetType("System.Void*")); type_name = this.converter.controller.Parser.LanguageInformation.GetStandardTypeByKeyword(PascalABCCompiler.Parsers.KeywordKind.PointerType); if (type_name != null) cur_scope.AddName(type_name, TypeTable.ptr_type); //cur_scope.AddName(PascalABCCompiler.TreeConverter.compiler_string_consts.pointer_type_name,ptr_type); ProcScope ps = new ProcScope(PascalABCCompiler.TreeConverter.compiler_string_consts.set_length_procedure_name,null); ps.AddParameter(new ElementScope(new SymInfo("arr", SymbolKind.Parameter,"arr"),new ArrayScope(),null,ps)); ps.parameters[0].param_kind = parametr_kind.var_parametr; ps.AddParameter(new ElementScope(new SymInfo("length", SymbolKind.Parameter,"length"),TypeTable.int_type,null,ps)); ps.Complete(); cur_scope.AddName(PascalABCCompiler.TreeConverter.compiler_string_consts.set_length_procedure_name,ps); cur_scope.AddName(PascalABCCompiler.TreeConverter.compiler_string_consts.true_const_name,new ElementScope(new SymInfo(PascalABCCompiler.TreeConverter.compiler_string_consts.true_const_name, SymbolKind.Constant,PascalABCCompiler.TreeConverter.compiler_string_consts.true_const_name),TypeTable.bool_type,true,null)); cur_scope.AddName(PascalABCCompiler.TreeConverter.compiler_string_consts.false_const_name,new ElementScope(new SymInfo(PascalABCCompiler.TreeConverter.compiler_string_consts.false_const_name, SymbolKind.Constant,PascalABCCompiler.TreeConverter.compiler_string_consts.false_const_name),TypeTable.bool_type,false,null)); ps = new ProcScope(PascalABCCompiler.TreeConverter.compiler_string_consts.new_procedure_name,null); ElementScope prm = new ElementScope(new SymInfo("p", SymbolKind.Parameter,"p"),TypeTable.ptr_type,null,ps); prm.param_kind = parametr_kind.var_parametr; ps.AddParameter(prm); ps.Complete(); cur_scope.AddName(PascalABCCompiler.TreeConverter.compiler_string_consts.new_procedure_name,ps); ps = new ProcScope(PascalABCCompiler.TreeConverter.compiler_string_consts.dispose_procedure_name,null); prm = new ElementScope(new SymInfo("p", SymbolKind.Parameter,"p"),TypeTable.ptr_type,null,ps); prm.param_kind = parametr_kind.var_parametr; ps.AddParameter(prm); ps.Complete(); cur_scope.AddName(PascalABCCompiler.TreeConverter.compiler_string_consts.dispose_procedure_name,ps); }
internal static bool is_good_overload(ProcScope ps, List<SymScope> args) { if (ps.parameters == null || ps.parameters.Count == 0) if (args.Count == 0) return true; else return false; if (args.Count == 0) if (ps.parameters.Count == 1 && ps.parameters[0].param_kind == parametr_kind.params_parametr) return true; else return false; if (args.Count == ps.parameters.Count || ps.IsExtension && args.Count == ps.parameters.Count - 1) { int off = 0; if (ps.IsExtension && args.Count == ps.parameters.Count - 1) off = 1; for (int i = 0; i < args.Count; i++) { if (args[i] is UnknownScope) continue; if (!(args[i] is TypeScope)) return false; TypeScope ts = args[i] as TypeScope; ElementScope parameter = ps.parameters[i + off]; if (!ts.IsConvertable(parameter.sc as TypeScope)) { if (parameter.param_kind == parametr_kind.params_parametr) { if (!(parameter.sc is TypeScope && (parameter.sc as TypeScope).IsArray && ts.IsConvertable((parameter.sc as TypeScope).elementType))) return false; } else return false; } } return true; } else { if (args.Count < ps.parameters.Count) return false; int min_arg_cnt = Math.Min(args.Count, ps.parameters.Count); for (int i = 0; i < min_arg_cnt; i++) { if (!(args[i] is TypeScope)) return false; TypeScope ts = args[i] as TypeScope; if (!ts.IsConvertable(ps.parameters[i].sc as TypeScope)) { if (ps.parameters[i].param_kind == parametr_kind.params_parametr) { if (!(ps.parameters[i].sc is ArrayScope && ts.IsConvertable((ps.parameters[i].sc as ArrayScope).elementType))) return false; } else return false; } else if (i == ps.parameters.Count - 1 && ps.parameters[i].param_kind != parametr_kind.params_parametr) return false; } return true; } }
public void AddExtensionMethod(string name, ProcScope meth, TypeScope ts) { if (extension_methods == null) extension_methods = new Dictionary<TypeScope, List<ProcScope>>(); List<ProcScope> meth_list = null; if (!extension_methods.TryGetValue(ts, out meth_list)) { meth_list = new List<ProcScope>(); extension_methods.Add(ts, meth_list); } meth_list.Add(meth); }
public void AddDefaultConstructorIfNeed() { if (members != null) { bool has_def_constr = false; ProcScope last_constr = null; //SymScope cnstr_ss = this.FindNameOnlyInThisType("Create"); foreach (SymScope ss in members) if (ss is ProcScope && (ss as ProcScope).is_constructor) { /*if ((ss as ProcScope).parameters != null && (ss as ProcScope).parameters.Count==0) { has_def_constr = true; break; } else { //last_constr = ss as ProcScope; }*/ has_def_constr = true; } if (!has_def_constr) { ProcScope ps = new ProcScope("Create", this, true); ps.Complete(); /*if (cnstr_ss != null && cnstr_ss is ProcScope) //last_constr.nextProc = ps; ps.nextProc = cnstr_ss as ProcScope; //else*/ //ps.si.name = this.si.name; members.Insert(0, ps); } } }
private bool equal_params(ProcScope ps, List<ProcScope> procs) { return false; }
private ElementScope GetParameter(ProcScope func) { int offset = (int)br.BaseStream.Position-start_pos; br.ReadByte(); string s = br.ReadString(); TypeScope tn = GetTypeReference(); concrete_parameter_type cpt = (concrete_parameter_type)br.ReadByte(); ElementScope p = new ElementScope(new SymInfo(s, SymbolKind.Parameter,s),tn,null,null); bool is_params = br.ReadBoolean(); if (is_params) p.param_kind = parametr_kind.params_parametr; else switch (cpt) { case concrete_parameter_type.cpt_const: p.param_kind = parametr_kind.const_parametr; break; case concrete_parameter_type.cpt_var: p.param_kind = parametr_kind.var_parametr; break; case concrete_parameter_type.cpt_none: p.param_kind = parametr_kind.none; break; } br.ReadBoolean(); if (CanReadObject()) { br.ReadInt32();//CreateExpression(); } br.ReadInt32();//attributes //members[offset] = p; return p; }
private void GetLocalVariable(ProcScope func) { int offset = (int)br.BaseStream.Position-start_pos; //int tmp=br.ReadByte(); br.ReadString(); GetTypeReference(); br.ReadBoolean(); //members[offset] = lv; if (CanReadObject()) br.ReadInt32(); //CreateExpression(); return; }
public ProcType(ProcScope target) { this.target = target; this.si = new SymInfo(this.ToString(), SymbolKind.Delegate, this.ToString()); }
internal static bool is_good_exact_overload(ProcScope ps, List<SymScope> args) { if (ps.parameters == null || ps.parameters.Count == 0) if (args.Count == 0) return true; else return false; if (args.Count == 0) if (ps.parameters.Count == 1 && ps.parameters[0].param_kind == parametr_kind.params_parametr) return true; else return false; if (args.Count == ps.parameters.Count) { for (int i=0; i<args.Count; i++) { if (!(args[i] is TypeScope)) return false; TypeScope ts = args[i] as TypeScope; if (!ts.IsEqual(ps.parameters[i].sc as TypeScope)) { if (ps.parameters[i].param_kind == parametr_kind.params_parametr) { if (!(ps.parameters[i].sc is ArrayScope && ts.IsEqual((ps.parameters[i].sc as ArrayScope).elementType))) return false; } else return false; } } return true; } else { if (args.Count < ps.parameters.Count) return false; int min_arg_cnt = Math.Min(args.Count,ps.parameters.Count); for (int i=0; i<min_arg_cnt; i++) { if (!(args[i] is TypeScope)) return false; TypeScope ts = args[i] as TypeScope; if (!ts.IsEqual(ps.parameters[i].sc as TypeScope)) { if (ps.parameters[i].param_kind == parametr_kind.params_parametr) { if (!(ps.parameters[i].sc is ArrayScope && ts.IsEqual((ps.parameters[i].sc as ArrayScope).elementType))) return false; } else return false; } else if (i == ps.parameters.Count-1 && ps.parameters[i].param_kind != parametr_kind.params_parametr) return false; } return false; } }
public ProcScope GetInstance(List<TypeScope> gen_args) { if (this.template_parameters == null || this.template_parameters.Count == 0) return this; ProcScope instance = new ProcScope(this.name, this.topScope, this.is_constructor); instance.parameters = new List<ElementScope>(this.parameters.Count); int i = 0; foreach (ElementScope parameter in this.parameters) { i++; if (parameter.sc is UnknownScope || (parameter.sc is TypeScope) && (parameter.sc as TypeScope).IsGenericParameter) { int ind = this.template_parameters.IndexOf((parameter.sc as TypeScope).Name); ElementScope inst_param = null; if (gen_args.Count > ind && ind != -1) inst_param = new ElementScope(parameter.si, gen_args[ind], parameter.topScope); else inst_param = new ElementScope(parameter.si, parameter.sc, parameter.topScope); instance.parameters.Add(inst_param); } else { ElementScope inst_param = null; if ((parameter.sc as TypeScope).IsGeneric) inst_param = new ElementScope(parameter.si, (parameter.sc as TypeScope).GetInstance(gen_args), parameter.topScope); else inst_param = new ElementScope(parameter.si, parameter.sc, parameter.topScope); instance.parameters.Add(inst_param); } if (parameter.param_kind == parametr_kind.params_parametr && i < gen_args.Count) gen_args.RemoveRange(i, gen_args.Count - i); } instance.si = this.si; instance.return_type = this.return_type.GetInstance(gen_args); return instance; }
public override void visit(destructor _destructor) { //throw new Exception("The method or operation is not implemented."); SymScope topScope = cur_scope; ProcScope ps = null; location loc = get_location(_destructor); bool is_realization = false; _destructor.name.visit(this); if (_destructor.name.class_name != null) { topScope = cur_scope.FindName(_destructor.name.class_name.name); if (topScope != null) { ps = topScope.FindNameOnlyInThisType(meth_name) as ProcScope; if (ps == null) { ps = new ProcScope(meth_name, cur_scope); ps.head_loc = loc; } else ps = select_function_definition(ps, _destructor.parameters, null, topScope as TypeScope); //while (ps != null && ps.already_defined) ps = ps.nextProc; if (ps == null) { ps = new ProcScope(meth_name, cur_scope); ps.head_loc = loc; } if (ps.parameters.Count != 0 && _destructor.parameters != null) { ps.parameters.Clear(); ps.already_defined = true; } if (impl_scope == null) { ProcRealization pr = new ProcRealization(ps, cur_scope); pr.already_defined = true; ps.proc_realization = pr; pr.loc = cur_loc; pr.head_loc = loc; is_realization = true; entry_scope.AddName("$method", pr); } else { ProcRealization pr = new ProcRealization(ps, impl_scope); pr.already_defined = true; ps.proc_realization = pr; pr.loc = cur_loc; pr.head_loc = loc; is_realization = true; impl_scope.AddName("$method", pr); } } else { ps = new ProcScope(meth_name, cur_scope); ps.head_loc = loc; } } else { ps = new ProcScope(meth_name, cur_scope); ps.head_loc = loc; SymScope ss = cur_scope.FindNameOnlyInThisType(meth_name); if (ss != null && ss is ProcScope) { while ((ss as ProcScope).nextProc != null) ss = (ss as ProcScope).nextProc; (ss as ProcScope).nextProc = ps; cur_scope.AddName("$method", ps); ps.si.name = meth_name; } else { cur_scope.AddName(meth_name, ps); } } if (!is_realization && ps.loc == null) ps.loc = cur_loc; //ps.head_loc = loc; ps.declaringUnit = entry_scope; SetAttributes(ps, _destructor.proc_attributes); if (add_doc_from_text && this.converter.controller.docs != null && this.converter.controller.docs.ContainsKey(_destructor)) ps.AddDocumentation(this.converter.controller.docs[_destructor]); if (is_proc_realization) ps.already_defined = true; else ps.loc = loc; if (_destructor.name == null || _destructor.name.class_name == null) { ps.acc_mod = cur_access_mod; ps.si.acc_mod = cur_access_mod; } if (_destructor.parameters != null) foreach (typed_parameters pars in _destructor.parameters.params_list) { pars.vars_type.visit(this); if (returned_scope != null) { if (returned_scope is ProcScope) returned_scope = new ProcType(returned_scope as ProcScope); foreach (ident id in pars.idents.idents) { ElementScope si = new ElementScope(new SymInfo(id.name, SymbolKind.Parameter, id.name), returned_scope, ps); si.loc = get_location(id); ps.AddName(id.name, si); si.param_kind = pars.param_kind; si.MakeDescription(); ps.AddParameter(si); } } } if (cur_scope is TypeScope) ps.AddName("self", new ElementScope(new SymInfo("self", SymbolKind.Parameter, "self"), cur_scope, ps)); //cur_scope = ps; returned_scope = ps; ps.Complete(); }
private bool equal_parameters_and_result(ProcScope ps) { if (this.parameters == null) { if (ps.parameters != null) return false; else if (this.return_type == null) { if (ps.return_type == null) return true; else return false; } return this.return_type.IsEqual(ps.return_type); } else if (ps.parameters == null) return false; if (ps.parameters.Count != this.parameters.Count) return false; for (int i = 0; i < this.parameters.Count; i++) { if (!this.parameters[i].sc.IsEqual(ps.parameters[i].sc)) return false; if (this.parameters[i].param_kind != ps.parameters[i].param_kind) return false; } if (this.return_type == null) { if (ps.return_type == null) return true; else return false; } return this.return_type.IsEqual(ps.return_type); }
public override void visit(function_lambda_definition _function_lambda_definition) { ProcScope ps = new ProcScope(_function_lambda_definition.lambda_name, this.cur_scope); ps.loc = get_location(_function_lambda_definition); cur_scope.AddName(_function_lambda_definition.lambda_name, ps); if (_function_lambda_definition.ident_list != null) foreach (ident id in _function_lambda_definition.ident_list.idents) { ElementScope es = new ElementScope(new SymInfo(id.name, SymbolKind.Parameter, ""), new UnknownScope(new SymInfo("T", SymbolKind.Type, "T")), ps); ps.AddName(id.name, es); ps.AddParameter(es); es.loc = get_location(id); } _function_lambda_definition.proc_body.visit(this); ps.return_type = returned_scope as TypeScope; returned_scope = new ProcType(ps); }
public void AddDefaultConstructorIfNeed() { if (members != null) { bool has_def_constr = false; foreach (SymScope ss in members) if (ss is ProcScope && (ss as ProcScope).is_constructor) { has_def_constr = true; } if (!has_def_constr) { ProcScope ps = new ProcScope("Create", this, true); ps.Complete(); members.Insert(0, ps); } } }
private void SetAttributes(ProcScope ps, procedure_attributes_list attrs) { if (attrs == null) return; for (int i = 0; i < attrs.proc_attributes.Count; i++) if (attrs.proc_attributes[i].attribute_type == proc_attribute.attr_static) ps.is_static = true; else if (attrs.proc_attributes[i].attribute_type == proc_attribute.attr_virtual) ps.is_virtual = true; else if (attrs.proc_attributes[i].attribute_type == proc_attribute.attr_abstract) ps.is_abstract = true; else if (attrs.proc_attributes[i].attribute_type == proc_attribute.attr_override) ps.is_override = true; else if (attrs.proc_attributes[i].attribute_type == proc_attribute.attr_reintroduce) ps.is_reintroduce = true; }
public override bool IsParamsEquals(ProcScope ps) { if (ps is CompiledMethodScope || ps is CompiledConstructorScope) return false; try { ParameterInfo[] prms = this.mi.GetParameters(); if (ps.parameters == null) { if (prms.Length != 0) return false; if (ps.return_type == null) { if (this.mi.ReturnType == typeof(void)) return true; else return false; } if (this.mi.ReturnType == null) return false; return ps.return_type.IsEqual(TypeTable.get_compiled_type(this.mi.ReturnType)); } if (prms.Length != ps.parameters.Count) return false; for (int i = 0; i < prms.Length; i++) { if (!ps.parameters[i].sc.IsEqual(TypeTable.get_compiled_type(prms[i].ParameterType))) return false; } if (ps.return_type == null) { if (this.mi.ReturnType == typeof(void)) return true; else return false; } if (this.mi.ReturnType == null) return false; return ps.return_type.IsEqual(TypeTable.get_compiled_type(this.mi.ReturnType)); } catch { return false; } }
private ProcScope select_function_definition(ProcScope ps, formal_parameters prms, TypeScope return_type, TypeScope declType) { SymScope tmp = returned_scope; List<ElementScope> lst = new List<ElementScope>(); if (prms != null) { foreach (typed_parameters pars in prms.params_list) { pars.vars_type.visit(this); if (returned_scope != null) { foreach (ident id in pars.idents.idents) { if (returned_scope is ProcScope) returned_scope = new ProcType(returned_scope as ProcScope); ElementScope si = new ElementScope(new SymInfo(id.name, SymbolKind.Parameter,id.name),returned_scope,ps); si.loc = get_location(id); si.param_kind = pars.param_kind; lst.Add(si); } } } while (ps != null) { if (ps.parameters != null) { if (ps.parameters.Count == lst.Count) { bool eq = true; for (int i=0; i<lst.Count; i++) { TypeScope left = ps.parameters[i].sc as TypeScope; TypeScope right = lst[i].sc as TypeScope; if (!left.IsEqual(right) || ps.parameters[i].param_kind != lst[i].param_kind) { eq = false; break; } } if (eq) { if (ps.return_type == null && return_type == null) return ps; if (ps.return_type != null && return_type != null) { if ((ps.return_type as TypeScope).IsEqual(return_type)) return ps; } } } } ps = ps.nextProc; } } else { while (ps != null) { if (ps.parameters == null || ps.parameters.Count == 0) { if (ps.return_type == null && return_type == null) return ps; if (ps.return_type != null && return_type != null) { if ((ps.return_type as TypeScope).IsEqual(return_type)) return ps; } else return null; } ps = ps.nextProc; } } returned_scope = tmp; return ps; }
static TypeTable() { obj_type = get_compiled_type(new SymInfo(PascalABCCompiler.TreeConverter.compiler_string_consts.object_type_name, SymbolKind.Type, PascalABCCompiler.TreeConverter.compiler_string_consts.object_type_name), typeof(object)); int_type = get_compiled_type(new SymInfo(PascalABCCompiler.TreeConverter.compiler_string_consts.integer_type_name, SymbolKind.Type, PascalABCCompiler.TreeConverter.compiler_string_consts.integer_type_name), typeof(int)); real_type = get_compiled_type(new SymInfo(PascalABCCompiler.TreeConverter.compiler_string_consts.real_type_name, SymbolKind.Type, PascalABCCompiler.TreeConverter.compiler_string_consts.real_type_name), typeof(double)); string_type = get_compiled_type(new SymInfo(PascalABCCompiler.TreeConverter.compiler_string_consts.string_type_name, SymbolKind.Class, PascalABCCompiler.TreeConverter.compiler_string_consts.string_type_name), typeof(string)); char_type = get_compiled_type(new SymInfo(PascalABCCompiler.TreeConverter.compiler_string_consts.char_type_name, SymbolKind.Type, PascalABCCompiler.TreeConverter.compiler_string_consts.char_type_name), typeof(char)); bool_type = get_compiled_type(new SymInfo(PascalABCCompiler.TreeConverter.compiler_string_consts.bool_type_name, SymbolKind.Type, PascalABCCompiler.TreeConverter.compiler_string_consts.bool_type_name), typeof(bool)); byte_type = get_compiled_type(new SymInfo(PascalABCCompiler.TreeConverter.compiler_string_consts.byte_type_name, SymbolKind.Type, PascalABCCompiler.TreeConverter.compiler_string_consts.byte_type_name), typeof(byte)); int16_type = get_compiled_type(new SymInfo(PascalABCCompiler.TreeConverter.compiler_string_consts.short_type_name, SymbolKind.Type, PascalABCCompiler.TreeConverter.compiler_string_consts.short_type_name), typeof(short)); sbyte_type = get_compiled_type(new SymInfo(PascalABCCompiler.TreeConverter.compiler_string_consts.sbyte_type_name, SymbolKind.Type, PascalABCCompiler.TreeConverter.compiler_string_consts.sbyte_type_name), typeof(sbyte)); uint16_type = get_compiled_type(new SymInfo(PascalABCCompiler.TreeConverter.compiler_string_consts.ushort_type_name, SymbolKind.Type, PascalABCCompiler.TreeConverter.compiler_string_consts.ushort_type_name), typeof(ushort)); uint32_type = get_compiled_type(new SymInfo(PascalABCCompiler.TreeConverter.compiler_string_consts.uint_type_name, SymbolKind.Type, PascalABCCompiler.TreeConverter.compiler_string_consts.uint_type_name), typeof(uint)); int64_type = get_compiled_type(new SymInfo(PascalABCCompiler.TreeConverter.compiler_string_consts.long_type_name, SymbolKind.Type, PascalABCCompiler.TreeConverter.compiler_string_consts.long_type_name), typeof(long)); uint64_type = get_compiled_type(new SymInfo(PascalABCCompiler.TreeConverter.compiler_string_consts.ulong_type_name, SymbolKind.Type, PascalABCCompiler.TreeConverter.compiler_string_consts.ulong_type_name), typeof(ulong)); float_type = get_compiled_type(new SymInfo(PascalABCCompiler.TreeConverter.compiler_string_consts.float_type_name, SymbolKind.Type, PascalABCCompiler.TreeConverter.compiler_string_consts.float_type_name), typeof(float)); ptr_type = get_compiled_type(new SymInfo(PascalABCCompiler.TreeConverter.compiler_string_consts.pointer_type_name, SymbolKind.Type, PascalABCCompiler.TreeConverter.compiler_string_consts.pointer_type_name), Type.GetType("System.Void*")); void_type = get_compiled_type(new SymInfo("void", SymbolKind.Type, "void"), typeof(void)); ProcScope ps = new ProcScope(PascalABCCompiler.TreeConverter.compiler_string_consts.plus_name, int_type); int_plus = ps; ElementScope left = new ElementScope(new SymInfo("", SymbolKind.Parameter, ""), int_type, int_type); ElementScope right = new ElementScope(new SymInfo("", SymbolKind.Parameter, ""), int_type, int_type); ps.return_type = int_type; ps.AddParameter(left); ps.AddParameter(right); int_type.AddName(PascalABCCompiler.TreeConverter.compiler_string_consts.plus_name, ps); ps = new ProcScope(PascalABCCompiler.TreeConverter.compiler_string_consts.minus_name, int_type); int_minus = ps; left = new ElementScope(new SymInfo("", SymbolKind.Parameter, ""), int_type, int_type); right = new ElementScope(new SymInfo("", SymbolKind.Parameter, ""), int_type, int_type); ps.return_type = int_type; ps.AddParameter(left); ps.AddParameter(right); int_type.AddName(PascalABCCompiler.TreeConverter.compiler_string_consts.minus_name, ps); ps = new ProcScope(PascalABCCompiler.TreeConverter.compiler_string_consts.mul_name, int_type); int_mul = ps; left = new ElementScope(new SymInfo("", SymbolKind.Parameter, ""), int_type, int_type); right = new ElementScope(new SymInfo("", SymbolKind.Parameter, ""), int_type, int_type); ps.return_type = int_type; ps.AddParameter(left); ps.AddParameter(right); int_type.AddName(PascalABCCompiler.TreeConverter.compiler_string_consts.mul_name, ps); ps = new ProcScope(PascalABCCompiler.TreeConverter.compiler_string_consts.idiv_name, int_type); int_div = ps; left = new ElementScope(new SymInfo("", SymbolKind.Parameter, ""), int_type, int_type); right = new ElementScope(new SymInfo("", SymbolKind.Parameter, ""), int_type, int_type); ps.return_type = int_type; ps.AddParameter(left); ps.AddParameter(right); int_type.AddName(PascalABCCompiler.TreeConverter.compiler_string_consts.idiv_name, ps); ps = new ProcScope(PascalABCCompiler.TreeConverter.compiler_string_consts.mod_name, int_type); int_mod = ps; left = new ElementScope(new SymInfo("", SymbolKind.Parameter, ""), int_type, int_type); right = new ElementScope(new SymInfo("", SymbolKind.Parameter, ""), int_type, int_type); ps.return_type = int_type; ps.AddParameter(left); ps.AddParameter(right); int_type.AddName(PascalABCCompiler.TreeConverter.compiler_string_consts.mod_name, ps); ps = new ProcScope(PascalABCCompiler.TreeConverter.compiler_string_consts.shl_name, int_type); int_shl = ps; left = new ElementScope(new SymInfo("", SymbolKind.Parameter, ""), int_type, int_type); right = new ElementScope(new SymInfo("", SymbolKind.Parameter, ""), int_type, int_type); ps.return_type = int_type; ps.AddParameter(left); ps.AddParameter(right); int_type.AddName(PascalABCCompiler.TreeConverter.compiler_string_consts.shl_name, ps); ps = new ProcScope(PascalABCCompiler.TreeConverter.compiler_string_consts.shr_name, int_type); int_shr = ps; left = new ElementScope(new SymInfo("", SymbolKind.Parameter, ""), int_type, int_type); right = new ElementScope(new SymInfo("", SymbolKind.Parameter, ""), int_type, int_type); ps.return_type = int_type; ps.AddParameter(left); ps.AddParameter(right); int_type.AddName(PascalABCCompiler.TreeConverter.compiler_string_consts.shr_name, ps); ps = new ProcScope(PascalABCCompiler.TreeConverter.compiler_string_consts.and_name, int_type); int_and = ps; left = new ElementScope(new SymInfo("", SymbolKind.Parameter, ""), int_type, int_type); right = new ElementScope(new SymInfo("", SymbolKind.Parameter, ""), int_type, int_type); ps.return_type = int_type; ps.AddParameter(left); ps.AddParameter(right); int_type.AddName(PascalABCCompiler.TreeConverter.compiler_string_consts.and_name, ps); ps = new ProcScope(PascalABCCompiler.TreeConverter.compiler_string_consts.or_name, int_type); int_or = ps; left = new ElementScope(new SymInfo("", SymbolKind.Parameter, ""), int_type, int_type); right = new ElementScope(new SymInfo("", SymbolKind.Parameter, ""), int_type, int_type); ps.return_type = int_type; ps.AddParameter(left); ps.AddParameter(right); int_type.AddName(PascalABCCompiler.TreeConverter.compiler_string_consts.or_name, ps); ps = new ProcScope(PascalABCCompiler.TreeConverter.compiler_string_consts.xor_name, int_type); int_xor = ps; left = new ElementScope(new SymInfo("", SymbolKind.Parameter, ""), int_type, int_type); right = new ElementScope(new SymInfo("", SymbolKind.Parameter, ""), int_type, int_type); ps.return_type = int_type; ps.AddParameter(left); ps.AddParameter(right); int_type.AddName(PascalABCCompiler.TreeConverter.compiler_string_consts.xor_name, ps); ps = new ProcScope(PascalABCCompiler.TreeConverter.compiler_string_consts.eq_name, int_type); int_eq = ps; left = new ElementScope(new SymInfo("", SymbolKind.Parameter, ""), int_type, int_type); right = new ElementScope(new SymInfo("", SymbolKind.Parameter, ""), int_type, int_type); ps.return_type = bool_type; ps.AddParameter(left); ps.AddParameter(right); int_type.AddName(PascalABCCompiler.TreeConverter.compiler_string_consts.eq_name, ps); ps = new ProcScope(PascalABCCompiler.TreeConverter.compiler_string_consts.noteq_name, int_type); int_noteq = ps; left = new ElementScope(new SymInfo("", SymbolKind.Parameter, ""), int_type, int_type); right = new ElementScope(new SymInfo("", SymbolKind.Parameter, ""), int_type, int_type); ps.return_type = bool_type; ps.AddParameter(left); ps.AddParameter(right); int_type.AddName(PascalABCCompiler.TreeConverter.compiler_string_consts.noteq_name, ps); ps = new ProcScope(PascalABCCompiler.TreeConverter.compiler_string_consts.sm_name, int_type); int_sm = ps; left = new ElementScope(new SymInfo("", SymbolKind.Parameter, ""), int_type, int_type); right = new ElementScope(new SymInfo("", SymbolKind.Parameter, ""), int_type, int_type); ps.return_type = bool_type; ps.AddParameter(left); ps.AddParameter(right); int_type.AddName(PascalABCCompiler.TreeConverter.compiler_string_consts.sm_name, ps); ps = new ProcScope(PascalABCCompiler.TreeConverter.compiler_string_consts.smeq_name, int_type); int_smeq = ps; left = new ElementScope(new SymInfo("", SymbolKind.Parameter, ""), int_type, int_type); right = new ElementScope(new SymInfo("", SymbolKind.Parameter, ""), int_type, int_type); ps.return_type = bool_type; ps.AddParameter(left); ps.AddParameter(right); int_type.AddName(PascalABCCompiler.TreeConverter.compiler_string_consts.smeq_name, ps); ps = new ProcScope(PascalABCCompiler.TreeConverter.compiler_string_consts.gr_name, int_type); int_gr = ps; left = new ElementScope(new SymInfo("", SymbolKind.Parameter, ""), int_type, int_type); right = new ElementScope(new SymInfo("", SymbolKind.Parameter, ""), int_type, int_type); ps.return_type = bool_type; ps.AddParameter(left); ps.AddParameter(right); int_type.AddName(PascalABCCompiler.TreeConverter.compiler_string_consts.gr_name, ps); ps = new ProcScope(PascalABCCompiler.TreeConverter.compiler_string_consts.greq_name, int_type); int_greq = ps; left = new ElementScope(new SymInfo("", SymbolKind.Parameter, ""), int_type, int_type); right = new ElementScope(new SymInfo("", SymbolKind.Parameter, ""), int_type, int_type); ps.return_type = bool_type; ps.AddParameter(left); ps.AddParameter(right); int_type.AddName(PascalABCCompiler.TreeConverter.compiler_string_consts.greq_name, ps); //byte type byte_type.AddName(PascalABCCompiler.TreeConverter.compiler_string_consts.plus_name, int_plus); byte_type.AddName(PascalABCCompiler.TreeConverter.compiler_string_consts.minus_name, int_minus); byte_type.AddName(PascalABCCompiler.TreeConverter.compiler_string_consts.mul_name, int_mul); byte_type.AddName(PascalABCCompiler.TreeConverter.compiler_string_consts.idiv_name, int_div); byte_type.AddName(PascalABCCompiler.TreeConverter.compiler_string_consts.mod_name, int_mod); byte_type.AddName(PascalABCCompiler.TreeConverter.compiler_string_consts.shl_name, int_shl); byte_type.AddName(PascalABCCompiler.TreeConverter.compiler_string_consts.shr_name, int_shr); byte_type.AddName(PascalABCCompiler.TreeConverter.compiler_string_consts.eq_name, int_eq); byte_type.AddName(PascalABCCompiler.TreeConverter.compiler_string_consts.noteq_name, int_noteq); byte_type.AddName(PascalABCCompiler.TreeConverter.compiler_string_consts.sm_name, int_sm); byte_type.AddName(PascalABCCompiler.TreeConverter.compiler_string_consts.smeq_name, int_smeq); byte_type.AddName(PascalABCCompiler.TreeConverter.compiler_string_consts.gr_name, int_gr); byte_type.AddName(PascalABCCompiler.TreeConverter.compiler_string_consts.greq_name, int_greq); ps = new ProcScope(PascalABCCompiler.TreeConverter.compiler_string_consts.and_name, byte_type); byte_and = ps; left = new ElementScope(new SymInfo("", SymbolKind.Parameter, ""), byte_type, byte_type); right = new ElementScope(new SymInfo("", SymbolKind.Parameter, ""), byte_type, byte_type); ps.return_type = byte_type; ps.AddParameter(left); ps.AddParameter(right); byte_type.AddName(PascalABCCompiler.TreeConverter.compiler_string_consts.and_name, ps); ps = new ProcScope(PascalABCCompiler.TreeConverter.compiler_string_consts.or_name, byte_type); byte_or = ps; left = new ElementScope(new SymInfo("", SymbolKind.Parameter, ""), byte_type, byte_type); right = new ElementScope(new SymInfo("", SymbolKind.Parameter, ""), byte_type, byte_type); ps.return_type = byte_type; ps.AddParameter(left); ps.AddParameter(right); byte_type.AddName(PascalABCCompiler.TreeConverter.compiler_string_consts.or_name, ps); ps = new ProcScope(PascalABCCompiler.TreeConverter.compiler_string_consts.xor_name, byte_type); byte_xor = ps; left = new ElementScope(new SymInfo("", SymbolKind.Parameter, ""), byte_type, byte_type); right = new ElementScope(new SymInfo("", SymbolKind.Parameter, ""), byte_type, byte_type); ps.return_type = byte_type; ps.AddParameter(left); ps.AddParameter(right); byte_type.AddName(PascalABCCompiler.TreeConverter.compiler_string_consts.xor_name, ps); //sbyte sbyte_type.AddName(PascalABCCompiler.TreeConverter.compiler_string_consts.plus_name, int_plus); sbyte_type.AddName(PascalABCCompiler.TreeConverter.compiler_string_consts.minus_name, int_minus); sbyte_type.AddName(PascalABCCompiler.TreeConverter.compiler_string_consts.mul_name, int_mul); sbyte_type.AddName(PascalABCCompiler.TreeConverter.compiler_string_consts.idiv_name, int_div); sbyte_type.AddName(PascalABCCompiler.TreeConverter.compiler_string_consts.mod_name, int_mod); sbyte_type.AddName(PascalABCCompiler.TreeConverter.compiler_string_consts.shl_name, int_shl); sbyte_type.AddName(PascalABCCompiler.TreeConverter.compiler_string_consts.shr_name, int_shr); sbyte_type.AddName(PascalABCCompiler.TreeConverter.compiler_string_consts.eq_name, int_eq); sbyte_type.AddName(PascalABCCompiler.TreeConverter.compiler_string_consts.noteq_name, int_noteq); sbyte_type.AddName(PascalABCCompiler.TreeConverter.compiler_string_consts.sm_name, int_sm); sbyte_type.AddName(PascalABCCompiler.TreeConverter.compiler_string_consts.smeq_name, int_smeq); sbyte_type.AddName(PascalABCCompiler.TreeConverter.compiler_string_consts.gr_name, int_gr); sbyte_type.AddName(PascalABCCompiler.TreeConverter.compiler_string_consts.greq_name, int_greq); ps = new ProcScope(PascalABCCompiler.TreeConverter.compiler_string_consts.and_name, sbyte_type); sbyte_and = ps; left = new ElementScope(new SymInfo("", SymbolKind.Parameter, ""), sbyte_type, sbyte_type); right = new ElementScope(new SymInfo("", SymbolKind.Parameter, ""), sbyte_type, sbyte_type); ps.return_type = sbyte_type; ps.AddParameter(left); ps.AddParameter(right); sbyte_type.AddName(PascalABCCompiler.TreeConverter.compiler_string_consts.and_name, ps); ps = new ProcScope(PascalABCCompiler.TreeConverter.compiler_string_consts.or_name, sbyte_type); sbyte_or = ps; left = new ElementScope(new SymInfo("", SymbolKind.Parameter, ""), sbyte_type, sbyte_type); right = new ElementScope(new SymInfo("", SymbolKind.Parameter, ""), sbyte_type, sbyte_type); ps.return_type = sbyte_type; ps.AddParameter(left); ps.AddParameter(right); sbyte_type.AddName(PascalABCCompiler.TreeConverter.compiler_string_consts.or_name, ps); ps = new ProcScope(PascalABCCompiler.TreeConverter.compiler_string_consts.xor_name, sbyte_type); sbyte_xor = ps; left = new ElementScope(new SymInfo("", SymbolKind.Parameter, ""), sbyte_type, sbyte_type); right = new ElementScope(new SymInfo("", SymbolKind.Parameter, ""), sbyte_type, sbyte_type); ps.return_type = sbyte_type; ps.AddParameter(left); ps.AddParameter(right); sbyte_type.AddName(PascalABCCompiler.TreeConverter.compiler_string_consts.xor_name, ps); //ushort uint16_type.AddName(PascalABCCompiler.TreeConverter.compiler_string_consts.plus_name, int_plus); uint16_type.AddName(PascalABCCompiler.TreeConverter.compiler_string_consts.minus_name, int_minus); uint16_type.AddName(PascalABCCompiler.TreeConverter.compiler_string_consts.mul_name, int_mul); uint16_type.AddName(PascalABCCompiler.TreeConverter.compiler_string_consts.idiv_name, int_div); uint16_type.AddName(PascalABCCompiler.TreeConverter.compiler_string_consts.mod_name, int_mod); uint16_type.AddName(PascalABCCompiler.TreeConverter.compiler_string_consts.shl_name, int_shl); uint16_type.AddName(PascalABCCompiler.TreeConverter.compiler_string_consts.shr_name, int_shr); uint16_type.AddName(PascalABCCompiler.TreeConverter.compiler_string_consts.eq_name, int_eq); uint16_type.AddName(PascalABCCompiler.TreeConverter.compiler_string_consts.noteq_name, int_noteq); uint16_type.AddName(PascalABCCompiler.TreeConverter.compiler_string_consts.sm_name, int_sm); uint16_type.AddName(PascalABCCompiler.TreeConverter.compiler_string_consts.smeq_name, int_smeq); uint16_type.AddName(PascalABCCompiler.TreeConverter.compiler_string_consts.gr_name, int_gr); uint16_type.AddName(PascalABCCompiler.TreeConverter.compiler_string_consts.greq_name, int_greq); ps = new ProcScope(PascalABCCompiler.TreeConverter.compiler_string_consts.and_name, uint16_type); uint16_and = ps; left = new ElementScope(new SymInfo("", SymbolKind.Parameter, ""), uint16_type, uint16_type); right = new ElementScope(new SymInfo("", SymbolKind.Parameter, ""), uint16_type, uint16_type); ps.return_type = uint16_type; ps.AddParameter(left); ps.AddParameter(right); uint16_type.AddName(PascalABCCompiler.TreeConverter.compiler_string_consts.and_name, ps); ps = new ProcScope(PascalABCCompiler.TreeConverter.compiler_string_consts.or_name, uint16_type); uint16_or = ps; left = new ElementScope(new SymInfo("", SymbolKind.Parameter, ""), uint16_type, uint16_type); right = new ElementScope(new SymInfo("", SymbolKind.Parameter, ""), uint16_type, uint16_type); ps.return_type = uint16_type; ps.AddParameter(left); ps.AddParameter(right); uint16_type.AddName(PascalABCCompiler.TreeConverter.compiler_string_consts.or_name, ps); ps = new ProcScope(PascalABCCompiler.TreeConverter.compiler_string_consts.xor_name, uint16_type); uint16_xor = ps; left = new ElementScope(new SymInfo("", SymbolKind.Parameter, ""), uint16_type, uint16_type); right = new ElementScope(new SymInfo("", SymbolKind.Parameter, ""), uint16_type, uint16_type); ps.return_type = uint16_type; ps.AddParameter(left); ps.AddParameter(right); uint16_type.AddName(PascalABCCompiler.TreeConverter.compiler_string_consts.xor_name, ps); //int16 int16_type.AddName(PascalABCCompiler.TreeConverter.compiler_string_consts.plus_name, int_plus); int16_type.AddName(PascalABCCompiler.TreeConverter.compiler_string_consts.minus_name, int_minus); int16_type.AddName(PascalABCCompiler.TreeConverter.compiler_string_consts.mul_name, int_mul); int16_type.AddName(PascalABCCompiler.TreeConverter.compiler_string_consts.idiv_name, int_div); int16_type.AddName(PascalABCCompiler.TreeConverter.compiler_string_consts.mod_name, int_mod); int16_type.AddName(PascalABCCompiler.TreeConverter.compiler_string_consts.shl_name, int_shl); int16_type.AddName(PascalABCCompiler.TreeConverter.compiler_string_consts.shr_name, int_shr); int16_type.AddName(PascalABCCompiler.TreeConverter.compiler_string_consts.eq_name, int_eq); int16_type.AddName(PascalABCCompiler.TreeConverter.compiler_string_consts.noteq_name, int_noteq); int16_type.AddName(PascalABCCompiler.TreeConverter.compiler_string_consts.sm_name, int_sm); int16_type.AddName(PascalABCCompiler.TreeConverter.compiler_string_consts.smeq_name, int_smeq); int16_type.AddName(PascalABCCompiler.TreeConverter.compiler_string_consts.gr_name, int_gr); int16_type.AddName(PascalABCCompiler.TreeConverter.compiler_string_consts.greq_name, int_greq); ps = new ProcScope(PascalABCCompiler.TreeConverter.compiler_string_consts.and_name, uint16_type); int16_and = ps; left = new ElementScope(new SymInfo("", SymbolKind.Parameter, ""), int16_type, int16_type); right = new ElementScope(new SymInfo("", SymbolKind.Parameter, ""), int16_type, int16_type); ps.return_type = int16_type; ps.AddParameter(left); ps.AddParameter(right); int16_type.AddName(PascalABCCompiler.TreeConverter.compiler_string_consts.and_name, ps); ps = new ProcScope(PascalABCCompiler.TreeConverter.compiler_string_consts.or_name, int16_type); int16_or = ps; left = new ElementScope(new SymInfo("", SymbolKind.Parameter, ""), int16_type, int16_type); right = new ElementScope(new SymInfo("", SymbolKind.Parameter, ""), int16_type, int16_type); ps.return_type = int16_type; ps.AddParameter(left); ps.AddParameter(right); int16_type.AddName(PascalABCCompiler.TreeConverter.compiler_string_consts.or_name, ps); ps = new ProcScope(PascalABCCompiler.TreeConverter.compiler_string_consts.xor_name, int16_type); int16_xor = ps; left = new ElementScope(new SymInfo("", SymbolKind.Parameter, ""), int16_type, int16_type); right = new ElementScope(new SymInfo("", SymbolKind.Parameter, ""), int16_type, int16_type); ps.return_type = int16_type; ps.AddParameter(left); ps.AddParameter(right); int16_type.AddName(PascalABCCompiler.TreeConverter.compiler_string_consts.xor_name, ps); //int64 ps = new ProcScope(PascalABCCompiler.TreeConverter.compiler_string_consts.plus_name, int64_type); int64_plus = ps; left = new ElementScope(new SymInfo("", SymbolKind.Parameter, ""), int64_type, int64_type); right = new ElementScope(new SymInfo("", SymbolKind.Parameter, ""), int64_type, int64_type); ps.return_type = int64_type; ps.AddParameter(left); ps.AddParameter(right); int64_type.AddName(PascalABCCompiler.TreeConverter.compiler_string_consts.plus_name, ps); ps = new ProcScope(PascalABCCompiler.TreeConverter.compiler_string_consts.minus_name, int64_type); int64_minus = ps; left = new ElementScope(new SymInfo("", SymbolKind.Parameter, ""), int64_type, int64_type); right = new ElementScope(new SymInfo("", SymbolKind.Parameter, ""), int64_type, int64_type); ps.return_type = int64_type; ps.AddParameter(left); ps.AddParameter(right); int64_type.AddName(PascalABCCompiler.TreeConverter.compiler_string_consts.minus_name, ps); ps = new ProcScope(PascalABCCompiler.TreeConverter.compiler_string_consts.mul_name, int64_type); int64_mul = ps; left = new ElementScope(new SymInfo("", SymbolKind.Parameter, ""), int64_type, int64_type); right = new ElementScope(new SymInfo("", SymbolKind.Parameter, ""), int64_type, int64_type); ps.return_type = int64_type; ps.AddParameter(left); ps.AddParameter(right); int64_type.AddName(PascalABCCompiler.TreeConverter.compiler_string_consts.mul_name, ps); ps = new ProcScope(PascalABCCompiler.TreeConverter.compiler_string_consts.idiv_name, int64_type); int64_div = ps; left = new ElementScope(new SymInfo("", SymbolKind.Parameter, ""), int64_type, int64_type); right = new ElementScope(new SymInfo("", SymbolKind.Parameter, ""), int64_type, int64_type); ps.return_type = int64_type; ps.AddParameter(left); ps.AddParameter(right); int64_type.AddName(PascalABCCompiler.TreeConverter.compiler_string_consts.idiv_name, ps); ps = new ProcScope(PascalABCCompiler.TreeConverter.compiler_string_consts.mod_name, int64_type); int64_mod = ps; left = new ElementScope(new SymInfo("", SymbolKind.Parameter, ""), int64_type, int64_type); right = new ElementScope(new SymInfo("", SymbolKind.Parameter, ""), int64_type, int64_type); ps.return_type = int64_type; ps.AddParameter(left); ps.AddParameter(right); int64_type.AddName(PascalABCCompiler.TreeConverter.compiler_string_consts.mod_name, ps); ps = new ProcScope(PascalABCCompiler.TreeConverter.compiler_string_consts.shl_name, int64_type); int64_shl = ps; left = new ElementScope(new SymInfo("", SymbolKind.Parameter, ""), int64_type, int64_type); right = new ElementScope(new SymInfo("", SymbolKind.Parameter, ""), int64_type, int64_type); ps.return_type = int64_type; ps.AddParameter(left); ps.AddParameter(right); int64_type.AddName(PascalABCCompiler.TreeConverter.compiler_string_consts.shl_name, ps); ps = new ProcScope(PascalABCCompiler.TreeConverter.compiler_string_consts.shr_name, int64_type); int64_shr = ps; left = new ElementScope(new SymInfo("", SymbolKind.Parameter, ""), int64_type, int64_type); right = new ElementScope(new SymInfo("", SymbolKind.Parameter, ""), int64_type, int64_type); ps.return_type = int64_type; ps.AddParameter(left); ps.AddParameter(right); int64_type.AddName(PascalABCCompiler.TreeConverter.compiler_string_consts.shr_name, ps); ps = new ProcScope(PascalABCCompiler.TreeConverter.compiler_string_consts.and_name, int64_type); int64_and = ps; left = new ElementScope(new SymInfo("", SymbolKind.Parameter, ""), int64_type, int64_type); right = new ElementScope(new SymInfo("", SymbolKind.Parameter, ""), int64_type, int64_type); ps.return_type = int64_type; ps.AddParameter(left); ps.AddParameter(right); int64_type.AddName(PascalABCCompiler.TreeConverter.compiler_string_consts.and_name, ps); ps = new ProcScope(PascalABCCompiler.TreeConverter.compiler_string_consts.or_name, int64_type); int64_or = ps; left = new ElementScope(new SymInfo("", SymbolKind.Parameter, ""), int64_type, int64_type); right = new ElementScope(new SymInfo("", SymbolKind.Parameter, ""), int64_type, int64_type); ps.return_type = int64_type; ps.AddParameter(left); ps.AddParameter(right); int64_type.AddName(PascalABCCompiler.TreeConverter.compiler_string_consts.or_name, ps); ps = new ProcScope(PascalABCCompiler.TreeConverter.compiler_string_consts.xor_name, int64_type); int64_xor = ps; left = new ElementScope(new SymInfo("", SymbolKind.Parameter, ""), int64_type, int64_type); right = new ElementScope(new SymInfo("", SymbolKind.Parameter, ""), int64_type, int64_type); ps.return_type = int64_type; ps.AddParameter(left); ps.AddParameter(right); int64_type.AddName(PascalABCCompiler.TreeConverter.compiler_string_consts.xor_name, ps); ps = new ProcScope(PascalABCCompiler.TreeConverter.compiler_string_consts.eq_name, int64_type); int64_eq = ps; left = new ElementScope(new SymInfo("", SymbolKind.Parameter, ""), int64_type, int64_type); right = new ElementScope(new SymInfo("", SymbolKind.Parameter, ""), int64_type, int64_type); ps.return_type = bool_type; ps.AddParameter(left); ps.AddParameter(right); int64_type.AddName(PascalABCCompiler.TreeConverter.compiler_string_consts.eq_name, ps); ps = new ProcScope(PascalABCCompiler.TreeConverter.compiler_string_consts.noteq_name, int64_type); int64_noteq = ps; left = new ElementScope(new SymInfo("", SymbolKind.Parameter, ""), int64_type, int64_type); right = new ElementScope(new SymInfo("", SymbolKind.Parameter, ""), int64_type, int64_type); ps.return_type = bool_type; ps.AddParameter(left); ps.AddParameter(right); int64_type.AddName(PascalABCCompiler.TreeConverter.compiler_string_consts.noteq_name, ps); ps = new ProcScope(PascalABCCompiler.TreeConverter.compiler_string_consts.sm_name, int64_type); int64_sm = ps; left = new ElementScope(new SymInfo("", SymbolKind.Parameter, ""), int64_type, int64_type); right = new ElementScope(new SymInfo("", SymbolKind.Parameter, ""), int64_type, int64_type); ps.return_type = bool_type; ps.AddParameter(left); ps.AddParameter(right); int64_type.AddName(PascalABCCompiler.TreeConverter.compiler_string_consts.sm_name, ps); ps = new ProcScope(PascalABCCompiler.TreeConverter.compiler_string_consts.smeq_name, int64_type); int64_smeq = ps; left = new ElementScope(new SymInfo("", SymbolKind.Parameter, ""), int64_type, int64_type); right = new ElementScope(new SymInfo("", SymbolKind.Parameter, ""), int64_type, int64_type); ps.return_type = bool_type; ps.AddParameter(left); ps.AddParameter(right); int64_type.AddName(PascalABCCompiler.TreeConverter.compiler_string_consts.smeq_name, ps); ps = new ProcScope(PascalABCCompiler.TreeConverter.compiler_string_consts.gr_name, int64_type); int64_gr = ps; left = new ElementScope(new SymInfo("", SymbolKind.Parameter, ""), int64_type, int64_type); right = new ElementScope(new SymInfo("", SymbolKind.Parameter, ""), int64_type, int64_type); ps.return_type = bool_type; ps.AddParameter(left); ps.AddParameter(right); int64_type.AddName(PascalABCCompiler.TreeConverter.compiler_string_consts.gr_name, ps); ps = new ProcScope(PascalABCCompiler.TreeConverter.compiler_string_consts.greq_name, int64_type); int64_greq = ps; left = new ElementScope(new SymInfo("", SymbolKind.Parameter, ""), int64_type, int64_type); right = new ElementScope(new SymInfo("", SymbolKind.Parameter, ""), int64_type, int64_type); ps.return_type = bool_type; ps.AddParameter(left); ps.AddParameter(right); int64_type.AddName(PascalABCCompiler.TreeConverter.compiler_string_consts.greq_name, ps); //uint //int16 uint32_type.AddName(PascalABCCompiler.TreeConverter.compiler_string_consts.plus_name, int64_plus); uint32_type.AddName(PascalABCCompiler.TreeConverter.compiler_string_consts.minus_name, int64_minus); uint32_type.AddName(PascalABCCompiler.TreeConverter.compiler_string_consts.mul_name, int64_mul); uint32_type.AddName(PascalABCCompiler.TreeConverter.compiler_string_consts.idiv_name, int64_div); uint32_type.AddName(PascalABCCompiler.TreeConverter.compiler_string_consts.mod_name, int64_mod); uint32_type.AddName(PascalABCCompiler.TreeConverter.compiler_string_consts.shl_name, int64_shl); uint32_type.AddName(PascalABCCompiler.TreeConverter.compiler_string_consts.shr_name, int64_shr); uint32_type.AddName(PascalABCCompiler.TreeConverter.compiler_string_consts.eq_name, int64_eq); uint32_type.AddName(PascalABCCompiler.TreeConverter.compiler_string_consts.noteq_name, int64_noteq); uint32_type.AddName(PascalABCCompiler.TreeConverter.compiler_string_consts.sm_name, int64_sm); uint32_type.AddName(PascalABCCompiler.TreeConverter.compiler_string_consts.smeq_name, int64_smeq); uint32_type.AddName(PascalABCCompiler.TreeConverter.compiler_string_consts.gr_name, int64_gr); uint32_type.AddName(PascalABCCompiler.TreeConverter.compiler_string_consts.greq_name, int64_greq); ps = new ProcScope(PascalABCCompiler.TreeConverter.compiler_string_consts.and_name, uint32_type); uint32_and = ps; left = new ElementScope(new SymInfo("", SymbolKind.Parameter, ""), uint32_type, uint32_type); right = new ElementScope(new SymInfo("", SymbolKind.Parameter, ""), uint32_type, uint32_type); ps.return_type = uint32_type; ps.AddParameter(left); ps.AddParameter(right); uint32_type.AddName(PascalABCCompiler.TreeConverter.compiler_string_consts.and_name, ps); ps = new ProcScope(PascalABCCompiler.TreeConverter.compiler_string_consts.or_name, uint32_type); uint32_or = ps; left = new ElementScope(new SymInfo("", SymbolKind.Parameter, ""), uint32_type, uint32_type); right = new ElementScope(new SymInfo("", SymbolKind.Parameter, ""), uint32_type, uint32_type); ps.return_type = uint32_type; ps.AddParameter(left); ps.AddParameter(right); uint32_type.AddName(PascalABCCompiler.TreeConverter.compiler_string_consts.or_name, ps); ps = new ProcScope(PascalABCCompiler.TreeConverter.compiler_string_consts.xor_name, uint32_type); uint32_xor = ps; left = new ElementScope(new SymInfo("", SymbolKind.Parameter, ""), uint32_type, uint32_type); right = new ElementScope(new SymInfo("", SymbolKind.Parameter, ""), uint32_type, uint32_type); ps.return_type = uint32_type; ps.AddParameter(left); ps.AddParameter(right); uint32_type.AddName(PascalABCCompiler.TreeConverter.compiler_string_consts.xor_name, ps); //uint64 type uint64_type.AddName(PascalABCCompiler.TreeConverter.compiler_string_consts.plus_name, int64_plus); uint64_type.AddName(PascalABCCompiler.TreeConverter.compiler_string_consts.minus_name, int64_minus); uint64_type.AddName(PascalABCCompiler.TreeConverter.compiler_string_consts.mul_name, int64_mul); uint64_type.AddName(PascalABCCompiler.TreeConverter.compiler_string_consts.idiv_name, int64_div); uint64_type.AddName(PascalABCCompiler.TreeConverter.compiler_string_consts.mod_name, int64_mod); uint64_type.AddName(PascalABCCompiler.TreeConverter.compiler_string_consts.shl_name, int64_shl); uint64_type.AddName(PascalABCCompiler.TreeConverter.compiler_string_consts.shr_name, int64_shr); uint64_type.AddName(PascalABCCompiler.TreeConverter.compiler_string_consts.eq_name, int64_eq); uint64_type.AddName(PascalABCCompiler.TreeConverter.compiler_string_consts.noteq_name, int64_noteq); uint64_type.AddName(PascalABCCompiler.TreeConverter.compiler_string_consts.sm_name, int64_sm); uint64_type.AddName(PascalABCCompiler.TreeConverter.compiler_string_consts.smeq_name, int64_smeq); uint64_type.AddName(PascalABCCompiler.TreeConverter.compiler_string_consts.gr_name, int64_gr); uint64_type.AddName(PascalABCCompiler.TreeConverter.compiler_string_consts.greq_name, int64_greq); ps = new ProcScope(PascalABCCompiler.TreeConverter.compiler_string_consts.and_name, uint64_type); uint64_and = ps; left = new ElementScope(new SymInfo("", SymbolKind.Parameter, ""), uint64_type, uint64_type); right = new ElementScope(new SymInfo("", SymbolKind.Parameter, ""), uint64_type, uint64_type); ps.return_type = uint64_type; ps.AddParameter(left); ps.AddParameter(right); uint64_type.AddName(PascalABCCompiler.TreeConverter.compiler_string_consts.and_name, ps); ps = new ProcScope(PascalABCCompiler.TreeConverter.compiler_string_consts.or_name, uint64_type); uint64_or = ps; left = new ElementScope(new SymInfo("", SymbolKind.Parameter, ""), uint64_type, uint64_type); right = new ElementScope(new SymInfo("", SymbolKind.Parameter, ""), uint64_type, uint64_type); ps.return_type = uint64_type; ps.AddParameter(left); ps.AddParameter(right); uint64_type.AddName(PascalABCCompiler.TreeConverter.compiler_string_consts.or_name, ps); ps = new ProcScope(PascalABCCompiler.TreeConverter.compiler_string_consts.xor_name, uint64_type); uint64_xor = ps; left = new ElementScope(new SymInfo("", SymbolKind.Parameter, ""), uint64_type, uint64_type); right = new ElementScope(new SymInfo("", SymbolKind.Parameter, ""), uint64_type, uint64_type); ps.return_type = uint64_type; ps.AddParameter(left); ps.AddParameter(right); uint64_type.AddName(PascalABCCompiler.TreeConverter.compiler_string_consts.xor_name, ps); //real_type ps = new ProcScope(PascalABCCompiler.TreeConverter.compiler_string_consts.plus_name, real_type); real_plus = ps; left = new ElementScope(new SymInfo("", SymbolKind.Parameter, ""), real_type, real_type); right = new ElementScope(new SymInfo("", SymbolKind.Parameter, ""), real_type, real_type); ps.return_type = real_type; ps.AddParameter(left); ps.AddParameter(right); real_type.AddName(PascalABCCompiler.TreeConverter.compiler_string_consts.plus_name, ps); ps = new ProcScope(PascalABCCompiler.TreeConverter.compiler_string_consts.minus_name, real_type); real_minus = ps; left = new ElementScope(new SymInfo("", SymbolKind.Parameter, ""), real_type, real_type); right = new ElementScope(new SymInfo("", SymbolKind.Parameter, ""), real_type, real_type); ps.return_type = real_type; ps.AddParameter(left); ps.AddParameter(right); real_type.AddName(PascalABCCompiler.TreeConverter.compiler_string_consts.minus_name, ps); ps = new ProcScope(PascalABCCompiler.TreeConverter.compiler_string_consts.mul_name, real_type); real_mul = ps; left = new ElementScope(new SymInfo("", SymbolKind.Parameter, ""), real_type, real_type); right = new ElementScope(new SymInfo("", SymbolKind.Parameter, ""), real_type, real_type); ps.return_type = real_type; ps.AddParameter(left); ps.AddParameter(right); real_type.AddName(PascalABCCompiler.TreeConverter.compiler_string_consts.mul_name, ps); ps = new ProcScope(PascalABCCompiler.TreeConverter.compiler_string_consts.div_name, real_type); real_div = ps; left = new ElementScope(new SymInfo("", SymbolKind.Parameter, ""), real_type, real_type); right = new ElementScope(new SymInfo("", SymbolKind.Parameter, ""), real_type, real_type); ps.return_type = real_type; ps.AddParameter(left); ps.AddParameter(right); real_type.AddName(PascalABCCompiler.TreeConverter.compiler_string_consts.div_name, ps); ps = new ProcScope(PascalABCCompiler.TreeConverter.compiler_string_consts.eq_name, real_type); real_eq = ps; left = new ElementScope(new SymInfo("", SymbolKind.Parameter, ""), real_type, real_type); right = new ElementScope(new SymInfo("", SymbolKind.Parameter, ""), real_type, real_type); ps.return_type = real_type; ps.AddParameter(left); ps.AddParameter(right); real_type.AddName(PascalABCCompiler.TreeConverter.compiler_string_consts.eq_name, ps); ps = new ProcScope(PascalABCCompiler.TreeConverter.compiler_string_consts.noteq_name, real_type); real_noteq = ps; left = new ElementScope(new SymInfo("", SymbolKind.Parameter, ""), real_type, real_type); right = new ElementScope(new SymInfo("", SymbolKind.Parameter, ""), real_type, real_type); ps.return_type = bool_type; ps.AddParameter(left); ps.AddParameter(right); real_type.AddName(PascalABCCompiler.TreeConverter.compiler_string_consts.noteq_name, ps); ps = new ProcScope(PascalABCCompiler.TreeConverter.compiler_string_consts.sm_name, real_type); real_sm = ps; left = new ElementScope(new SymInfo("", SymbolKind.Parameter, ""), real_type, real_type); right = new ElementScope(new SymInfo("", SymbolKind.Parameter, ""), real_type, real_type); ps.return_type = bool_type; ps.AddParameter(left); ps.AddParameter(right); real_type.AddName(PascalABCCompiler.TreeConverter.compiler_string_consts.sm_name, ps); ps = new ProcScope(PascalABCCompiler.TreeConverter.compiler_string_consts.smeq_name, real_type); real_smeq = ps; left = new ElementScope(new SymInfo("", SymbolKind.Parameter, ""), real_type, real_type); right = new ElementScope(new SymInfo("", SymbolKind.Parameter, ""), real_type, real_type); ps.return_type = bool_type; ps.AddParameter(left); ps.AddParameter(right); real_type.AddName(PascalABCCompiler.TreeConverter.compiler_string_consts.smeq_name, ps); ps = new ProcScope(PascalABCCompiler.TreeConverter.compiler_string_consts.gr_name, real_type); real_gr = ps; left = new ElementScope(new SymInfo("", SymbolKind.Parameter, ""), real_type, real_type); right = new ElementScope(new SymInfo("", SymbolKind.Parameter, ""), real_type, real_type); ps.return_type = bool_type; ps.AddParameter(left); ps.AddParameter(right); real_type.AddName(PascalABCCompiler.TreeConverter.compiler_string_consts.gr_name, ps); ps = new ProcScope(PascalABCCompiler.TreeConverter.compiler_string_consts.greq_name, int64_type); real_greq = ps; left = new ElementScope(new SymInfo("", SymbolKind.Parameter, ""), int64_type, int64_type); right = new ElementScope(new SymInfo("", SymbolKind.Parameter, ""), int64_type, int64_type); ps.return_type = bool_type; ps.AddParameter(left); ps.AddParameter(right); real_type.AddName(PascalABCCompiler.TreeConverter.compiler_string_consts.greq_name, ps); int_type.AddName(PascalABCCompiler.TreeConverter.compiler_string_consts.plus_name, int64_plus); int_type.AddName(PascalABCCompiler.TreeConverter.compiler_string_consts.minus_name, int64_minus); int_type.AddName(PascalABCCompiler.TreeConverter.compiler_string_consts.mul_name, int64_mul); int_type.AddName(PascalABCCompiler.TreeConverter.compiler_string_consts.div_name, int64_div); int_type.AddName(PascalABCCompiler.TreeConverter.compiler_string_consts.mod_name, int64_mod); int_type.AddName(PascalABCCompiler.TreeConverter.compiler_string_consts.shl_name, int64_shl); int_type.AddName(PascalABCCompiler.TreeConverter.compiler_string_consts.shr_name, int64_shr); int_type.AddName(PascalABCCompiler.TreeConverter.compiler_string_consts.eq_name, int64_eq); int_type.AddName(PascalABCCompiler.TreeConverter.compiler_string_consts.noteq_name, int64_noteq); int_type.AddName(PascalABCCompiler.TreeConverter.compiler_string_consts.sm_name, int64_sm); int_type.AddName(PascalABCCompiler.TreeConverter.compiler_string_consts.smeq_name, int64_smeq); int_type.AddName(PascalABCCompiler.TreeConverter.compiler_string_consts.gr_name, int64_gr); int_type.AddName(PascalABCCompiler.TreeConverter.compiler_string_consts.greq_name, int64_greq); int_type.AddName(PascalABCCompiler.TreeConverter.compiler_string_consts.plus_name, real_plus); int_type.AddName(PascalABCCompiler.TreeConverter.compiler_string_consts.minus_name, real_minus); int_type.AddName(PascalABCCompiler.TreeConverter.compiler_string_consts.mul_name, real_mul); int_type.AddName(PascalABCCompiler.TreeConverter.compiler_string_consts.div_name, real_div); int_type.AddName(PascalABCCompiler.TreeConverter.compiler_string_consts.eq_name, real_eq); int_type.AddName(PascalABCCompiler.TreeConverter.compiler_string_consts.noteq_name, real_noteq); int_type.AddName(PascalABCCompiler.TreeConverter.compiler_string_consts.sm_name, real_sm); int_type.AddName(PascalABCCompiler.TreeConverter.compiler_string_consts.smeq_name, real_smeq); int_type.AddName(PascalABCCompiler.TreeConverter.compiler_string_consts.gr_name, real_gr); int_type.AddName(PascalABCCompiler.TreeConverter.compiler_string_consts.greq_name, real_greq); int64_type.AddName(PascalABCCompiler.TreeConverter.compiler_string_consts.plus_name, real_plus); int64_type.AddName(PascalABCCompiler.TreeConverter.compiler_string_consts.minus_name, real_minus); int64_type.AddName(PascalABCCompiler.TreeConverter.compiler_string_consts.mul_name, real_mul); int64_type.AddName(PascalABCCompiler.TreeConverter.compiler_string_consts.div_name, real_div); int64_type.AddName(PascalABCCompiler.TreeConverter.compiler_string_consts.eq_name, real_eq); int64_type.AddName(PascalABCCompiler.TreeConverter.compiler_string_consts.noteq_name, real_noteq); int64_type.AddName(PascalABCCompiler.TreeConverter.compiler_string_consts.sm_name, real_sm); int64_type.AddName(PascalABCCompiler.TreeConverter.compiler_string_consts.smeq_name, real_smeq); int64_type.AddName(PascalABCCompiler.TreeConverter.compiler_string_consts.gr_name, real_gr); int64_type.AddName(PascalABCCompiler.TreeConverter.compiler_string_consts.greq_name, real_greq); //boolean type ps = new ProcScope(PascalABCCompiler.TreeConverter.compiler_string_consts.and_name, bool_type); bool_and = ps; left = new ElementScope(new SymInfo("", SymbolKind.Parameter, ""), bool_type, bool_type); right = new ElementScope(new SymInfo("", SymbolKind.Parameter, ""), bool_type, bool_type); ps.return_type = bool_type; ps.AddParameter(left); ps.AddParameter(right); bool_type.AddName(PascalABCCompiler.TreeConverter.compiler_string_consts.and_name, ps); ps = new ProcScope(PascalABCCompiler.TreeConverter.compiler_string_consts.or_name, bool_type); bool_or = ps; left = new ElementScope(new SymInfo("", SymbolKind.Parameter, ""), bool_type, bool_type); right = new ElementScope(new SymInfo("", SymbolKind.Parameter, ""), bool_type, bool_type); ps.return_type = bool_type; ps.AddParameter(left); ps.AddParameter(right); bool_type.AddName(PascalABCCompiler.TreeConverter.compiler_string_consts.or_name, ps); ps = new ProcScope(PascalABCCompiler.TreeConverter.compiler_string_consts.xor_name, bool_type); bool_xor = ps; left = new ElementScope(new SymInfo("", SymbolKind.Parameter, ""), bool_type, bool_type); right = new ElementScope(new SymInfo("", SymbolKind.Parameter, ""), bool_type, bool_type); ps.return_type = bool_type; ps.AddParameter(left); ps.AddParameter(right); bool_type.AddName(PascalABCCompiler.TreeConverter.compiler_string_consts.xor_name, ps); ps = new ProcScope(PascalABCCompiler.TreeConverter.compiler_string_consts.eq_name, bool_type); bool_eq = ps; left = new ElementScope(new SymInfo("", SymbolKind.Parameter, ""), bool_type, bool_type); right = new ElementScope(new SymInfo("", SymbolKind.Parameter, ""), bool_type, bool_type); ps.return_type = bool_type; ps.AddParameter(left); ps.AddParameter(right); bool_type.AddName(PascalABCCompiler.TreeConverter.compiler_string_consts.eq_name, ps); ps = new ProcScope(PascalABCCompiler.TreeConverter.compiler_string_consts.noteq_name, bool_type); bool_noteq = ps; left = new ElementScope(new SymInfo("", SymbolKind.Parameter, ""), bool_type, bool_type); right = new ElementScope(new SymInfo("", SymbolKind.Parameter, ""), bool_type, bool_type); ps.return_type = bool_type; ps.AddParameter(left); ps.AddParameter(right); bool_type.AddName(PascalABCCompiler.TreeConverter.compiler_string_consts.noteq_name, ps); ps = new ProcScope(PascalABCCompiler.TreeConverter.compiler_string_consts.sm_name, bool_type); bool_sm = ps; left = new ElementScope(new SymInfo("", SymbolKind.Parameter, ""), bool_type, bool_type); right = new ElementScope(new SymInfo("", SymbolKind.Parameter, ""), bool_type, bool_type); ps.return_type = bool_type; ps.AddParameter(left); ps.AddParameter(right); bool_type.AddName(PascalABCCompiler.TreeConverter.compiler_string_consts.sm_name, ps); ps = new ProcScope(PascalABCCompiler.TreeConverter.compiler_string_consts.smeq_name, bool_type); bool_smeq = ps; left = new ElementScope(new SymInfo("", SymbolKind.Parameter, ""), bool_type, bool_type); right = new ElementScope(new SymInfo("", SymbolKind.Parameter, ""), bool_type, bool_type); ps.return_type = bool_type; ps.AddParameter(left); ps.AddParameter(right); bool_type.AddName(PascalABCCompiler.TreeConverter.compiler_string_consts.smeq_name, ps); ps = new ProcScope(PascalABCCompiler.TreeConverter.compiler_string_consts.gr_name, bool_type); bool_gr = ps; left = new ElementScope(new SymInfo("", SymbolKind.Parameter, ""), bool_type, bool_type); right = new ElementScope(new SymInfo("", SymbolKind.Parameter, ""), bool_type, bool_type); ps.return_type = bool_type; ps.AddParameter(left); ps.AddParameter(right); bool_type.AddName(PascalABCCompiler.TreeConverter.compiler_string_consts.gr_name, ps); ps = new ProcScope(PascalABCCompiler.TreeConverter.compiler_string_consts.greq_name, bool_type); bool_greq = ps; left = new ElementScope(new SymInfo("", SymbolKind.Parameter, ""), bool_type, bool_type); right = new ElementScope(new SymInfo("", SymbolKind.Parameter, ""), bool_type, bool_type); ps.return_type = bool_type; ps.AddParameter(left); ps.AddParameter(right); bool_type.AddName(PascalABCCompiler.TreeConverter.compiler_string_consts.greq_name, ps); //char type ps = new ProcScope(PascalABCCompiler.TreeConverter.compiler_string_consts.eq_name, char_type); char_eq = ps; left = new ElementScope(new SymInfo("", SymbolKind.Parameter, ""), char_type, char_type); right = new ElementScope(new SymInfo("", SymbolKind.Parameter, ""), char_type, char_type); ps.return_type = bool_type; ps.AddParameter(left); ps.AddParameter(right); char_type.AddName(PascalABCCompiler.TreeConverter.compiler_string_consts.eq_name, ps); ps = new ProcScope(PascalABCCompiler.TreeConverter.compiler_string_consts.noteq_name, char_type); char_noteq = ps; left = new ElementScope(new SymInfo("", SymbolKind.Parameter, ""), char_type, char_type); right = new ElementScope(new SymInfo("", SymbolKind.Parameter, ""), char_type, char_type); ps.return_type = bool_type; ps.AddParameter(left); ps.AddParameter(right); char_type.AddName(PascalABCCompiler.TreeConverter.compiler_string_consts.noteq_name, ps); ps = new ProcScope(PascalABCCompiler.TreeConverter.compiler_string_consts.sm_name, char_type); char_sm = ps; left = new ElementScope(new SymInfo("", SymbolKind.Parameter, ""), char_type, char_type); right = new ElementScope(new SymInfo("", SymbolKind.Parameter, ""), char_type, char_type); ps.return_type = bool_type; ps.AddParameter(left); ps.AddParameter(right); char_type.AddName(PascalABCCompiler.TreeConverter.compiler_string_consts.sm_name, ps); ps = new ProcScope(PascalABCCompiler.TreeConverter.compiler_string_consts.smeq_name, char_type); char_smeq = ps; left = new ElementScope(new SymInfo("", SymbolKind.Parameter, ""), char_type, char_type); right = new ElementScope(new SymInfo("", SymbolKind.Parameter, ""), char_type, char_type); ps.return_type = bool_type; ps.AddParameter(left); ps.AddParameter(right); char_type.AddName(PascalABCCompiler.TreeConverter.compiler_string_consts.smeq_name, ps); ps = new ProcScope(PascalABCCompiler.TreeConverter.compiler_string_consts.greq_name, char_type); char_greq = ps; left = new ElementScope(new SymInfo("", SymbolKind.Parameter, ""), char_type, char_type); right = new ElementScope(new SymInfo("", SymbolKind.Parameter, ""), char_type, char_type); ps.return_type = bool_type; ps.AddParameter(left); ps.AddParameter(right); char_type.AddName(PascalABCCompiler.TreeConverter.compiler_string_consts.greq_name, ps); ps = new ProcScope(PascalABCCompiler.TreeConverter.compiler_string_consts.gr_name, char_type); char_gr = ps; left = new ElementScope(new SymInfo("", SymbolKind.Parameter, ""), char_type, char_type); right = new ElementScope(new SymInfo("", SymbolKind.Parameter, ""), char_type, char_type); ps.return_type = bool_type; ps.AddParameter(left); ps.AddParameter(right); char_type.AddName(PascalABCCompiler.TreeConverter.compiler_string_consts.gr_name, ps); //string type ps = new ProcScope(PascalABCCompiler.TreeConverter.compiler_string_consts.plus_name, string_type); string_plus = ps; left = new ElementScope(new SymInfo("", SymbolKind.Parameter, ""), string_type, string_type); right = new ElementScope(new SymInfo("", SymbolKind.Parameter, ""), string_type, string_type); ps.return_type = string_type; ps.AddParameter(left); ps.AddParameter(right); string_type.AddName(PascalABCCompiler.TreeConverter.compiler_string_consts.plus_name, ps); ps = new ProcScope(PascalABCCompiler.TreeConverter.compiler_string_consts.eq_name, string_type); string_eq = ps; left = new ElementScope(new SymInfo("", SymbolKind.Parameter, ""), string_type, string_type); right = new ElementScope(new SymInfo("", SymbolKind.Parameter, ""), string_type, string_type); ps.return_type = bool_type; ps.AddParameter(left); ps.AddParameter(right); string_type.AddName(PascalABCCompiler.TreeConverter.compiler_string_consts.eq_name, ps); ps = new ProcScope(PascalABCCompiler.TreeConverter.compiler_string_consts.noteq_name, string_type); string_noteq = ps; left = new ElementScope(new SymInfo("", SymbolKind.Parameter, ""), string_type, string_type); right = new ElementScope(new SymInfo("", SymbolKind.Parameter, ""), string_type, string_type); ps.return_type = bool_type; ps.AddParameter(left); ps.AddParameter(right); string_type.AddName(PascalABCCompiler.TreeConverter.compiler_string_consts.noteq_name, ps); ps = new ProcScope(PascalABCCompiler.TreeConverter.compiler_string_consts.sm_name, string_type); string_sm = ps; left = new ElementScope(new SymInfo("", SymbolKind.Parameter, ""), string_type, string_type); right = new ElementScope(new SymInfo("", SymbolKind.Parameter, ""), string_type, string_type); ps.return_type = bool_type; ps.AddParameter(left); ps.AddParameter(right); string_type.AddName(PascalABCCompiler.TreeConverter.compiler_string_consts.sm_name, ps); ps = new ProcScope(PascalABCCompiler.TreeConverter.compiler_string_consts.smeq_name, string_type); string_smeq = ps; left = new ElementScope(new SymInfo("", SymbolKind.Parameter, ""), string_type, string_type); right = new ElementScope(new SymInfo("", SymbolKind.Parameter, ""), string_type, string_type); ps.return_type = bool_type; ps.AddParameter(left); ps.AddParameter(right); string_type.AddName(PascalABCCompiler.TreeConverter.compiler_string_consts.smeq_name, ps); ps = new ProcScope(PascalABCCompiler.TreeConverter.compiler_string_consts.gr_name, string_type); string_gr = ps; left = new ElementScope(new SymInfo("", SymbolKind.Parameter, ""), string_type, string_type); right = new ElementScope(new SymInfo("", SymbolKind.Parameter, ""), string_type, string_type); ps.return_type = bool_type; ps.AddParameter(left); ps.AddParameter(right); string_type.AddName(PascalABCCompiler.TreeConverter.compiler_string_consts.gr_name, ps); ps = new ProcScope(PascalABCCompiler.TreeConverter.compiler_string_consts.greq_name, string_type); string_greq = ps; left = new ElementScope(new SymInfo("", SymbolKind.Parameter, ""), string_type, string_type); right = new ElementScope(new SymInfo("", SymbolKind.Parameter, ""), string_type, string_type); ps.return_type = bool_type; ps.AddParameter(left); ps.AddParameter(right); string_type.AddName(PascalABCCompiler.TreeConverter.compiler_string_consts.greq_name, ps); }
public override void visit(procedure_header _procedure_header) { //throw new Exception("The method or operation is not implemented."); SymScope topScope; ProcScope ps = null; bool not_def = false; ProcRealization pr = null; bool is_realization = false; location loc = get_location(_procedure_header); if (_procedure_header.name != null) { _procedure_header.name.visit(this); if (_procedure_header.name.class_name != null) { topScope = null; if (_procedure_header.name.ln != null && _procedure_header.name.ln.Count > 0) { SymScope tmp_scope = cur_scope; for (int i = 0; i < _procedure_header.name.ln.Count; i++) { tmp_scope = tmp_scope.FindName(_procedure_header.name.ln[i].name); if (tmp_scope == null) break; } topScope = tmp_scope; } else topScope = cur_scope.FindName(_procedure_header.name.class_name.name); if (topScope != null) { ps = topScope.FindNameOnlyInThisType(meth_name) as ProcScope; if (ps != null && ps is CompiledMethodScope) ps = null; if (ps == null) { ps = new ProcScope(meth_name, topScope); ps.head_loc = loc; bool ext = false; if (topScope is CompiledScope || topScope is ArrayScope || topScope is TypeSynonim && ((topScope as TypeSynonim).actType is CompiledScope || (topScope as TypeSynonim).actType is ArrayScope || (topScope as TypeSynonim).actType is DiapasonScope)) ext = true; else if (!(topScope is TypeSynonim) && !(topScope is PointerScope) && !(topScope is SetScope) && !(topScope is FileScope)) ext = true; if (ext) { not_def = true; ps.is_extension = true; ps.AddName("self", new ElementScope(new SymInfo("self", SymbolKind.Parameter, "self"), topScope, cur_scope)); ps.declaringType = topScope as TypeScope; TypeScope ts = topScope as TypeScope; if (topScope is TypeSynonim) ts = (ts as TypeSynonim).actType; this.entry_scope.AddExtensionMethod(meth_name, ps, ts); topScope.AddExtensionMethod(meth_name, ps, ts); } } //while (ps != null && ps.already_defined) ps = ps.nextProc; else ps = select_function_definition(ps, _procedure_header.parameters, null, topScope as TypeScope); if (ps == null) { ps = new ProcScope(meth_name, cur_scope); ps.head_loc = loc; } if (ps.parameters.Count != 0 && _procedure_header.parameters != null && is_proc_realization) { ps.parameters.Clear(); ps.already_defined = true; } if (impl_scope == null) { pr = new ProcRealization(ps, cur_scope); pr.already_defined = true; ps.proc_realization = pr; pr.loc = cur_loc; pr.head_loc = loc; is_realization = true; entry_scope.AddName("$method", pr); } else { pr = new ProcRealization(ps, impl_scope); pr.already_defined = true; ps.proc_realization = pr; pr.loc = cur_loc; is_realization = true; pr.head_loc = loc; impl_scope.AddName("$method", pr); } } else { ps = new ProcScope(meth_name, cur_scope); ps.head_loc = loc; } } else { ps = new ProcScope(meth_name, cur_scope); if (has_extensionmethod_attr(_procedure_header.proc_attributes.proc_attributes) && _procedure_header.parameters.params_list.Count > 0) { ps.is_extension = true; _procedure_header.parameters.params_list[0].vars_type.visit(this); topScope = returned_scope; ps.declaringType = topScope as TypeScope; TypeScope ts = topScope as TypeScope; if (topScope is TypeSynonim) ts = (ts as TypeSynonim).actType; if (ts.original_type != null && ts.instances != null) { bool pure_instance = true; foreach (TypeScope gen_arg in ts.instances) { if (!(gen_arg is TemplateParameterScope)) pure_instance = false; } if (pure_instance) ts = ts.original_type; } this.entry_scope.AddExtensionMethod(meth_name, ps, ts); topScope.AddExtensionMethod(meth_name, ps, ts); pr = new ProcRealization(ps, cur_scope); pr.already_defined = true; ps.proc_realization = pr; pr.loc = cur_loc; pr.head_loc = loc; if (impl_scope != null) impl_scope.AddName("$method", pr); else this.entry_scope.AddName("$method", pr); } ps.head_loc = loc; if (!ps.is_extension) { if (IsForward(_procedure_header)) { cur_scope.AddName(meth_name, ps); ps.is_forward = true; } else { bool found_in_top = false; SymScope ss = null; if (cur_scope is ImplementationUnitScope) { ss = (cur_scope as ImplementationUnitScope).topScope.FindNameOnlyInThisType(meth_name); if (ss != null && ss is ProcScope) { //ps = ss as ProcScope; //while ((ss as ProcScope).already_defined && (ss as ProcScope).nextProc != null) // ss = (ss as ProcScope).nextProc; ps = select_function_definition(ss as ProcScope, _procedure_header.parameters, null, null); if (ps == null) { ps = new ProcScope(meth_name, cur_scope); ps.head_loc = loc; } //ps = ss as ProcScope; if (ps.parameters.Count != 0 && _procedure_header.parameters != null) { ps.parameters.Clear(); ps.already_defined = true; } pr = new ProcRealization(ps, cur_scope); pr.already_defined = true; pr.loc = cur_loc; ps.proc_realization = pr; pr.head_loc = loc; is_realization = true; cur_scope.AddName("$method", pr); found_in_top = true; } } if (!found_in_top) //ne nashli opisanie v interface chasti modilja { //ss = cur_scope.FindNameOnlyInType(meth_name); ss = cur_scope.FindName(meth_name); if (ss != null && ss is ProcScope) { if ((ss as ProcScope).is_forward) { //if ((ss as ProcScope).parameters.Count != 0 && _procedure_header.parameters != null) (ss as ProcScope).parameters.Clear(); pr = new ProcRealization(ss as ProcScope, cur_scope); pr.already_defined = true; pr.loc = cur_loc; cur_scope.AddName("$method", pr); returned_scope = pr; pr.head_loc = loc; return; } else { ps = new ProcScope(meth_name, cur_scope); ps.head_loc = loc; if (ps.topScope == ss.topScope) { while ((ss as ProcScope).nextProc != null && (ss as ProcScope).nextProc.topScope == ps.topScope) ss = (ss as ProcScope).nextProc; ProcScope tmp_ps = (ss as ProcScope).nextProc; (ss as ProcScope).nextProc = ps; ps.nextProc = tmp_ps; cur_scope.AddName(meth_name, ps); ps.si.name = meth_name; } else { ps.nextProc = ss as ProcScope; cur_scope.AddName(meth_name, ps); } //ps = select_function_definition(ss as ProcScope,_procedure_header.parameters); } } else { cur_scope.AddName(meth_name, ps); } } } } } } else { ps = new ProcScope("", cur_scope); ps.head_loc = loc; } if ((!is_realization || not_def) && ps.loc == null) ps.loc = cur_loc; //ps.head_loc = loc; ps.declaringUnit = entry_scope; if (_procedure_header.template_args != null && !ps.IsGeneric()) { foreach (ident s in _procedure_header.template_args.idents) { ps.AddTemplateParameter(s.name); TemplateParameterScope tps = new TemplateParameterScope(s.name, TypeTable.obj_type, ps); tps.loc = get_location(s); ps.AddName(s.name, tps); } } SetAttributes(ps, _procedure_header.proc_attributes); ps.is_static = _procedure_header.class_keyword; if (add_doc_from_text && this.converter.controller.docs != null && this.converter.controller.docs.ContainsKey(_procedure_header)) ps.AddDocumentation(this.converter.controller.docs[_procedure_header]); if (is_proc_realization) ps.already_defined = true; else { ps.loc = loc; } if (_procedure_header.name == null || _procedure_header.name.class_name == null) { ps.acc_mod = cur_access_mod; ps.si.acc_mod = cur_access_mod; } SymScope tmp = cur_scope; cur_scope = ps; if (_procedure_header.parameters != null) foreach (typed_parameters pars in _procedure_header.parameters.params_list) { pars.vars_type.visit(this); if (returned_scope != null) { if (returned_scope is ProcScope) returned_scope = new ProcType(returned_scope as ProcScope); foreach (ident id in pars.idents.idents) { ElementScope si = new ElementScope(new SymInfo(id.name, SymbolKind.Parameter, id.name), returned_scope, ps); si.loc = get_location(id); si.param_kind = pars.param_kind; if (pars.inital_value != null) { pars.inital_value.visit(this); si.cnst_val = cnst_val.prim_val; } si.MakeDescription(); ps.AddName(id.name, si); ps.AddParameter(si); } } } cur_scope = tmp; if (cur_scope is TypeScope && !ps.is_static) ps.AddName("self", new ElementScope(new SymInfo("self", SymbolKind.Parameter, "self"), cur_scope, ps)); //cur_scope = ps; returned_scope = ps; ps.Complete(); if (pr != null && not_def) pr.Complete(); }
public static string GetParamNames(ProcScope mi) { StringBuilder sb = new StringBuilder(); if (mi.parameters.Count > 0) { sb.Append("("); for (int i=0; i<mi.parameters.Count; i++) { SymScope typ = mi.parameters[i].sc; if (typ is TypeScope) sb.Append(GetTypeName(typ as TypeScope)); if (mi.parameters[i].param_kind == PascalABCCompiler.SyntaxTree.parametr_kind.var_parametr || mi.parameters[i].param_kind == PascalABCCompiler.SyntaxTree.parametr_kind.const_parametr) sb.Append('@'); if (i<mi.parameters.Count-1) sb.Append(','); } sb.Append(")"); } return sb.ToString(); }
public ProcRealization(ProcScope def_proc, SymScope top_mod_scope) { this.def_proc = def_proc; this.top_mod_scope = top_mod_scope; if (def_proc != null) this.topScope = def_proc.topScope; this.si = new SymInfo(def_proc.si.name, def_proc.si.kind, def_proc.si.description); }
public static void AddDescribeToComplete(ProcScope value) { elem_cache.Add(value); }
private ProcScope CreateInterfaceMethod(string name, int offset) { ProcScope cmn = members[offset] as ProcScope; if (cmn != null) return cmn; cmn = new ProcScope(name,cur_scope); cmn.declaringUnit = root_scope; //members[offset] = cmn; AddMember(cmn, offset); int name_ref = br.ReadInt32(); br.ReadByte(); br.ReadByte(); bool is_generic = br.ReadBoolean(); if (is_generic) { throw new NotSupportedException(); } //ssyy //\ssyy if (br.ReadByte() == 1) //return_value_type { cmn.return_type = GetTypeReference(); if (br.ReadByte() == 1) { GetLocalVariable(cmn); } } int num_par = br.ReadInt32(); for (int i = 0; i < num_par; i++) cmn.parameters.Add(GetParameter(cmn)); br.ReadInt32(); br.ReadInt32(); cmn.is_constructor = br.ReadBoolean(); cmn.is_forward = br.ReadBoolean(); br.ReadBoolean(); PascalABCCompiler.SemanticTree.field_access_level fal = (PascalABCCompiler.SemanticTree.field_access_level)br.ReadByte(); PascalABCCompiler.SemanticTree.polymorphic_state ps = (PascalABCCompiler.SemanticTree.polymorphic_state)br.ReadByte(); switch (fal) { case PascalABCCompiler.SemanticTree.field_access_level.fal_internal : cmn.acc_mod = access_modifer.internal_modifer; break; case PascalABCCompiler.SemanticTree.field_access_level.fal_private : cmn.acc_mod = access_modifer.private_modifer; return null; case PascalABCCompiler.SemanticTree.field_access_level.fal_protected : cmn.acc_mod = access_modifer.protected_modifer; break; case PascalABCCompiler.SemanticTree.field_access_level.fal_public : cmn.acc_mod = access_modifer.public_modifer; break; } switch (ps) { case PascalABCCompiler.SemanticTree.polymorphic_state.ps_static : cmn.is_static = true; break; case PascalABCCompiler.SemanticTree.polymorphic_state.ps_virtual : cmn.is_virtual = true; break; } br.ReadInt32(); br.ReadInt32(); cmn.is_override = br.ReadBoolean() == true; cmn.Complete(); return cmn; }