public InternalFunction(string name, string nameContext, CFunctionType functionType) { Name = name; NameContext = nameContext; FunctionType = functionType; Action = _ => { }; }
public CompiledFunction(string name, CFunctionType functionType, Block body = null) { Name = name; FunctionType = functionType; Body = body; LocalVariables = new List <CompiledVariable> (); Instructions = new List <Instruction> (); }
private void Initialize(CILConverter CILConverter, string Name, Lazy <MethodInfo> MethodInfoLazy, SafeMethodTypeInfo SafeMethodTypeInfo = null) { this.Name = Name; this._MethodInfoLazy = MethodInfoLazy; this.SafeMethodTypeInfo = SafeMethodTypeInfo; Type ReturnType; Type[] ParametersType; BodyFinalized = MethodInfoLazy.IsValueCreated; if (SafeMethodTypeInfo != null) { ReturnType = SafeMethodTypeInfo.ReturnType; ParametersType = SafeMethodTypeInfo.Parameters; } else { ReturnType = this.MethodInfo.ReturnType; ParametersType = this.MethodInfo.GetParameters().Select(Item => Item.ParameterType).ToArray(); } var ReturnCType = CILConverter.ConvertTypeToCType(ReturnType); var ParametersCType = new List <CType>(); foreach (var ParameterType in ParametersType) { ParametersCType.Add(CILConverter.ConvertTypeToCType(ParameterType)); } this.CFunctionType = new CFunctionType( ReturnCType, Name, ParametersCType.Select(Item => new CSymbol() { CType = Item }).ToArray() ); }
public CompiledFunction(string name, string nameContext, CFunctionType functionType, Block body = null) : this(name, functionType, body) { NameContext = nameContext; }
/// <summary> /// 通用产生式处理函数 /// </summary> /// <param name="myNode">产生式节点</param> /// <param name="myType">候选式类型</param> /// <param name="mySyntax">节点语法类型</param> /// <param name="myToken">命中单词</param> /// <returns>下一个展开节点的指针</returns> private SyntaxTreeNode Derivate(SyntaxTreeNode myNode, CFunctionType myType, SyntaxType mySyntax, Token myToken) { // 更新节点信息 if (myNode != null) { myNode.NodeType = myType; myNode.NodeValue = myToken.OriginalCodeStr; myNode.NodeSyntaxType = mySyntax; myNode.NodeName = mySyntax.ToString(); myNode.Line = myToken.Line; myNode.Column = myToken.Column; if (myToken.IsVar) { myNode.NodeVarType = myToken.IsGlobal ? VarScopeType.GLOBAL : VarScopeType.LOCAL; } } // 取候选向量 List<SyntaxType> iSvec = this.derivatorTypeDict[Convert.ToInt32(myType)]; // 左边出栈 this.parseStack.Pop(); // 如果她是一个非终结符 if (myType < CFunctionType.DERI_UMI_BOUNDARY) { // 自右向左压匹配栈 for (int i = iSvec.Count - 1; i >= 0; i--) { this.parseStack.Push(iSvec[i]); } // 自左向右构造子节点 bool flag = false; SyntaxTreeNode successor = null; myNode.Children = new List<SyntaxTreeNode>(); for (int i = 0; i < iSvec.Count; i++) { SyntaxTreeNode newNode = new SyntaxTreeNode(); newNode.Parent = myNode; myNode.Children.Add(newNode); if (flag == false) { successor = newNode; flag = true; } } // 返回第一个产生式 return successor; } // 如果她是一个终结符 else { // 递增token指针 if (myType != CFunctionType.umi_epsilon) { this.nextTokenPointer++; } // 返回她的后继 return this.RecursiveDescent(myNode); } }
public FunctionDeclaration(PositionInfo PositionInfo, CFunctionType CFunctionType, CompoundStatement FunctionBody) : base(PositionInfo, FunctionBody) { this.CFunctionType = CFunctionType; this.FunctionBody = FunctionBody; }
private void Initialize(CILConverter CILConverter, string Name, Lazy<MethodInfo> MethodInfoLazy, SafeMethodTypeInfo SafeMethodTypeInfo = null) { this.Name = Name; this._MethodInfoLazy = MethodInfoLazy; this.SafeMethodTypeInfo = SafeMethodTypeInfo; Type ReturnType; Type[] ParametersType; BodyFinalized = MethodInfoLazy.IsValueCreated; if (SafeMethodTypeInfo != null) { ReturnType = SafeMethodTypeInfo.ReturnType; ParametersType = SafeMethodTypeInfo.Parameters; } else { ReturnType = this.MethodInfo.ReturnType; ParametersType = this.MethodInfo.GetParameters().Select(Item => Item.ParameterType).ToArray(); } var ReturnCType = CILConverter.ConvertTypeToCType(ReturnType); var ParametersCType = new List<CType>(); foreach (var ParameterType in ParametersType) { ParametersCType.Add(CILConverter.ConvertTypeToCType(ParameterType)); } this.CFunctionType = new CFunctionType( ReturnCType, Name, ParametersCType.Select(Item => new CSymbol() { CType = Item }).ToArray() ); }
/// <summary> /// 设置候选式处理器 /// </summary> /// <param name="proc">处理函数委托</param> /// <param name="type">候选式类型</param> public void SetProc(iHandle proc, CFunctionType type) { this.candidateProcessor = proc; this.candidateType = type; }
/// <summary> /// 构造函数 /// </summary> /// <param name="proc">处理函数委托</param> /// <param name="type">候选式类型</param> public CandidateFunction(iHandle proc, CFunctionType type) { this.SetProc(proc, type); }