Esempio n. 1
0
        public virtual void Assign(VarInfo field)
        {
            Code   code = Code.Nop;
            string arg  = "";

            int popCount = 1;

            if (field is MethodVarInfo)
            {
                var methodVar = field as MethodVarInfo;

                code = methodVar.VarType == MethodVarType.Local ? Code.LoadFromStackLocal : Code.LoadFromStackArg;
                arg  = methodVar.Name;
            }
            else if (field is GlobalVarInfo)
            {
                var globalVar = field as GlobalVarInfo;

                bool isPackage = globalVar.Where is PackageType;
                code = isPackage ? Code.LoadFromStackStaticGlobal : Code.LoadFromStackGlobal;
                if (!isPackage)
                {
                    popCount++;
                }
                arg = GetMemberAssignString(globalVar.Where, field);
            }

            Pop(popCount);

            AddCommand(code, arg);
        }
Esempio n. 2
0
        private VarInfo CreateVariableFromCsv(ContentManager contentManager, string strVarInfo)
        {
            try
            {
                string[] info = strVarInfo.Split(':');

                string strParamType = info[2].ToLower();

                ParamType paramType = null;
                if (contentManager.ParamTypes.ContainsKey(strParamType))
                {
                    paramType = contentManager.ParamTypes[strParamType];
                }
                else
                {
                    int iDbg = 0;   // TODO
                }

                VarInfo vi = new VarInfo(info[0], info[1], paramType);
                return(vi);
            }
            catch (Exception ex)
            {
                throw;      // Will be caught by the level above
            }
        }
Esempio n. 3
0
        public void LoadToStack(VarInfo field)
        {
            Code   code      = Code.Nop;
            string val       = "";
            int    pushCount = 1;

            if (field is MethodVarInfo)
            {
                var methodVar = field as MethodVarInfo;

                code = methodVar.VarType == MethodVarType.Local ? Code.LoadLocal : Code.LoadArg;
                val  = methodVar.Name;
            }
            else if (field is GlobalVarInfo)
            {
                var globalVar = field as GlobalVarInfo;

                bool isPackage = globalVar.Where is PackageType;
                code = isPackage ? Code.LoadStaticGlobal : Code.LoadGlobal;
                if (!isPackage)
                {
                    pushCount = 0;
                }

                val = GetMemberCallString(globalVar.Where, field);
            }

            Push(pushCount);

            AddCommand(code, val);
        }
            private void GetVariablesInformation(PropertyInfo[] proPS)
            {
                foreach (var p in proPS)
                {
                    VarInfo v;
                    ShaderReflectionVariable ud = program.GetUniformDescription(p.Name);

                    if (!_varlookup.TryGetValue(p.Name, out v))
                    {
                        v = new VarInfo()
                        {
                            Name    = p.Name,
                            NetProp = p,
                            Desc    = ud,
                            NetType = ud != null ? p.PropertyType : null,
                        };
                        if (v.Desc != null && v.NetType != null)
                        {
                            v.Variable        = CreateVariable(v.NetType, v.Desc);
                            v.Variable.Name   = ud.Name;
                            v.Variable.Binder = program.CreateUniformSetter(ud.Name);
                        }

                        _varlookup.Add(v.Name, v);
                    }
                }
            }
Esempio n. 5
0
    /// <summary>
    /// func-decl -> DEF ID LP type-list RP optional-return-spec brace-block
    /// </summary>
    /// <param name="n"></param>
    private void funcdeclNodeCode(TreeNode n, bool justPutFunctionNameInSymtable)
    {
        var     fname = n.Children[1].Token.Lexeme;
        VarType retType;

        optionalreturnspecNodeCode(n.Children[5], out retType);

        List <VarType> argTypes;
        List <string>  argNames;

        optionaltypelistNodeCode(n.Children[3], out argNames, out argTypes);

        VarType funcType = new FuncVarType(argTypes, retType);

        if (justPutFunctionNameInSymtable)
        {
            if (symtable.ContainsInCurrentScope(fname))
            {
                throw new Exception("Error!! duplicate function decleration in scope!! DupFuncName: " + fname);
            }
            symtable[fname] = new VarInfo(funcType, label());
        }
        else
        {
            symtable.AddScope();
            addParametersToSymbolTable(argNames, argTypes);
            emit("{0}:  ;{1}", symtable[fname].Label, fname);
            prologueCode();
            emit("; braceblock for {0}", fname);
            braceblockNodeCode(n.Children[6], 0);
            emit("; final epilogue for {0}", fname);
            epilogueCode();
            symtable.DeleteScope();
        }
    }
