diff options
| author | ruki <[email protected]> | 2019-02-15 23:59:37 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2019-02-18 10:09:01 +0800 |
| commit | e9639a1d7ef67477ba12b740e38a5d5b4f774865 (patch) | |
| tree | 451a064cf6a0ab9497278ff8af0bf3ca01f9ab02 /xmake/core/base/scopeinfo.lua | |
| parent | 7f7e2806ac8a10133f564ad5bbb163dc4e0327d1 (diff) | |
add scope info for interpreter
Diffstat (limited to 'xmake/core/base/scopeinfo.lua')
| -rw-r--r-- | xmake/core/base/scopeinfo.lua | 75 |
1 files changed, 75 insertions, 0 deletions
diff --git a/xmake/core/base/scopeinfo.lua b/xmake/core/base/scopeinfo.lua new file mode 100644 index 000000000..2ab0e2788 --- /dev/null +++ b/xmake/core/base/scopeinfo.lua @@ -0,0 +1,75 @@ +--!A cross-platform build utility based on Lua +-- +-- Licensed to the Apache Software Foundation (ASF) under one +-- or more contributor license agreements. See the NOTICE file +-- distributed with this work for additional information +-- regarding copyright ownership. The ASF licenses this file +-- to you under the Apache License, Version 2.0 (the +-- "License"); you may not use this file except in compliance +-- with the License. You may obtain a copy of the License at +-- +-- http://www.apache.org/licenses/LICENSE-2.0 +-- +-- Unless required by applicable law or agreed to in writing, software +-- distributed under the License is distributed on an "AS IS" BASIS, +-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +-- See the License for the specific language governing permissions and +-- limitations under the License. +-- +-- Copyright (C) 2015 - 2019, TBOOX Open Source Group. +-- +-- @author ruki +-- @file scopeinfo.lua +-- + +-- define module +local scopeinfo = scopeinfo or {} +local _instance = _instance or {} + +-- load modules +local io = require("base/io") +local os = require("base/os") +local path = require("base/path") +local table = require("base/table") +local utils = require("base/utils") + +-- new an instance +function _instance.new(kind, info) + local instance = table.inherit(_instance) + instance._KIND = kind or "root" + instance._INFO = info + return instance +end + +-- get the scope kind +function _instance:kind() + return self._KIND +end + +-- is root scope? +function _instance:is_root() + return self:kind() == "root" +end + +-- get all scope info +function _instance:info() + return self._INFO +end + +-- get the scope info from the given name +function _instance:get(name) + return self._INFO[name] +end + +-- set the value to the scope info +function _instance:set(name, value) + self._INFO[name] = value +end + +-- new an scope instance +function scopeinfo.new(name, info) + return _instance.new(name, info) +end + +-- return module +return scopeinfo |
