private void CheckSemanticLocal(MoveInfo treeInfo, ScriptInfo scriptInfo, CheckingInfo checkingInfo) { _funcInfo = scriptInfo.FindLocalFunc(_name); if (_funcInfo == null) { _funcInfo = scriptInfo.FindGlobalsFunc(_name); } if (_funcInfo == null) // find in includes { _funcInfo = scriptInfo.FindIncludesFunc(_name); if (_funcInfo == null) { scriptInfo.SF.Errors.Add( new SemanticError("Unknown function '" + _name + "'", treeInfo.GetErrorInfo(treeInfo.Current))); return; } if (_funcInfo.Access != MemberAccess.Public) // private member in include { scriptInfo.SF.Errors.Add( new SemanticError("Cannot access function '" + _funcInfo.ToString() + "'", treeInfo.GetErrorInfo(treeInfo.Current))); } } }
private void CheckSemanticLocal(MoveInfo treeInfo, ScriptInfo scriptInfo, CheckingInfo checkingInfo) { _funcInfo = scriptInfo.FindLocalFunc(_name); if (_funcInfo == null) // find in includes { _funcInfo = scriptInfo.FindIncludesFunc(_name); if (_funcInfo == null) { scriptInfo.SF.Errors.Add( new SemanticError("Unknown function '" + _name + "'", treeInfo.GetErrorInfo(treeInfo.Current))); return; } if (_funcInfo.Access == MemberAccess.Private) { scriptInfo.SF.Errors.Add( new SemanticError("Cannot access member '" + _funcInfo.ToString() + "'", treeInfo.GetErrorInfo(treeInfo.Current))); } } scriptInfo.References.Add(new FuncRefInfo(scriptInfo.SF, _funcInfo, this.CharIndex, this.CharLength, checkingInfo.SC.SourceCode.Substring(this.CharIndex, this.CharLength), false)); }
private void CGForInStat(FuncInfo funcInfo, ForInStatNode node) { funcInfo.EnterScope(true); LocalVarDecStatNode varDecStatNode = new LocalVarDecStatNode(); varDecStatNode.ExpList = node.ExpList; varDecStatNode.NameList = new List <ConstExpNode>() { new ConstExpNode(new Token(TokenType.Identifier, "for_generator", -1)), new ConstExpNode(new Token(TokenType.Identifier, "for_state", -1)), new ConstExpNode(new Token(TokenType.Identifier, "for_control", -1)) }; foreach (var name in node.NameList.NameList) { funcInfo.AddLocalVar(name.name); } int jmpToTFCPC = funcInfo.EmitJMP(0, 0); CGBlock(funcInfo, node.DoBlock.Block); funcInfo.FixSBX(jmpToTFCPC, funcInfo.PC() - jmpToTFCPC); var geneartor = funcInfo.VarDic1["for_generator"]; funcInfo.EmitTForCall(geneartor.RegIndex, node.NameList.NameList.Count); funcInfo.EmitTForLoop(geneartor.RegIndex + 2, jmpToTFCPC - funcInfo.PC() - 1); funcInfo.ExitScope(); }
private void CGTableConstructorExp(FuncInfo funcInfo, TableConstructorExpNode node, int a) { int nArray = 0; foreach (var key in node.KeyExpList) { var nilNode = key as ConstExpNode; if (nilNode != null && nilNode.ExpType == ConstExpNode.ConstExpType.NilExp) { nArray++; } } int nExps = node.KeyExpList.Count; funcInfo.EmitNewTable(a, nArray, nExps - nArray); int i = 0; foreach (var key in node.KeyExpList) { var nilNode = key as ConstExpNode; var valNode = node.ValExpList[i]; if (nilNode.ExpType == ConstExpNode.ConstExpType.NilExp) { } int b = funcInfo.AllocReg(); CGExp(funcInfo, key, b, 1); int c = funcInfo.AllocReg(); CGExp(funcInfo, valNode, c, 1); funcInfo.FreeRegs(2); funcInfo.EmitSetTable(a, b, c); i++; } }
private static void CheckOutParam(ParsingInfo parsingInfo, Expression exp, MoveInfo parentInfo) { if (parsingInfo.OutParamFuncCall != null) { FuncInfo funcInfo = parsingInfo.OutParamFuncInfo; if (parsingInfo.OutParamFuncArgIndex < funcInfo.Parameters.Count) { if (funcInfo.Parameters[parsingInfo.OutParamFuncArgIndex].IsOut) { // check exp content List <IElement> expChildren = exp.GetChildren(); if (expChildren.Count != 0 && (expChildren[0] is VarName) && ((VarName)expChildren[0]).GetChildren().Count == 1) { VarName varName = (VarName)expChildren[0]; string varNameStr = varName.ToString(); parsingInfo.CurrentFunc.LocalVars.Add(new LocalVarInfo(parsingInfo.SF, varNameStr, varName.CharIndex, varName.CharLength, null, varName)); } else { throw new SyntaxException("Only VarName is allowed as out parameter", parentInfo.GetErrorInfo()); } } } parsingInfo.OutParamFuncArgIndex++; } }
public Prototype GenPrototype(BlockNode block) { var mainFunc = new FuncdefExpNode(); mainFunc.Block = block; mainFunc.IsVararg = false; mainFunc.ParList = new List <ConstExpNode>(); FuncInfo funcInfo = new FuncInfo(); funcInfo.UpVarDic.Add("_ENV", new UpValInfo(-1, 0, 0)); paser.CGBlock(funcInfo, block); VM.LuaVM vm = new VM.LuaVM(); //vm.e System.Diagnostics.Stopwatch watch = new System.Diagnostics.Stopwatch(); var p = ToPrototype(funcInfo); watch.Start(); //开始监视代码运行时间 // try // { vm.LuaMain(p); // } // catch(Exception e) // { // // } watch.Stop(); //停止监视 TimeSpan timespan = watch.Elapsed; //获取当前实例测量得出的总时间 Console.WriteLine("打开窗口代码执行时间:{0}(毫秒)", timespan.TotalMilliseconds); //总毫秒数 Console.WriteLine("生成完毕!"); return(null); }
private void CGNameExp(FuncInfo funcInfo, ConstExpNode node, int a) { LocalVarInfo varInfo = null; int r = 0; if (funcInfo.VarDic1.TryGetValue(node.name, out varInfo)) { funcInfo.EmitMove(a, varInfo.RegIndex); } else if (funcInfo.UpValOfIndex(node.name) != -1) { r = funcInfo.UpValOfIndex(node.name); funcInfo.EmitGetUpval(a, r); } //else if (funcInfo.ConstDic.TryGetValue(node.name, out r)) // { // funcInfo.EmitLoadK(a, node.name); // } else { var exp = new TableAccessExpNode(); exp.PreExp = new ConstExpNode(new Token(TokenType.Identifier, "_ENV", -1)); exp.Exp = new ConstExpNode(new Token(TokenType.String, node.name, -1)); CGTableAccessExp(funcInfo, exp, a); } }
private void CGForNumStat(FuncInfo funcInfo, ForNumStatNode node) { funcInfo.EnterScope(true); LocalVarDecStatNode varDecStatNode = new LocalVarDecStatNode(); varDecStatNode.ExpList = new List <ExpNode>() { node.InitExp, node.LimitExp, node.StepExp }; if (node.StepExp == null) { varDecStatNode.ExpList[2] = new ConstExpNode(new Token(TokenType.Number, "1", -1)); } varDecStatNode.NameList = new List <ConstExpNode>() { new ConstExpNode(new Token(TokenType.Identifier, "for_index", -1)), new ConstExpNode(new Token(TokenType.Identifier, "for_limit", -1)), new ConstExpNode(new Token(TokenType.Identifier, "for_step", -1)) }; CGLocalVarDefStat(funcInfo, varDecStatNode); funcInfo.AddLocalVar(node.VarName.name); int a = funcInfo.UsedReg - 4; int forPrepPC = funcInfo.EmitForPrep(a, 0); CGBlock(funcInfo, node.DoBlock.Block); int forLoopPC = funcInfo.EmitForLoop(a, 0); funcInfo.FixSBX(forPrepPC, forLoopPC - forPrepPC - 1); funcInfo.FixSBX(forLoopPC, forPrepPC - forLoopPC - 1); funcInfo.ExitScope(); }
private void ConsultarResponsavel(FuncColecao funcColecao) { Form_ConsultarColecao form_ConsultarColecao = new Form_ConsultarColecao(); foreach (FuncInfo func in funcColecao) { Form_Consultar form_Consultar = new Form_Consultar { Cod = string.Format("{0:000}", func.funId), Descricao = func.funNome }; form_ConsultarColecao.Add(form_Consultar); } FormConsultar_Cod_Descricao formConsultar_Cod_Descricao = new FormConsultar_Cod_Descricao(form_ConsultarColecao, "Técnico Responsável"); formConsultar_Cod_Descricao.ShowDialog(this); if (formConsultar_Cod_Descricao.DialogResult == DialogResult.Yes) { textBoxCodTec.Text = formConsultar_Cod_Descricao.Selecionado.Cod; textBoxResponsavel.Text = formConsultar_Cod_Descricao.Selecionado.Descricao; responsavel = negocioFunc.ConsultarFuncPorId(Convert.ToInt32(formConsultar_Cod_Descricao.Selecionado.Cod)); textBoxCodTec.Select(); buttonSalvar.Enabled = true; } }
public FormRelatorioFicha(ServicoInfo serv) { InitializeComponent(); infoServ = serv; clienteInfo = BuscarClientePorId(); infoEletro = negocioServ.ConsultarEletroId(infoServ.serideletro); infoFunc = negociosFunc.ConsultarFuncPorId(infoServ.seridfunc); }
//得到函数的插件配置信息 public static FuncRefInfo GetFuncRefInfo(FuncInfo func) { if (func == null) { return(null); } return(FuncCache.GetFuncRefInfo(func.Name)); }
private void CGUnaryExp(FuncInfo funcInfo, UnaryExpNode node, int a) { int b = funcInfo.AllocReg(); CGExp(funcInfo, node.Exp, b, 1); funcInfo.EmitUnaryOp(a, b, node.OpType); funcInfo.FreeReg(); }
public static bool AddFuncInfoMetaData(string key, FuncInfo func) { if (string.IsNullOrEmpty(key)) { return(false); } return(funcInfoMetaDataCache.TryAdd(key.ToUpper(), func)); }
public static IEnumerable <FuncInfo> GetFuncInfos(IEnumerable <FuncDef> funcDefs, SolverAliases aliasOf, Func <FuncInfo, bool> funcFilter = null) { if (funcFilter == null) { funcFilter = x => true; } return(funcDefs.Select(fd => FuncInfo.Create(fd, aliasOf)).Where(fi => fi != null && funcFilter(fi))); }
Prototype ToPrototype(FuncInfo funcInfo) { uint[] codes = new uint[funcInfo.InstructionList.Count]; for (int i = 0; i < codes.Length; i++) { codes[i] = funcInfo.InstructionList[i].instruction; } return(new Prototype("main", 0, 100, funcInfo.NParam, false, funcInfo.MaxReg, codes, GetUpVal(funcInfo), GetChildProtype(funcInfo), GetConstsVar(funcInfo))); }
public void start() { FuncInfo info = this.getInfo(); if (++info.recCnt == 1) { info.lastRecord = Stopwatch.GetTimestamp(); } }
private void CheckSemanticExtern(MoveInfo treeInfo, ScriptInfo scriptInfo, CheckingInfo checkingInfo) { _path = _pathOrUsing; #region Finding using UsingInfo usingInfoTry = scriptInfo.FindUsing(_path); if (usingInfoTry != null) { if (usingInfoTry.SF != scriptInfo.SF && usingInfoTry.Access != MemberAccess.Public) { scriptInfo.SF.Errors.Add(new SemanticError("Could not access using '" + usingInfoTry.SF.SFPath + "::" + usingInfoTry.Name + "'", treeInfo.GetErrorInfo(_pathElem))); return; } _path = usingInfoTry.SFPath; UsingName usingName = UsingName.ConvertToMe(this, _pathElem, usingInfoTry); scriptInfo.References.Add(new UsingRefInfo(scriptInfo.SF, usingInfoTry, usingName.CharIndex, usingName.CharLength, checkingInfo.SC.SourceCode.Substring(usingName.CharIndex, usingName.CharLength))); } #endregion ScriptFile sf = scriptInfo.SF.Manager.GetSF(_path); if (sf == null) { scriptInfo.SF.Errors.Add( new SemanticError("Could not find file '" + _path + "'", treeInfo.GetErrorInfo(treeInfo.Current))); return; } else if (sf.SI == null) { scriptInfo.SF.Errors.Add( new WarningError("Could not read file '" + _path + "'", treeInfo.GetErrorInfo(treeInfo.Current))); return; } _funcInfo = sf.SI.FindLocalFunc(_name); if (_funcInfo == null) { scriptInfo.SF.Errors.Add( new SemanticError("Unknown function '" + _path + "::" + _name + "'", treeInfo.GetErrorInfo(treeInfo.Current))); return; } // member is private if (sf != scriptInfo.SF && _funcInfo.Access != MemberAccess.Public) { scriptInfo.SF.Errors.Add( new SemanticError("Cannot access function '" + _path + "::" + _name + "'", treeInfo.GetErrorInfo(treeInfo.Current))); } }
private void CGFuncCallStat(FuncInfo funcInfo, FuncCallStatNode node) { var r = funcInfo.AllocReg(); FuncCallExpNode funcCall = new FuncCallExpNode(); funcCall.Args = node.Args; funcCall.NameExp = node.NameExp; funcCall.PreExp = node.PreExp; CGFuncCallExp(funcInfo, funcCall, r, 0); }
public override IResultValue Evaluate() { List <IResultValue> argResults = new List <IResultValue>(); foreach (NodeBase fact in Children) { argResults.Add(fact.Evaluate()); } return(FuncInfo.Invoke(argResults.ToArray())); }
Prototype[] GetChildProtype(FuncInfo funcInfo) { Prototype[] childs = new Prototype[funcInfo.ChildFunc.Count]; int i = 0; foreach (var f in funcInfo.ChildFunc) { childs[i] = ToPrototype(f); } return(childs); }
private void CGTableAccessExp(FuncInfo funcInfo, TableAccessExpNode node, int a) { int b = funcInfo.AllocReg(); CGExp(funcInfo, node.PreExp, b, 1); int c = funcInfo.AllocReg(); CGExp(funcInfo, node.Exp, c, 1); funcInfo.EmitGetTable(a, b, c); funcInfo.FreeRegs(2); }
private void CGVarargExp(FuncInfo funcInfo, ConstExpNode node, int a, int n) { if (!funcInfo.IsVararg) { throw new Exception("this function is not use ... beacuse it is not vararg function"); } else { funcInfo.EmitVararg(a, n); } }
public IDictionary <string, IList <FuncInfo> > LoadFuncInfos(string catalogs) { string sql = @"SELECT r.code,r.funcname,r.USAGE,r.detail,r.example,r.catalogid, c.catalogname,r.resulttype FROM rpt_func r, rpt_funccatalog c WHERE r.catalogid = c.phid and catalogid in ({0}) ORDER BY r.catalogid"; sql = string.Format(sql, catalogs); var datas = this.QueryForDataTable(sql); if (datas == null) { throw new FuncException("无法从数据库加载公式配置信息"); } IDictionary <string, IList <FuncInfo> > funcinfos = new Dictionary <string, IList <FuncInfo> >(); List <FuncInfo> funcInfoList = new List <FuncInfo>(); string catalogid = string.Empty; foreach (DataRow dr in datas.Rows) { if (string.IsNullOrEmpty(catalogid)) { catalogid = dr["catalogid"].TryGetString(); } else { if (catalogid != dr["catalogid"].TryGetString()) { //表示不同的目录处理,则直接加入到dictionary funcinfos.Add(catalogid, funcInfoList); funcInfoList = new List <FuncInfo>(); catalogid = dr["catalogid"].TryGetString(); } } FuncInfo func = new FuncInfo(); func.Module = dr["catalogname"].TryGetString(); func.Name = dr["funcname"].TryGetString(); func.Usage = dr["usage"].TryGetString(); func.Detail = dr["detail"].TryGetString(); func.Example = dr["example"].TryGetString(); func.ResultType = (EnumFuncDataType)dr["resulttype"].TryGetInt(); funcInfoList.Add(func); } if (!string.IsNullOrEmpty(catalogid)) { funcinfos.Add(catalogid, funcInfoList); } return(funcinfos); }
public void CGBlock(FuncInfo funcInfo, BlockNode blockNode) { foreach (var stat in blockNode.StatsNode) { CGStat(funcInfo, stat); } if (blockNode.ReturnNode != null) { CGReturnStat(funcInfo, blockNode.ReturnNode.ExpList); } }
private void CGConcatExp(FuncInfo funcInfo, ConcatExpNode node, int a) { foreach (var exp in node.ExpList) { int r = funcInfo.AllocReg(); CGExp(funcInfo, exp, r, 1); } int c = funcInfo.UsedReg - 1; int b = node.ExpList.Count - 1; funcInfo.FreeRegs(c - b + 1); funcInfo.EmitABC(a, b, c, OP.OP_CONCAT); }
public static void Start(object target = null) { if (CPUCount.CounterList == null) { CPUCount.CounterList = new List <FuncInfo>(); } FuncInfo funcInfo = CPUPerf.getFuncInfo(target); CPUCount.CounterList.Add(funcInfo); if (++funcInfo.recCnt == 1) { funcInfo.lastRecord = Stopwatch.GetTimestamp(); } }
private void CGStat(FuncInfo funcInfo, StatNode node) { switch (node.Type) { case GrammarNodeType.FunctionCallStat: CGFuncCallStat(funcInfo, node as FuncCallStatNode); break; case GrammarNodeType.BreakStat: int pc = funcInfo.EmitJMP(0, 0); funcInfo.AddBreakJmp(pc); break; case GrammarNodeType.DoStat: CGDoStat(funcInfo, node as DoStatNode); break; case GrammarNodeType.RepeatStat: CGRepeatStat(funcInfo, node as RepeatStatNode); break; case GrammarNodeType.WhileStat: CGWhileStat(funcInfo, node as WhileStatNode); break; case GrammarNodeType.ForInStat: CGWhileStat(funcInfo, node as WhileStatNode); break; case GrammarNodeType.IfStat: CGIfStat(funcInfo, node as IfStatNode); break; case GrammarNodeType.ForNumStat: CGForNumStat(funcInfo, node as ForNumStatNode); break; case GrammarNodeType.LocalVarDecStat: CGLocalVarDefStat(funcInfo, node as LocalVarDecStatNode); break; case GrammarNodeType.LocalFuncDefStat: CGLocalFuncDefStat(funcInfo, node as LoacalFuncDefStatNode); break; case GrammarNodeType.AssignStat: CGAssignStat(funcInfo, node as AssignStatNode); break; } }
public static FuncInfo getFuncInfo(object targ) { if (CPUPerf.PerfNameMap == null) { CPUPerf.PerfNameMap = new Dictionary <object, FuncInfo>(); } FuncInfo funcInfo; if (!CPUPerf.PerfNameMap.TryGetValue(targ, out funcInfo)) { funcInfo = new FuncInfo(targ.ToString()); CPUPerf.PerfNameMap.Add(targ, funcInfo); } return(funcInfo); }
public void RegisterStaticFunction(FuncInfo funcInfos) { MethodInfo m = null; if (funcInfos.funcParamTypes == null) { m = register_type_.GetMethod(funcInfos.funcName); } else { m = register_type_.GetMethod(funcInfos.funcName, funcInfos.funcParamTypes); } RegisterFuncByMethodInfo(m, new LuaAPI.lua_CFunction(LuaInstance.CallbackStatic)); }
/// <summary> /// 解析触发点的方法模型 /// </summary> /// <param name="dte"></param> /// <param name="serviceFunc"></param> public static void AnalyzeFunc(DTE2 dte, ref FuncInfo serviceFunc) { var codeModel = (FileCodeModel2)dte.ActiveDocument.ProjectItem.FileCodeModel; var selection = (TextSelection)dte.ActiveDocument.Selection; // 触发的方法信息 var codeFunc = (CodeFunction2)codeModel.CodeElementFromPoint(selection.AnchorPoint, vsCMElement.vsCMElementFunction); var codeClass = (CodeClass2)codeFunc.Parent; serviceFunc.Namespace = codeClass.Namespace.Name; serviceFunc.Class = codeClass.Name; serviceFunc.Func = codeFunc.Name; serviceFunc.ParamNum = codeFunc.Parameters.Count; serviceFunc.IsPublic = codeFunc.Access == vsCMAccess.vsCMAccessPublic; }