Esempio n. 6
0
    /// <summary>
    /// var-decl -> VAR ID type
    /// type -> non-array-type
    /// non-array-type -> NUM | STRING
    /// </summary>
    /// <param name="n"></param>
    private void vardeclNodeCode(TreeNode n, int sizeOfVariablesDeclaredSoFar, out int sizeOfThisVariable)
    {
        string  vname = n.Children[1].Token.Lexeme;
        VarType type;

        typeNodeCode(n.Children[2], out type);
        sizeOfThisVariable = 8;
        int offset = sizeOfVariablesDeclaredSoFar + 8;

        if (symtable.ContainsInCurrentScope(vname)) //declare variable
        {
            if (symtable[vname].VType == type)
            {
                symtable[vname] = new VarInfo(type, "rbp-" + offset);
            }
            else
            {
                throw new Exception("ERROR!!! Duplicate Decleration!! Symtable already contains: " + vname + " in this scope!!! Mismatch of type");
            }
        }
        else
        {
            if (symtable.ScopeCount == 1) //global
            {
                symtable[vname] = new VarInfo(type, label());
            }
            else //the very first local is at rbp-8
            {
                symtable[vname] = new VarInfo(type, "rbp-" + offset);
            }
        }
    }
    /// <summary>
    /// var-decl -> VAR ID type
    /// type -> non-array-type
    /// non-array-type -> NUM | STRING
    /// </summary>
    /// <param name="n"></param>
    private void vardeclNodeCode(TreeNode n, int sizeOfVariablesDeclaredSoFar, out int sizeOfThisVariable)
    {
        string  vname    = n.Children[1].Token.Lexeme;
        string  vtypestr = n.Children[2].Children[0].Children[0].Token.Symbol;
        VarType vtype    = (VarType)Enum.Parse(typeof(VarType), vtypestr);

        sizeOfThisVariable = 8;
        int offset = sizeOfVariablesDeclaredSoFar + 8;

        if (symtable.ContainsInCurrentScope(vname)) //setting variable to new value as long as its in scope
        {
            if (symtable[vname].VType == vtype)
            {
                symtable[vname] = new VarInfo(vtype, "rbp-" + offset);
            }
            else
            {
                throw new Exception("ERROR!!! Duplicate Decleration!! Symtable already contains: " + vname + " in this scope!!! Mismatch of type");
            }
        }
        else
        {
            if (symtable.ScopeCount == 1) //global
            {
                symtable[vname] = new VarInfo(vtype, label());
            }
            else //the very first local is at rbp-8
            {
                symtable[vname] = new VarInfo(vtype, "rbp-" + offset);
            }
        }
    }
            private void GetVariablesInformation()
            {
                foreach (var cd in program.GetUniformDescriptions())
                {
                    VarInfo v;

                    if (!_varlookup.TryGetValue(cd.Name, out v))
                    {
                        v = new VarInfo()
                        {
                            Desc    = cd,
                            Name    = cd.Name,
                            NetType = ResolveType(cd),
                        };

                        if (v.NetType != null)
                        {
                            v.Variable        = CreateVariable(v.NetType, v.Desc);
                            v.Variable.Name   = cd.Name;
                            v.Variable.Binder = program.CreateUniformSetter(cd.Name);

                            if (v.Variable is ShaderVariableArray && ((ShaderVariableArray)v.Variable).Elements != cd.Type.Elements)
                            {
                                throw new InvalidOperationException("There are two array with the same name \"" + cd.Name + "\" but diferent dimensions in the effect");
                            }
                        }

                        _varlookup.Add(cd.Name, v);
                    }
                }
            }
