Ejemplo n.º 1
0
/*
 * @description Returns the arguments for this function as an AST fragment.
 * @argument None
 * @returns Node
 */
EH_METHOD(Function, args) {
	ASSERT_RESOURCE(Function, "Function.args");
	if(data->type == Function::user_e) {
		return data->args;
	} else {
		throw_ArgumentError("Cannot give arguments for non-user function", "Function.args", obj, ehi);
	}
}
Ejemplo n.º 2
0
/*
 * @description Returns the code for this function as an AST fragment.
 * @argument None
 * @returns Node
 */
EH_METHOD(Function, code) {
	ASSERT_RESOURCE(Function, "Function.code");
	if(data->type == Function::user_e) {
		return data->code;
	} else {
		throw_ArgumentError("Cannot give code for non-user function", "Function.code", obj, ehi);
	}
}
Ejemplo n.º 3
0
EH_METHOD(Map, operator_arrow) {
	ASSERT_RESOURCE(Map, "Map.operator->");
	if(data->has(args, ehi)) {
		return data->get(args, ehi);
	} else {
		return nullptr;
	}
}
Ejemplo n.º 4
0
EH_METHOD(Map_Iterator, peek) {
	args->assert_type<Null>("Map.Iterator.peek", ehi);
	ASSERT_RESOURCE(Map_Iterator, "Map.Iterator.peek");
	if(!data->has_next()) {
		throw_EmptyIterator(ehi);
	}
	return data->peek(ehi);
}
Ejemplo n.º 5
0
EH_METHOD(Map_Iterator, next) {
	args->assert_type<Null>("Map.Iterator.next", ehi);
	ASSERT_RESOURCE(Map_Iterator, "Map.Iterator.hasNext");
	if(!data->has_next()) {
		throw_EmptyIterator(ehi);
	}
	return data->next(ehi);
}
Ejemplo n.º 6
0
EH_METHOD(Map, operator_arrow_equals) {
	ASSERT_NARGS(2, "Map.operator->=");
	ASSERT_RESOURCE(Map, "Map.operator->=");
	const Tuple::t *tuple = args->get<Tuple>();
	ehval_p key = tuple->get(0);
	ehval_p value = tuple->get(1);
	data->set(key, value, ehi);
	return value;
}
Ejemplo n.º 7
0
NTSTATUS
ExDeleteResource (
    IN PNTDDK_ERESOURCE Resource
    )

/*++

Routine Description:

    This routine deletes (i.e., uninitializes) the input resource variable


Arguments:

    Resource - Supplies the resource variable being deleted

Return Value:

    None

--*/

{
    ASSERTMSG("Routine cannot be called at DPC ", !KeIsExecutingDpc() );

    ASSERT_RESOURCE( Resource );
    ASSERT( !IsExclusiveWaiting(Resource) );


    if (Resource >= (PNTDDK_ERESOURCE)MM_USER_PROBE_ADDRESS) {
        KIRQL OldIrql;

        ExAcquireSpinLock( &ExpResourceSpinLock, &OldIrql );
        RemoveEntryList( &Resource->SystemResourcesList );
        ExReleaseSpinLock( &ExpResourceSpinLock, OldIrql );

    }

    return STATUS_SUCCESS;
}
Ejemplo n.º 8
0
/*
 * @description Compare two maps.
 * @argument Map to compare to.
 * @returns Integer (as specified for Object.compare)
 */
EH_METHOD(Map, compare) {
	ASSERT_RESOURCE(Map, "Map.compare");
	ASSERT_TYPE(args, Map, "Map.compare");
	eh_map_t *lhs = data;
	eh_map_t *rhs = args->get<Map>();

	eh_map_t::iterator lhs_it = lhs->map.begin();
	eh_map_t::iterator rhs_it = rhs->map.begin();
	eh_map_t::iterator lhs_end = lhs->map.end();
	eh_map_t::iterator rhs_end = rhs->map.end();
	while(true) {
		// check whether we've reached the end
		if(lhs_it == lhs_end) {
			if(rhs_it == rhs_end) {
				break;
			} else {
				return Integer::make(-1);
			}
		} else if(rhs_it == rhs_end) {
			return Integer::make(1);
		}

		// compare keys
		int key_cmp = ehi->compare(lhs_it->first, rhs_it->first, obj);
		if(key_cmp != 0) {
			return Integer::make(key_cmp);
		}

		// compare values
		int value_cmp = ehi->compare(lhs_it->second, rhs_it->second, obj);
		if(value_cmp != 0) {
			return Integer::make(value_cmp);
		}

		// continue iteration
		lhs_it++;
		rhs_it++;
	}
	return Integer::make(0);
}
Ejemplo n.º 9
0
EH_METHOD(Node_Context, getScope) {
	ASSERT_RESOURCE(Node_Context, "Node.Context.getScope");
	return data->scope;
}
Ejemplo n.º 10
0
EH_METHOD(Node_Context, getObject) {
	ASSERT_RESOURCE(Node_Context, "Node.Context.getObject");
	return data->object;
}
Ejemplo n.º 11
0
EH_METHOD(Map, has) {
	ASSERT_RESOURCE(Map, "Map.operator->");
	return Bool::make(data->has(args, ehi));
}
Ejemplo n.º 12
0
EH_METHOD(Map, size) {
	ASSERT_NULL("Map.size");
	ASSERT_RESOURCE(Map, "Map.size");
	return Integer::make(data->size());
}
Ejemplo n.º 13
0
EH_METHOD(Map_Iterator, hasNext) {
	args->assert_type<Null>("Map.Iterator.hasNext", ehi);
	ASSERT_RESOURCE(Map_Iterator, "Map.Iterator.hasNext");
	return Bool::make(data->has_next());
}