예제 #1
0
 public HostBridge(GossipLexer gossipLexer)
 {
     m_HostCallTable = new HostCallTable();
     m_TypeBindingTable = new TypeBindingTable(gossipLexer);
     m_EnumDefineTable = new EnumDefineTable();
     m_ExpressionEvaluator = new ExpressionEvaluator(m_HostCallTable);
     m_EventBindingTable = new EventBindingTable();
 }
예제 #2
0
 public CompilationContext(HostCallTable hostCallTable,
                           StringTable stringTable,
                           EnumDefineTable enumTable,
                           TypeBindingTable typeBindingTable,
                           EventBindingTable eventBindingTable)
 {
     m_HostCallTable = hostCallTable;
     m_StringTable = stringTable;
     m_EnumTable = enumTable;
     m_TypeBindingTable = typeBindingTable;
     m_EventBindingTable = eventBindingTable;
 }
예제 #3
0
        public Int32 GetAccessIndex(EnumDefineTable enumDefineTable)
        {
            string replace = Value.Replace('[', ' ').Replace(']', ' ');
            string[] strSplit = replace.Split(new[] {" "}, StringSplitOptions.RemoveEmptyEntries);
            if (Type == TokenType.LocalFlagAccessEnum ||
                Type == TokenType.LocalStringAccessEnum ||
                Type == TokenType.LocalVariableAccessEnum ||
                Type == TokenType.GlobalFlagAccessEnum ||
                Type == TokenType.GlobalStringAccessEnum ||
                Type == TokenType.GlobalVariableAccessEnum ||
                Type == TokenType.ReferenceObjectAccessEnum)
            {
                if (enumDefineTable.HasEnum(strSplit[1]))
                {
                    return enumDefineTable.DefinesByString[strSplit[1]];
                }
                else
                {
                    throw new GossipScriptException("Invalid index");
                }
            }
            else
            {
                int varIndex = Int32.Parse(strSplit[1]);

                if (Type == TokenType.GlobalVariableAccess || Type == TokenType.GlobalFlagAccess ||
                    Type == TokenType.GlobalStringAccess)
                {
                    if (varIndex < 0 || varIndex >= 1024)
                        throw new GossipScriptException("Index out of bounds");
                }
                if (Type == TokenType.LocalFlagAccess || Type == TokenType.LocalVariableAccess ||
                    Type == TokenType.LocalStringAccess)
                {
                    if (varIndex < 0 || varIndex >= 64)
                        throw new GossipScriptException("Index out of bounds");
                }
                return varIndex;
            }
        }