Esempio n. 9
0
 private static string CallConverter(VarInfo varInfo, bool isGet)
 {
     if (isGet)
     {
         if (varInfo.IsGetStatic)
         {
             return(string.Format("{0} res = {1}.{2};", GetTypeString(varInfo.VarType), varInfo.DeclaringType.FullName, varInfo.Name));
         }
         else
         {
             return(string.Format("{0} res = arg0.{1};", GetTypeString(varInfo.VarType), varInfo.Name));
         }
     }
     else
     {
         if (varInfo.IsSetStatic)
         {
             return(string.Format("{0}.{1} = arg0;", varInfo.DeclaringType.FullName, varInfo.Name));
         }
         else
         {
             return(string.Format("arg0.{0} = arg1;", varInfo.Name));
         }
     }
 }
 /// <summary>
 /// Creates a PropertyDescription from the specified values
 /// </summary>
 /// <param name="propertyName"></param>
 /// <param name="propertyType"></param>
 /// <param name="domainClassType"></param>
 /// <param name="propertyVarInfo"></param>
 public PropertyDescription(string propertyName, Type propertyType, Type domainClassType, VarInfo propertyVarInfo)
 {
     PropertyName    = propertyName;
     PropertyType    = propertyType;
     DomainClassType = domainClassType;
     PropertyVarInfo = propertyVarInfo;
 }
    /// <summary>
    /// factor -> NUM | LP expr RP | STRING-CONSTANT | ID | func-call
    /// </summary>
    /// <param name="n"></param>
    /// <param name="type"></param>
    private void factorNodeCode(TreeNode n, out VarType type)
    {
        var child = n.Children[0];

        switch (child.Symbol)
        {
        case "NUM":
            makeDouble_and_push(child.Token.Lexeme);
            type = VarType.NUMBER;
            break;

        case "LP":
            exprNodeCode(n.Children[1], out type);
            break;

        case "STRING-CONSTANT":     //Stores the address of the string data on stack
            string lbl;
            stringconstantNodeCode(child, out lbl);
            emit("mov rax, {0}", lbl);
            emit("push rax");
            type = VarType.STRING;
            break;

        case "ID":
            string vname = n.Children[0].Token.Lexeme;
            if (!symtable.ContainsInCurrentScope(vname))
            {
                symtable.printScopes();
                throw new Exception("ERROR!!! Undeclared Variable: " + vname);
            }
            VarInfo vi = symtable[vname];
            switch (vi.VType)
            {
            case VarType.NUMBER:
            case VarType.STRING:
                emit("mov rax,[{0}]", symtable[vname].Label);
                emit("push rax");
                break;

            default:
                throw new Exception("ICE!!! Expected type NUMBER or STRING, Recieved: " + vi.VType);
            }
            type = vi.VType;
            break;

        case "func-call":
            funccallNodeCode(child, out type);
            if (type == VarType.VOID)
            {
                throw new Exception("ICE!!! Can't use VOID in math expressions");
            }
            emit("push rax");
            break;

        default:
            throw new Exception("ICE!!! Expected NUM, LP, STRING-CONSTANT, or ID Recieved:" + child.Symbol);
        }
    }
Esempio n. 12
0
        private void ReadWriteVariables(TextReader reader, TextWriter writer)
        {
            List <VarInfo> variables = new List <VarInfo>();

            String string1 = reader.ReadLine();

            while (string1 != null)
            {
                Regex reg = new Regex("(?<type>[\\p{L}0-9_?<>]+ )?(?<text>[\\p{L}0-9_]+)(;)?(\\s)*(,|$|\\t)");

                foreach (Match m in reg.Matches(string1))
                {
                    string type = "String";
                    if (m.Groups["type"].Success)
                    {
                        type = m.Groups["type"].Value;
                    }

                    var inf = new VarInfo {
                        Name = m.Groups["text"].Value, VarType = type
                    };
                    if (CamelCase)
                    {
                        inf.Name = inf.Name.Substring(0, 1).ToUpper() + inf.Name.Substring(1);
                    }
                    variables.Add(inf);
                }
                string1 = reader.ReadLine();
            }


            foreach (var inf in variables)
            {
                String memberName = GetMemberName(inf.Name);
                writer.WriteLine("        private " + inf.VarType + " " + memberName + ";");
            }

            writer.WriteLine();

            foreach (var inf in variables)
            {
                String memberName = GetMemberName(inf.Name);
                writer.WriteLine("public " + inf.VarType + " " + inf.Name + "{get{return " + memberName + ";}set{if(" + memberName + "!=value){" + memberName + "=value;");
                if (propertyChangedCheck.IsChecked == true)
                {
                    if (SimpleNotifyCheckBox.IsChecked == true)
                    {
                        writer.WriteLine("Notify(\"" + inf.Name + "\");");
                    }
                    else
                    {
                        writer.WriteLine("PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(\"" + inf.Name + "\");");
                    }
                }

                writer.WriteLine("} } }");
            }
        }
Esempio n. 13
0
        public VarInfo AddVariable(string name, Type type)
        {
            Raise <ArgumentException> .If(_variables.Any(v => v.Name == name));

            var varInfo = new VarInfo(name, type);

            _variables.Add(varInfo);
            return(varInfo);
        }
Esempio n. 14
0
        public override void GenerateCode(ILCode code, ExpressionAst rightExpr)
        {
            ILGenerator il = code.Method.GetILGenerator();

            //buscar la variable
            VarInfo varInfo = _varAst.CurrentScope.GetVarInfo(_varAst.VarId);

            //--->

            bool pushOnStack = code.PushOnStack;

            code.PushOnStack = true;

            if (_varAst.IsForeignVar)
            //aqui se entra cuando se usa una variable se usa en una funcion que no fue quien la declaro
            {
                string currentParentFunctionCodeName = _varAst.CurrentScope.CurrentFunction.FunctionParent.CodeName;
                //carga el respectivo campo de la clase contenedora.
                //como mis metodos son de instancia y las varibles tambien tengo que cargar el parametro 0
                il.Emit(OpCodes.Ldarg_0);
                //ahora viene cargar la variable de verdad.
                TypeCodeInfo typeCodeInfo = code.GetWrapperAsociatteTo(currentParentFunctionCodeName);
                while (!typeCodeInfo.ContainFieldInLevel1(varInfo.CodeName))
                {
                    //cargo el campo que representa al padre del tipo actual
                    string parentInstanceName = typeCodeInfo.FieldNameOfParent;
                    il.Emit(OpCodes.Ldfld, typeCodeInfo.GetField(parentInstanceName));
                    typeCodeInfo = typeCodeInfo.Parent;
                }
                //pongo el valor que quiero asignar en la pila
                rightExpr.Accept(CodeGenerator);
                //lo asigno.
                il.Emit(OpCodes.Stfld, typeCodeInfo.GetField(varInfo.CodeName));
            }
            else
            {
                if (varInfo.IsLocalVariable)
                {
                    rightExpr.Accept(CodeGenerator);
                    il.Emit(OpCodes.Stloc, code.DefinedLocal[varInfo.CodeName].LocalIndex);
                }
                else if (varInfo.IsParameterFunction)
                {
                    rightExpr.Accept(CodeGenerator);
                    il.Emit(OpCodes.Starg, varInfo.ParameterNumber + 1);
                }
                else // tengo que acceder a la variable a travez de la instancia que tengo como varible local.
                {
                    //se asume que el wrapper siempre esta como primera variable del metodo.
                    il.Emit(OpCodes.Ldloc_0);
                    rightExpr.Accept(CodeGenerator);
                    il.Emit(OpCodes.Stfld, code.DefinedField[varInfo.CodeName]);
                }
            }
            code.PushOnStack = pushOnStack;
        }
 /// <summary>Applies the variable to the builder.</summary>
 public void Apply(VarInfo varInfo)
 {
     foreach (var component in _components)
     {
         if (!component.WasRejected)
         {
             component.Apply(varInfo);
         }
     }
 }
Esempio n. 16
0
    static void addParametersToSymbolTable(List <string> argNames, List <VarType> argTypes)
    {
        int offs = 16;

        for (int i = 0; i < argNames.Count; ++i)
        {
            symtable[argNames[i]] = new VarInfo(argTypes[i], "rbp+" + offs, false);
            offs += 8;
        }
    }
Esempio n. 17
0
 public TestCaseBuilder()
 {
     Script         = null;
     Tags           = new string[0];
     ParamsIn       = new VarInfo[0];
     ParamsOut      = new VarInfo[0];
     _setChecks     = new List <ISetCheckData>();
     IsTestExecuted = true;
     StartLine      = -1;
 }
Esempio n. 18
0
        private TypeInfo Visit(AssignMemberCallNode node, MethodBuilder builder, CodegenContext context)
        {
            var whereType = Visit(node.MemberCallNode.Where as dynamic, builder, context);

            VarInfo varInfo = types.GetType(whereType.Name).GetField(node.MemberCallNode.MemberName);

            context.LastVar = varInfo;

            return(varInfo.Type);
        }
Esempio n. 19
0
    private void addParametersToSymbolTable(List <string> argNames, List <VarType> argTypes)
    {
        int offs = 16;

        for (int i = 0; i < argNames.Count; i++)
        {
            symtable[argNames[i]] = new VarInfo(argTypes[i], "rbp+" + offs, symtable[argNames[i]].isGlobal);
            offs += 8;
        }
    }
Esempio n. 20
0
        private FieldInfo GetFieldInfo(string owner, string field, BindingFlags visibility)
        {
            VarInfo   vi = GetVarInfo(owner);
            FieldInfo fi = vi.VarType.GetField(field, visibility | BindingFlags.Instance);

            if (fi == null)
            {
                throw new KamimuEmitException("Unknown field '" + field + "' in variable '" + owner + "'.");
            }
            return(fi);
        }
Esempio n. 21
0
        //public bool AddLocalVar(string name, TypeInfo type, VarLocation loc)
        //{
        //    return AddLocalVar(new VarInfo(name, type, loc));
        //}
        public VarInfo GetVar(string name)
        {
            VarInfo res = vars.FirstOrDefault(x => x.Name == name);

            if (res == null && Inner != null)
            {
                res = Inner.GetVar(name);
            }

            return(res);
        }
Esempio n. 22
0
        public bool AddVar(VarInfo var)
        {
            bool res = GetVar(var.Name) == null;

            if (res)
            {
                vars.Add(var);
            }

            return(res);
        }
        private void LoadVar(Dsl.CallData callData)
        {
            int num = callData.GetParamNum();

            if (num >= 2)
            {
                VarInfo info = new VarInfo();
                info.m_VarName.InitFromDsl(callData.GetParam(0));
                info.m_ControlPath.InitFromDsl(callData.GetParam(1));
                m_VarInfos.Add(info);
            }
        }
Esempio n. 24
0
        public bool IsLocalOrArg(LexToken token, ref Type theType)
        {
            VarInfo vi = null;

            VarAccess.TryGetValue(token.Str, out vi);
            if (vi == null)
            {
                return(false);
            }
            theType = vi.VarType;
            return(true);
        }
    /// <summary>
    /// var-decl -> VAR ID type
    /// </summary>
    /// <param name="n"></param>
    private void vardeclNodeCode(TreeNode n)
    {
        string  vname    = n.Children[1].Token.Lexeme;
        string  vtypestr = n.Children[2].Children[0].Children[0].Token.Symbol;
        VarType vtype    = (VarType)Enum.Parse(typeof(VarType), vtypestr);

        if (symtable.Contains(vname))
        {
            symtable.printTable();
            throw new Exception("ERRROR!!! Symtable already contains: " + vname);
        }
        symtable[vname] = new VarInfo(vtype, label());
    }
        /**
         * Returns the variable.
         */
        public VarInfo createVar(StringValue name)
        {
            VarInfo var = _varMap.get(name);

            if (var == null)
            {
                var = createVarInfo(name);

                _varMap.put(name, var);
            }

            return(var);
        }
        public void Apply(VarInfo varInfo)
        {
            switch (Attribute)
            {
            // Access levels
            case AttributeType.Public: varInfo.AccessLevel = AccessLevel.Public; break;

            case AttributeType.Protected: varInfo.AccessLevel = AccessLevel.Protected; break;

            case AttributeType.Private: varInfo.AccessLevel = AccessLevel.Private; break;

            // globalvar
            case AttributeType.GlobalVar:
                varInfo.VariableTypeHandler.SetAttribute(true);
                break;

            // playervar
            case AttributeType.PlayerVar:
                varInfo.VariableTypeHandler.SetAttribute(false);
                break;

            // ref
            case AttributeType.Ref:
                varInfo.Ref = true;
                break;

            // in
            case AttributeType.In:
                varInfo.VariableTypeHandler.SetWorkshopReference();
                break;

            // Static
            case AttributeType.Static:
                varInfo.Static = true;
                break;

            // Virtual
            case AttributeType.Virtual:
                varInfo.Virtual = true;
                break;

            // Override
            case AttributeType.Override:
                varInfo.Override = true;
                break;

                // Missing attribute function
                // default:
                //     throw new NotImplementedException();
            }
        }
Esempio n. 28
0
    /// <summary>
    /// array-access -> ID LB expr-list RB
    /// </summary>
    /// <param name="vinfo"></param>
    /// <param name="exprListNode"></param>
    private void putArrayAddressInRcx(VarInfo vinfo, TreeNode exprListNode)
    {
        ArrayVarType typ = vinfo.VType as ArrayVarType;

        if (typ == null)
        {
            throw new Exception("ICE!!! Arraytype cannot be null or typ not Array type!! tpy: " + typ == null ? "null" : typ.typeString);
        }

        List <VarType> types;

        exprlistNodeCode(exprListNode.Children[2], out types); //expr-list -> expr expr-list'
        if (types.Count != typ.arrayDimensions.Count)
        {
            throw new Exception("Error!! Arrays dimension mismatch!!");
        }

        foreach (var t in types)
        {
            if (t != VarType.NUMBER)
            {
                throw new Exception("Error!! only numbers are valid as array indices!! type: " + t.typeString);
            }
        }

        emit("mov rcx, 0");
        for (int i = 0; i < typ.arrayDimensions.Count; i++)
        {
            int product = 1;
            for (int j = i + 1; j < typ.arrayDimensions.Count; j++)
            {
                product *= typ.arrayDimensions[j];
            }
            emit("pop rax");                    //get next from expr-list
            emit("movq xmm0, rax");             //convert to double
            emit("cvtsd2si rax, xmm0");         //convert to int
            emit("imul rax, rax,{0}", product); //dest, op1, op2
            emit("add rcx, rax");
        }

        if (vinfo.isGlobal)
        {
            emit("shl rcx, 3"); //same as imul rcx, 8 but faster
            emit("add rcx, {0}", vinfo.Label);
        }
        else
        {
            emit("lea rcx, [rcx*8+{0}]", vinfo.Label);
        }
    }
Esempio n. 29
0
        public override Unit VisitVar(VarAST ast)
        {
            ILGenerator il = code.Method.GetILGenerator();

            //buscar la variable
            VarInfo varInfo = ast.CurrentScope.GetVarInfo(ast.VarId);
            string  currentFunctionCodeName = ast.CurrentScope.CurrentFunction.CodeName;

            if (ast.IsForeignVar) //se entra aca cuando la variable pertenece a otra funcion que no es la actual .
            {
                //carga el respectivo campo de la clase contenedora.
                //como mis metodos son de instancia y las varibles tambien tengo que cargar el parametro 0
                il.Emit(OpCodes.Ldarg_0);
                //ahora viene cargar la variable de verdad.
                TypeCodeInfo typeCodeInfo =
                    code.GetWrapperAsociatteTo(ast.CurrentScope.CurrentFunction.FunctionParent.CodeName);
                while (typeCodeInfo != null && !typeCodeInfo.ContainFieldInLevel1(varInfo.CodeName))
                {
                    //cargo el campo que representa al padre del tipo actual
                    il.Emit(OpCodes.Ldfld, typeCodeInfo.GetField(typeCodeInfo.FieldNameOfParent));
                    typeCodeInfo = typeCodeInfo.Parent;
                }
                il.Emit(OpCodes.Ldfld, typeCodeInfo.GetField(varInfo.CodeName));
            }
            else
            {
                if (varInfo.IsLocalVariable)
                {
                    il.Emit(OpCodes.Ldloc, code.DefinedLocal[varInfo.CodeName].LocalIndex);
                }
                else if (varInfo.IsParameterFunction)
                {
                    il.Emit(OpCodes.Ldarg, varInfo.ParameterNumber + 1);
                }
                else // tengo que acceder a la variable a travez de la instancia que tengo como varible local.
                {
                    TypeCodeInfo typeCodeInfo = code.GetWrapperAsociatteTo(currentFunctionCodeName);
                    //cargar esta variable local donde estan todas las variables que son usadas por  los demas metodos.
                    il.Emit(OpCodes.Ldloc_0);
                    il.Emit(OpCodes.Ldfld, typeCodeInfo.GetField(varInfo.CodeName));
                }
            }

            //ver si debo dejar el valor en la pila.
            if (!code.PushOnStack)
            {
                il.Emit(OpCodes.Pop);
            }
            return(Unit.Create());
        }
Esempio n. 30
0
    private static string PushConverter(VarInfo varInfo)
    {
        string s;

        if (ContainsKey(pushConverterDict, varInfo.VarType, out s))
        {
            return(string.Format("LuaCallback.Push{0}(L, {1}res); ", s, varInfo.VarType.IsEnum ? "(double)" : ""));
        }
        else
        {
            Debug.LogError("PushConverter Error: " + varInfo.VarType.FullName);
            return(null);
        }
    }
Esempio n. 31
0
 public override bool TryGetVariable(string name, out VarInfo v)
 {
     return _locals.TryGetValue(name, out v) || _parent.TryGetVariable(name, out v);
 }
 internal VarInfo(VarInfo other)
 {
     m_VarName = other.m_VarName.Clone();
     m_ControlPath = other.m_ControlPath.Clone();
 }
Esempio n. 33
0
 public VarInfo AddVariable(string name, Type type)
 {
     Raise<ArgumentException>.If(_variables.Any(v => v.Name == name));
     var varInfo = new VarInfo(name, type);
     _variables.Add(varInfo);
     return varInfo;
 }
Esempio n. 34
0
 public override void SetVariable(string name, VarInfo v)
 {
     throw new TypeCheckException("Internal compiler error");
 }
Esempio n. 35
0
 public override bool TryGetVariable(string name, out VarInfo v)
 {
     v = null;
     return false;
 }
Esempio n. 36
0
 public abstract bool TryGetVariable(string name, out VarInfo v);
Esempio n. 37
0
 public override void SetVariable(string name, VarInfo v)
 {
     Debug.Assert(!_locals.ContainsKey(name));
     _locals[name] = v;
 }
 private void LoadVar(Dsl.CallData callData)
 {
     int num = callData.GetParamNum();
     if (num >= 2) {
         VarInfo info = new VarInfo();
         info.m_VarName.InitFromDsl(callData.GetParam(0));
         info.m_ControlPath.InitFromDsl(callData.GetParam(1));
         m_VarInfos.Add(info);
     }
 }
Esempio n. 39
0
 public abstract void SetVariable(string name, VarInfo v);